| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/include/appl/diag/bal_cmd.h sdk-all-6.5.7/include/appl/diag/bal_cmd.h |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/include/appl/diag/bal_cmd.h 1970-01-01 02:00:00.000000000 +0200 |
| +++ sdk-all-6.5.7/include/appl/diag/bal_cmd.h 2017-01-26 11:24:18.251278489 +0200 |
| @@ -0,0 +1,22 @@ |
| +/****************************************************************************** |
| + * |
| + * Copyright 2016 - Broadcom Corporation |
| + * |
| + ******************************************************************************/ |
| + |
| +#ifndef BAL_CMD_H |
| +#define BAL_CMD_H |
| + |
| +#include <appl/diag/shell.h> |
| + |
| +static char cmd_bal_usage[] = |
| + "bal [cmd]\n\t" |
| + "Commands:\n\t" |
| + " trap_target <target_ip:port> - Set a remote ip and port to receive local cpu trapped packets\n\t" |
| + " trap_receive <sender_ip:port> - Set a local port to receive remote sender_ip messages \n\t" |
| + "\n\t" |
| + "When called with no parameters, initialize the BAL BCM Api and enter the bal sub-shell.\n"; |
| + |
| +cmd_result_t cmd_bal(int unit, args_t *args); |
| + |
| +#endif |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/include/bcm/rx.h sdk-all-6.5.7/include/bcm/rx.h |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/include/bcm/rx.h 2016-12-01 05:15:05.000000000 +0200 |
| +++ sdk-all-6.5.7/include/bcm/rx.h 2017-01-26 11:30:12.960122166 +0200 |
| @@ -1789,5 +1789,18 @@ |
| bcm_rx_cosq_mapping_t *rx_cosq_mapping); |
| |
| #endif /* BCM_HIDE_DISPATCHABLE */ |
| + |
| +/* |
| + * BAL patch to allow RPC register packet receive callback |
| + */ |
| +typedef void (*dpp_rx_cb_f) ( |
| + int unit, |
| + int port, |
| + int reason, |
| + unsigned char *pkt, |
| + int pkt_len); |
| + |
| +extern |
| +void dpp_dft_tx_cb(int unit, int port, int reason, unsigned char *payload, int payload_len); |
| |
| #endif /* __BCM_RX_H__ */ |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Make.config sdk-all-6.5.7/make/Make.config |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Make.config 2016-12-01 05:16:16.000000000 +0200 |
| +++ sdk-all-6.5.7/make/Make.config 2017-01-26 11:34:39.553494599 +0200 |
| @@ -32,6 +32,13 @@ |
| # } |
| endif |
| |
| +ifeq (${BUILD_ING_AS_LIB},1) |
| +CFGFLAGS += -DBUILD_ING_AS_LIB -DNO_CTRL_C |
| +endif |
| +ifeq (${CONFIG_SWITCH_RPC},y) |
| +CFGFLAGS += -DCONFIG_SWITCH_RPC |
| +endif |
| + |
| # |
| # Set a default target if one is not set. If override-target is set, |
| # then the target will become override-target and a warning is printed |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Make.local.bal sdk-all-6.5.7/make/Make.local.bal |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Make.local.bal 1970-01-01 02:00:00.000000000 +0200 |
| +++ sdk-all-6.5.7/make/Make.local.bal 2017-01-26 11:36:43.722735752 +0200 |
| @@ -0,0 +1,30 @@ |
| +#FEATURE_LIST := CINT L3 I2C MEM_SCAN EDITLINE TEST BCM_SAL_PROFILE CUSTOMER CHASSIS RCPU ATPTRANS_SOCKET DUNE_UI INTR APIMODE PTP KBP |
| +FEATURE_LIST := CINT L3 I2C MEM_SCAN EDITLINE TEST BCM_SAL_PROFILE CHASSIS RCPU ATPTRANS_SOCKET DUNE_UI INTR APIMODE PTP |
| + |
| +DEBUG_CFLAGS=-Wdeclaration-after-statement |
| + |
| +BCM_PTL_SPT=1 |
| + |
| +ALL_DPP_CHIPS = 1 |
| +ALL_DFE_CHIPS = 1 |
| + |
| +# Includes XML library and enables use of "diag pp dump" utility for PP import/export facilities |
| +DATAIO_SUPPORT = 1 |
| +KERN_VER=3.7.10 |
| + |
| +CFGFLAGS += -DSTATIC=static |
| +CFGFLAGS += -DBCM_WARM_BOOT_SUPPORT |
| +CFGFLAGS += -DBCM_WARM_BOOT_SUPPORT_SW_DUMP |
| +CFGFLAGS += -DBCM_EASY_RELOAD_WB_COMPAT_SUPPORT |
| +CFGFLAGS += -DBCM_CONTROL_API_TRACKING |
| +CFGFLAGS += -D__DUNE_LINUX_BCM_CPU_PCIE__ |
| +CFGFLAGS += -DPHYS_ADDRS_ARE_64BITS -DSAL_BDE_32BIT_USER_64BIT_KERNEL |
| +CFGFLAGS += -D_SIMPLE_MEMORY_ALLOCATION_=0 -DUSE_LINUX_BDE_MMAP=1 |
| +CFGFLAGS += -DSCACHE_CRC_CHECK |
| + |
| +CFGFLAGS += -DBROADCOM_SVK |
| + |
| +#KBP_DEVICE := KBP_ALG |
| + |
| +VENDOR_LIST=CUSTOMER78 BROADCOM DNX |
| + |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Makefile.unix-linux sdk-all-6.5.7/make/Makefile.unix-linux |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Makefile.unix-linux 2016-12-01 05:16:17.000000000 +0200 |
| +++ sdk-all-6.5.7/make/Makefile.unix-linux 2017-01-26 13:16:35.035828648 +0200 |
| @@ -47,7 +47,7 @@ |
| |
| |
| # Linux |
| -LIBS= -lnsl -lpthread -lm -lrt |
| +LIBS= -lnsl -pthread -lm -lrt |
| CFGFLAGS += -DBCM_PLATFORM_STRING=\"unix-linux\" |
| |
| # For GCC 4.2.x, add -Wno-address |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Makefile.unix-linux-64 sdk-all-6.5.7/make/Makefile.unix-linux-64 |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Makefile.unix-linux-64 2016-12-01 05:16:17.000000000 +0200 |
| +++ sdk-all-6.5.7/make/Makefile.unix-linux-64 2017-01-26 13:17:35.959446054 +0200 |
| @@ -48,7 +48,7 @@ |
| FEATURE_EXCLUDE_LIST = $(sort $(_FEATURE_EXCLUDE_LIST)) |
| |
| # Linux |
| -LIBS= -lnsl -lpthread -lm -lrt |
| +LIBS= -lnsl -pthread -lm -lrt |
| |
| CFGFLAGS += -DBCM_PLATFORM_STRING=\"unix-linux-64\" |
| |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Makefile.unix-linux~ sdk-all-6.5.7/make/Makefile.unix-linux~ |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Makefile.unix-linux~ 1970-01-01 02:00:00.000000000 +0200 |
| +++ sdk-all-6.5.7/make/Makefile.unix-linux~ 2017-01-26 13:16:34.973829038 +0200 |
| @@ -0,0 +1,60 @@ |
| +# $Id: Makefile.unix-linux,v 1.11 Broadcom SDK $ |
| +# $Copyright: (c) 2016 Broadcom. |
| +# Broadcom Proprietary and Confidential. All rights reserved.$ |
| +# |
| +# Build rules for Linux/x86 (Little Endian) with PLI support |
| + |
| +include ${SDK}/make/Makefile.unix-common |
| + |
| +# When using GDB on Linux, you may want to use "setenv GDB 1" to disable |
| +# editline. For best results put "set environment GDB 1" in your .gdbinit. |
| + |
| +# Linux-specific Configuration Flags |
| + |
| +ENDIAN_DEF = -DLE_HOST=1 |
| + |
| +# Notes on AMD Athlon 64-bit |
| +# |
| +# Compiles on x86_64 default to 32-bit emulation unless 64-bit mode |
| +# is specifically requested in Make.local by uncommenting the two defines |
| +# for PTRS_ARE_64BITS and LONGS_ARE_64BITS. |
| +# |
| +# Note that the code base will compile in 64-bit mode, but will not run |
| +# correctly because malloc() can return values >32 bits and the PLISIM |
| +# protocol only supports 32-bit addresses. |
| + |
| +ifeq ($(shell uname -m),x86_64) |
| + ifeq (,$(findstring -DPTRS_ARE_64BITS,$(CFGFLAGS))) |
| + CC = ${HCC} -m32 |
| + CXX = g++ -m32 |
| + else |
| + CC = ${HCC} |
| + CXX = g++ |
| + endif |
| +endif |
| + |
| +LD = ld |
| +AR = ar |
| +ARFLAGS = -rc |
| +STRIP = strip |
| +RANLIB = ranlib |
| + |
| +# Filter out features that cannot or should not be supported in Linux |
| +ifdef ESW_CHIPS |
| +_FEATURE_EXCLUDE_LIST += OOB_RCPU |
| +endif |
| +FEATURE_EXCLUDE_LIST = $(sort $(_FEATURE_EXCLUDE_LIST)) |
| + |
| + |
| +# Linux |
| +LIBS= -lnsl -lpthread -lm -lrt |
| +CFGFLAGS += -DBCM_PLATFORM_STRING=\"unix-linux\" |
| + |
| +# For GCC 4.2.x, add -Wno-address |
| +GCC_MAJOR_VER = $(shell echo |$(CC) -dM -E -| grep __GNUC__ | cut -d' ' -f3) |
| +GCC_MINOR_VER = $(shell echo |$(CC) -dM -E -| grep __GNUC_MINOR__ | cut -d' ' -f3) |
| +ifeq (${GCC_MAJOR_VER}, 4) |
| +ifeq (${GCC_MINOR_VER}, 2) |
| +BCM_EXTRA_CC_CFLAGS = -Wno-address |
| +endif |
| +endif |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Makefile.unix-netbsd sdk-all-6.5.7/make/Makefile.unix-netbsd |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Makefile.unix-netbsd 2016-12-01 05:16:17.000000000 +0200 |
| +++ sdk-all-6.5.7/make/Makefile.unix-netbsd 2017-01-26 13:13:03.884156251 +0200 |
| @@ -27,7 +27,7 @@ |
| FEATURE_EXCLUDE_LIST = $(sort $(_FEATURE_EXCLUDE_LIST)) |
| |
| # NetBSD |
| -LIBS= -lpthread -lm -lsem |
| ++LIBS= -pthread -lm -lsem |
| |
| CFGFLAGS += -DBCM_PLATFORM_STRING=\"unix-netbsd\" |
| |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Makefile.unix-user sdk-all-6.5.7/make/Makefile.unix-user |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/make/Makefile.unix-user 2016-12-01 05:16:17.000000000 +0200 |
| +++ sdk-all-6.5.7/make/Makefile.unix-user 2017-01-26 13:14:29.289618967 +0200 |
| @@ -42,7 +42,7 @@ |
| OSTYPE = LINUX |
| |
| # Linux |
| -LIBS= -lnsl -lpthread -lm -lrt |
| +LIBS= -lnsl -pthread -lm -lrt |
| |
| # |
| # ORIGIN is used to Optionally select different CFLAGS. It is used to import |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/appl/diag/bal_cmd.c sdk-all-6.5.7/src/appl/diag/bal_cmd.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/appl/diag/bal_cmd.c 1970-01-01 02:00:00.000000000 +0200 |
| +++ sdk-all-6.5.7/src/appl/diag/bal_cmd.c 2017-01-26 11:38:20.574144410 +0200 |
| @@ -0,0 +1,837 @@ |
| +/****************************************************************************** |
| + * |
| + * Copyright 2015- Broadcom Corporation |
| + * This program is the proprietary software of Broadcom Corporation |
| + * and/or its licensors, and may only be used, duplicated, modified or |
| + * distributed pursuant to the terms and conditions of a separate, |
| + * written license agreement executed between you and Broadcom (an |
| + * "Authorized License"). Except as set forth in an Authorized License, |
| + * Broadcom grants no license (express or implied), right to use, or |
| + * waiver of any kind with respect to the Software, and Broadcom |
| + * expressly reserves all rights in and to the Software and all |
| + * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED |
| + * LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND |
| + * SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE |
| + * SOFTWARE. |
| + * |
| + * Except as expressly set forth in the Authorized License, |
| + * |
| + * 1. This program, including its structure, sequence and organization, |
| + * constitutes the valuable trade secrets of Broadcom, and you shall use |
| + * all reasonable efforts to protect the confidentiality thereof, and to |
| + * use this information only in connection with your use of Broadcom |
| + * integrated circuit products. |
| + * |
| + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED |
| + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, |
| + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR |
| + * OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY |
| + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, |
| + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, |
| + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR |
| + * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT |
| + * OF USE OR PERFORMANCE OF THE SOFTWARE. |
| + * |
| + * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM |
| + * OR ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, |
| + * INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY |
| + * RELATING TO YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF |
| + * BROADCOM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR (ii) |
| + * ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE SOFTWARE |
| + * ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE LIMITATIONS SHALL APPLY |
| + * NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED |
| + * REMEDY. |
| + * |
| + ******************************************************************************/ |
| + |
| +/** |
| + * @file bal_cmd.c_ |
| + * @brief BAL ING CLI commands support SDK access that is not supported by regular CLI |
| + * The BAL CLI command line interface is implemented by the CLI |
| + * module. The CLI module can be used as the configuration and management |
| + * interface for the BAL Switch Util. BAL Switch Util configuration can be specified |
| + * using a series of BAL CLI commands. The main purpose of the CLI is to provide |
| + * ING API access that are not normally available through public API, such as RPC |
| + * access to ING features that are deep in SDK stack. |
| + * |
| + **/ |
| + |
| + /*@{*/ |
| + |
| +/* --- system includes --- */ |
| + |
| +#include <unistd.h> |
| +#include <stdio.h> |
| +#include <string.h> |
| +#include <ctype.h> |
| +#include <stdlib.h> |
| +#include <appl/diag/shell.h> |
| +#include <appl/diag/parse.h> |
| +#include <sal/appl/sal.h> |
| +#include <sal/appl/editline/editline.h> |
| +#include <errno.h> |
| +#include <sys/types.h> |
| +#include <sys/socket.h> |
| +#include <netinet/in.h> |
| +#include <arpa/inet.h> |
| +#include <bcm/rx.h> |
| +#include <bcm/error.h> |
| +#include <bcm/stack.h> |
| + |
| +#define BAL_CLI_VERSION "1.0" |
| + |
| +/* --- project includes --- */ |
| +extern int start_trap_service(char *ip_port); |
| +extern int start_host_listener(char *ip_port); |
| + |
| +/* --- local static constants ---*/ |
| +#define BAL_SWITCH_CLI_IP_LEN 128 |
| +typedef struct bal_switch_cli_cfg_t |
| +{ |
| + char trap_target[BAL_SWITCH_CLI_IP_LEN]; /* remote ip:port address where the trapped packet sent */ |
| + char trap_receive[BAL_SWITCH_CLI_IP_LEN]; /* remote ip where the local port receive message */ |
| +}bal_switch_cli_cfg_t; |
| + |
| +static bal_switch_cli_cfg_t g_cur_ctx; |
| + |
| +static bal_switch_cli_cfg_t *gp_cur_ctx = &g_cur_ctx; |
| + |
| +enum |
| +{ |
| + BAL_REASON_SEND_TO_NNI = 1, |
| + BAL_REASON_SEND_TO_PON |
| +}; |
| + |
| +/** |
| + * * @brief Maximum number of arguments supported by the 'bal' CLI command |
| + * */ |
| +#define MAX_ARGS 10 |
| + |
| +/** |
| + ** @brief BAL CLI help text |
| + **/ |
| +#define HELP \ |
| +"exit - Exit the BAL sub-shell\n" \ |
| +"show - Show current settings\n" \ |
| +"trap_target - register callback and send CPU trapped packets to remote IP:PORT\n" \ |
| +"trap_receive - Start a receiving thread to listen on PORT for messages from remote IP \n" \ |
| + |
| + |
| +/** |
| + ** @brief BAL Switch App help text specific to 'show' commands |
| + **/ |
| +#define SHOW_HELP \ |
| +"show config - Display the BAL CLI configuration\n" \ |
| +"show version - Display the BAL BCM SDK version\n" \ |
| + |
| + |
| +/** |
| + * @brief CLI prompt string |
| + * */ |
| +static char g_bal_cli_prompt[8]; |
| + |
| + |
| +/* |
| + * @brief BAL Switch App help text |
| + * |
| + * @return char* A string containing the prompt to display |
| + **/ |
| +static char *bal_set_prompt() |
| +{ |
| + sprintf(g_bal_cli_prompt, "bal>"); |
| + return g_bal_cli_prompt; |
| +} |
| + |
| +/** |
| + * @brief Parse a line of input into a POSIX-like argument list |
| + * |
| + ** @param parsed_input Unparsed line of CLI input |
| + ** @param argc Pointer to the number of arguments in the list |
| + ** @param argv Pointer to the argument list |
| + ** @return int Number of argument that has been successfully parsed |
| + **/ |
| +int bal_parse_input (char *parsed_input, int *argc, char **argv) |
| +{ |
| + char *s; |
| + int largc; |
| + |
| + largc = 0; |
| + s = parsed_input; |
| + while ((largc < MAX_ARGS) && (s != NULL) && (*s != 0)) |
| + { |
| + /* Skip leading whitespace */ |
| + s += strspn (s, " \t"); |
| + |
| + /* Non-whitespace found */ |
| + if (*s != 0) |
| + { |
| + /* Add the string to the argument list */ |
| + argv[largc++] = s; |
| + |
| + /* Find the trailing whitespace (if any...) */ |
| + s = strpbrk (s, " \t"); |
| + if (s != NULL) |
| + { |
| + /* Found some white space, null out the first white |
| + space character. */ |
| + if (largc < MAX_ARGS) |
| + { |
| + *s++ = 0; |
| + } |
| + |
| + /* Otherwise, don't null the last param, to pass it on |
| + * command to parse themselves |
| + */ |
| + } |
| + } |
| + } |
| + |
| + *argc = largc; |
| + |
| + return largc; |
| +} |
| + |
| + /* BAL packet_in function and definitions */ |
| + typedef struct |
| + { |
| + int socket; |
| + struct sockaddr_in addr; |
| + }trap_target_t; |
| + static trap_target_t s_target_device; |
| + static int target_init = 0; |
| + #define DEFAULT_SOP_ADJ 2 |
| + #define DEFAULT_REASON_ADJ 4 |
| + |
| + bcm_rx_t trap_service_cb(int unit, bcm_pkt_t *pkt, void *cookie) |
| + { |
| + |
| + uint8 *p_payload; |
| + int dpp_hdr_len, payload_len, n_sent; |
| + trap_target_t *p_target_device = (trap_target_t *)cookie; |
| + uint16 *p_src_port, def_sop; |
| + uint32 *p_reason, def_reason; |
| + /* skip the dpp header - 19 bytes */ |
| + p_payload = pkt->_pkt_data.data; |
| + dpp_hdr_len = pkt->tot_len - pkt->pkt_len + 0; |
| + payload_len = pkt->tot_len - dpp_hdr_len; |
| + p_payload += dpp_hdr_len; |
| + |
| + /* |
| + * replace SOP_ADJ bytes with source port info before send |
| + * assuming DEFAULT_SOP_ADJ is always 2 bytes |
| + * replace SOP_REASON bytes with trap reason - TBD |
| + */ |
| + p_src_port = (uint16 *)(p_payload - DEFAULT_SOP_ADJ); |
| + /* save the original info */ |
| + def_sop = *(p_src_port); |
| + /* replace 2 bytes with ingress port info */ |
| + *p_src_port = htons(pkt->src_port & 0xff); /* pkt->src_port is 1 byte long */ |
| + |
| + p_reason = (uint32 *)(p_payload - DEFAULT_SOP_ADJ - DEFAULT_REASON_ADJ); |
| + /* save the original info */ |
| + def_reason = *(p_reason); |
| + /* replace 4 bytes with reason code */ |
| + *p_reason = htonl(pkt->rx_trap_data); |
| + |
| + n_sent = sendto(p_target_device->socket, |
| + p_payload-DEFAULT_SOP_ADJ-DEFAULT_REASON_ADJ, |
| + payload_len+DEFAULT_SOP_ADJ+DEFAULT_REASON_ADJ, 0, |
| + (struct sockaddr *) &(p_target_device->addr), |
| + sizeof(struct sockaddr_in)); |
| + |
| + /* put back the original values */ |
| + *p_src_port = def_sop; |
| + *p_reason = def_reason; |
| + |
| + if (n_sent > 0) |
| + return BCM_RX_HANDLED; |
| + else |
| + return BCM_RX_NOT_HANDLED; |
| + } |
| + |
| + int start_trap_service( char *ip_port) |
| + { |
| + int ret, port; |
| + char ip[80], *col; |
| + |
| + if(target_init == 0) |
| + { |
| + if((s_target_device.socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) |
| + { |
| + return -1; |
| + } |
| + target_init = 1; |
| + } |
| + /* fill in traget device info - ip_port has the format of ip:port, so look for ":" for separation */ |
| + col = strstr(ip_port, ":"); |
| + port = atoi(col+1); |
| + /* terminate the string at the end of IP address */ |
| + *col = 0; |
| + strcpy(ip, ip_port); |
| + |
| + s_target_device.addr.sin_family = AF_INET; |
| + s_target_device.addr.sin_port = htons(port); |
| + s_target_device.addr.sin_addr.s_addr = inet_addr(ip); |
| + |
| + ret = bcm_rx_register(0, "Cpu Traps", trap_service_cb, 50, (void *)&s_target_device, BCM_RCO_F_ALL_COS); |
| + return ret; |
| + } |
| + |
| +/** |
| + ** @brief CLI parser and handler for 'trap_target' commands |
| + ** |
| + ** This routine handles the 'bal trap_target [args]' CLI app configuration |
| + ** commands. |
| + ** |
| + ** @param argc Pointer to the number of arguments in the list |
| + ** @param argv Pointer to the argument list |
| + * */ |
| +void bal_bcm_cli_trap_target(int argc, char **argv) |
| +{ |
| + |
| + if (argc != 1) |
| + { |
| + printf("Invalid arguments\n"); |
| + return; |
| + } |
| + |
| + { |
| + strcpy(gp_cur_ctx->trap_target, argv[0]); |
| + /* Configure the trap target with the specified setting. */ |
| + if (start_trap_service(argv[0]) != 0) |
| + { |
| + printf("Error, failed to start trap service on '%s'\n", |
| + argv[0]); |
| + } |
| + } |
| +} |
| + |
| +typedef struct |
| +{ |
| + int udp_port; |
| + sal_thread_t threadid; |
| + dpp_rx_cb_f callback; |
| +}trap_context_t; |
| + |
| + static trap_context_t trap_ctx = {0}; |
| + static int listener_init = 0; |
| + |
| +#define MAX_RX_PACKET_SIZE (2000) |
| + |
| +static void host_receive(void *p_user_data) |
| +{ |
| + int rc; |
| + int sUDPSocket; |
| + unsigned char cBuffer[MAX_RX_PACKET_SIZE]; |
| + int nBytesRecv = 0; |
| + int nBufSize = MAX_RX_PACKET_SIZE; |
| + socklen_t nReceiveAddrSize = 0; |
| + int maxfd; |
| + fd_set read_fds; |
| + struct timeval tv; |
| + uint16 *p_dst_port, dst_port; |
| + trap_context_t *p_trap_ctx = (trap_context_t *)p_user_data; |
| + uint32 *p_reason, reason; |
| + struct sockaddr_in sReceiveFromAddr; |
| + |
| + /* Create a connectionless socket */ |
| + sUDPSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); |
| + /* Check to see if we have a valid socket */ |
| + if(sUDPSocket < 0) |
| + { |
| + printf(" host_receive:create socket failed\n"); |
| + return; |
| + } |
| + |
| + /* Setup a bind on the socket, telling us what port and |
| + * adapter to receive datagrams on. |
| + * NOTE: we accept UDP packets from any sender as long |
| + * as they arrive on the specified port. |
| + */ |
| + memset(&sReceiveFromAddr, 0, sizeof(struct sockaddr_in)); |
| + |
| + sReceiveFromAddr.sin_family = AF_INET; |
| + sReceiveFromAddr.sin_port = htons(p_trap_ctx->udp_port); |
| + sReceiveFromAddr.sin_addr.s_addr = htonl(INADDR_ANY); |
| + |
| + rc = bind(sUDPSocket, (struct sockaddr *)&sReceiveFromAddr, |
| + sizeof(struct sockaddr_in)); |
| + if (rc < 0) |
| + { |
| + printf("host_receive:bind failed\n"); |
| + return; |
| + } |
| + |
| + // Receive a datagram from another device |
| + while(1) |
| + { |
| + FD_ZERO(&read_fds); |
| + FD_SET(sUDPSocket, &read_fds); |
| + maxfd = sUDPSocket; |
| + /* Set the timeout */ |
| + tv.tv_sec = 1; |
| + tv.tv_usec = 0; /* 1 seconds */ |
| + rc = select(maxfd + 1, &read_fds, NULL, NULL, &tv); |
| + |
| + if (rc < 0) |
| + { |
| + printf(" host_receive:select failed err = %d\n", rc); |
| + break; |
| + } |
| + if (rc == 0) |
| + { |
| + fflush(stdout); |
| + continue; |
| + } |
| + // Get the datagram |
| + nBytesRecv = recvfrom(sUDPSocket, cBuffer, nBufSize, 0, |
| + (struct sockaddr *) &sReceiveFromAddr, |
| + &nReceiveAddrSize); |
| + printf("Got %d bytes message \n", nBytesRecv); |
| + /* the first 4 bytes are reason */ |
| + p_reason = (uint32 *)(cBuffer); |
| + reason = ntohl(*p_reason); |
| + |
| + /* the next 2 bytes are destination port */ |
| + p_dst_port = (uint16 *)(cBuffer + DEFAULT_REASON_ADJ); |
| + dst_port = ntohs(*p_dst_port); |
| + |
| + /* call the register callback here - set unit to 0 as it is don't care */ |
| + if(p_trap_ctx->callback) |
| + { |
| + p_trap_ctx->callback(0, |
| + dst_port, |
| + reason, |
| + cBuffer+DEFAULT_SOP_ADJ+DEFAULT_REASON_ADJ, |
| + nBytesRecv-DEFAULT_SOP_ADJ-DEFAULT_REASON_ADJ); |
| + } |
| + } |
| + close(sUDPSocket); |
| + |
| + return; |
| +} |
| + |
| + |
| +void dpp_dft_tx_cb(int unit, int dst_port, int reason, unsigned char *payload, int payload_len) |
| +{ |
| + |
| + int i; |
| + bcm_pkt_t *tx_pkt; |
| + uint8_t tx_pkt_dune_header[6]; |
| + uint32_t tx_pkt_offset = 0; |
| + bcm_gport_t sys_gport; |
| + bcm_gport_t local_gport; |
| + bcm_port_t sysport = 0; |
| + bcm_gport_t local_cpu_port = 0; |
| + int sdk_rc; |
| + |
| + printf("Msg from core:\n"); |
| + printf(" dst port:%d, rcv reason: 0x%x, ", dst_port, reason); |
| + |
| + /* dump out first 32 bytes */ |
| + printf("payload (first 12 bytes): "); |
| + for(i=0; i<12; i++) |
| + { |
| + if(i%6 == 0 && i) printf(" "); |
| + printf("%02x", payload[i]); |
| + } |
| + printf("\n"); |
| + |
| + |
| + /* Map the local port number to a CPU "system" port. */ |
| + local_gport = dst_port; |
| + sdk_rc = bcm_stk_gport_sysport_get(unit, local_gport, &sys_gport); |
| + if (sdk_rc != BCM_E_NONE) |
| + { |
| + /* Error */ |
| + printf("%s(): [PacketOut] bcm_stk_gport_sysport_get returned with failure code '%s'\n", |
| + __FUNCTION__, bcm_errmsg(sdk_rc)); |
| + return; |
| + } |
| + |
| + sysport = sys_gport & 0xff; |
| + |
| + /* Get the local CPU port */ |
| + sdk_rc = bcm_port_local_get(unit, BCM_GPORT_LOCAL_CPU, &local_cpu_port); |
| + if (sdk_rc != BCM_E_NONE) |
| + { |
| + /* Error */ |
| + printf("%s(): [PacketOut] bcm_port_local_get returned with failure code '%s'\n", |
| + __FUNCTION__, bcm_errmsg(sdk_rc)); |
| + return; |
| + } |
| + |
| + /* Allocate a packet structure */ |
| + sdk_rc = bcm_pkt_alloc(unit, payload_len+sizeof(tx_pkt_dune_header), 0, &tx_pkt); |
| + |
| + if (sdk_rc != BCM_E_NONE) |
| + { |
| + /* Error */ |
| + printf("%s(): [PacketOut] bcm_pkt_alloc returned with failure code '%s'\n", |
| + __FUNCTION__, bcm_errmsg(sdk_rc)); |
| + return; |
| + } |
| + |
| + /* Set up the packet for a single block */ |
| + tx_pkt->call_back = 0; |
| + tx_pkt->blk_count = 1; |
| + tx_pkt->unit = unit; |
| + |
| + /* Dune TM header */ |
| + tx_pkt->_dpp_hdr[3] = 0x00; /* channel num */ |
| + tx_pkt->_dpp_hdr[2] = 0x00; |
| + tx_pkt->_dpp_hdr[1] = 0x00; |
| + tx_pkt->_dpp_hdr[0] = 0x00; |
| + |
| + tx_pkt->_dpp_hdr_type = 1; /* DPP_HDR_itmh_base */ |
| + |
| + /* PTCH */ |
| + tx_pkt_dune_header[0] = 0x50; |
| + tx_pkt_dune_header[1] = local_cpu_port; |
| + |
| + /* ITMH */ |
| + tx_pkt_dune_header[2] = 0x01; |
| + tx_pkt_dune_header[3] = 0x00; |
| + tx_pkt_dune_header[4] = (sysport & 0xff); /* Destination port */ |
| + tx_pkt_dune_header[5] = 0x00; |
| + |
| + /* Insert the DUNE header into the packet */ |
| + bcm_pkt_memcpy (tx_pkt, tx_pkt_offset, tx_pkt_dune_header, sizeof(tx_pkt_dune_header)); |
| + tx_pkt_offset += sizeof(tx_pkt_dune_header); |
| + |
| + /* Insert the payload into the packet */ |
| + bcm_pkt_memcpy (tx_pkt, tx_pkt_offset, payload, payload_len); |
| + tx_pkt_offset += payload_len; |
| + |
| + printf("%s(): [PacketOut] transmitting a %d length packet, " |
| + "sys_gport:0x%X, sysport: %d\n", |
| + __FUNCTION__, |
| + payload_len, |
| + sys_gport, |
| + sysport); |
| + |
| + /* Transmit the packet */ |
| + sdk_rc = bcm_tx(unit, tx_pkt, NULL); |
| + if (sdk_rc != BCM_E_NONE) |
| + { |
| + /* Error */ |
| + printf( "%s(): bcm_tx returned with failure code '%s'\n", |
| + __FUNCTION__, bcm_errmsg(sdk_rc)); |
| + } |
| + |
| + /* Cleanup */ |
| + bcm_pkt_free(unit, tx_pkt); |
| + |
| + return; |
| +} |
| + |
| +void dpp_dft_msg_cb(int unit, int dst_port, int reason, unsigned char *payload, int payload_len) |
| +{ |
| + |
| + int i, len; |
| + |
| + printf("Msg from core:\n"); |
| + printf(" dst port:%d, rcv reason: 0x%x, ", dst_port, reason); |
| + |
| + len = (payload_len > 32)? 32: payload_len; |
| + |
| + /* dump out first 32 bytes */ |
| + printf("payload (first %d bytes): ", len); |
| + for(i=0; i<len; i++) |
| + { |
| + if(i%8 == 0 && i) printf(" "); |
| + printf("%02x", payload[i]); |
| + } |
| + printf("\n"); |
| + |
| + return; |
| +} |
| + |
| +void dpp_dft_host_cb(int unit, int dst_port, int reason, unsigned char *payload, int payload_len) |
| +{ |
| + switch(reason) |
| + { |
| + case BAL_REASON_SEND_TO_NNI: |
| + case BAL_REASON_SEND_TO_PON: |
| + dpp_dft_tx_cb(unit, dst_port, reason, payload, payload_len); |
| + break; |
| + default: |
| + dpp_dft_msg_cb(unit, dst_port, reason, payload, payload_len); |
| + break; |
| + } |
| + return; |
| +} |
| + |
| + |
| + |
| + |
| + |
| + |
| + |
| + |
| + |
| + |
| +/* |
| + * This is the function that is called to start a thread to listen for |
| + * packets sent from BAL to bcm.user for injection into the switch. |
| + * |
| + * This happens when the user includes the trap_receive identifier in |
| + * the rpc.soc file that is co-resident with the bcm.user executable. |
| + * |
| + ** An example line in the rpc.soc file might be: |
| + * |
| + * dune "sand trap_receive 10.3.2.2:50003" |
| + * |
| + * This line specifies to listen on port 50003 and that messages will |
| + * arrive from IP 10.3.2.2 (although the IP address is not respected |
| + * in this code). |
| + * |
| + * */ |
| +int start_host_listener(char *ip_port) |
| + { |
| + |
| + char *col; |
| + |
| + if(listener_init != 0) |
| + { |
| + return 0; |
| + } |
| + |
| + /* fill in host listener info - ip_port has the format of ip:port, so look for ":" for separation */ |
| + col = strstr(ip_port, ":"); |
| + trap_ctx.udp_port = atoi(col+1); |
| + |
| + /* register a default handler */ |
| + trap_ctx.callback = dpp_dft_host_cb; |
| + |
| + /* spawn a thread to listen to socket */ |
| + trap_ctx.threadid = sal_thread_create("trap_rx", 8192, 50, host_receive, &trap_ctx); |
| + |
| + if (trap_ctx.threadid == SAL_THREAD_ERROR) |
| + { |
| + return -2; |
| + } |
| + |
| + listener_init = 1; |
| + return 0; |
| + } |
| + |
| +/** |
| + ** @brief CLI parser and handler for 'trap_receive' commands |
| + ** |
| + ** This routine handles the 'bal trap_receive [args]' CLI app configuration |
| + ** commands. |
| + ** |
| + ** @param argc Pointer to the number of arguments in the list |
| + ** @param argv Pointer to the argument list |
| + * */ |
| +void bal_bcm_cli_trap_receive(int argc, char **argv) |
| +{ |
| + |
| + if (argc != 1) |
| + { |
| + printf("Invalid arguments\n"); |
| + return; |
| + } |
| + |
| + { |
| + strcpy(gp_cur_ctx->trap_receive, argv[0]); |
| + /* Configure the msg receiver with the specified setting. */ |
| + if (start_host_listener(argv[0]) != 0) |
| + { |
| + printf("Error, failed to start trap listener on '%s'\n", |
| + argv[0]); |
| + } |
| + } |
| +} |
| + |
| +/** |
| + ** @brief Handler for the 'bal show version' command |
| + ** |
| + ** This routine handles the 'bal show version' CLI command |
| + ** and show version information on the console. |
| + ** |
| + **/ |
| +void bal_bcm_show_version(void) |
| +{ |
| + |
| + /* Print out the software revision information */ |
| + printf("Broadcom Software, Broadband Abstraction Layer, CLI Version %s \n", |
| + BAL_CLI_VERSION); |
| +} |
| + |
| + |
| +/** |
| + ** @brief CLI parser and handler for 'show' commands |
| + ** |
| + ** This routine handles the 'bal show [args]' CLI app commands. |
| + ** |
| + ** @param argc Pointer to the number of arguments in the list |
| + ** @param argv Pointer to the argument list |
| + **/ |
| +void bal_bcm_cli_show(int argc, char **argv) |
| +{ |
| + char *show_cmd; |
| + |
| + show_cmd = argv[0]; |
| + |
| + if (argc == 0) |
| + { |
| + printf("Error: missing show sub-command.\n"); |
| + printf("%s", SHOW_HELP); |
| + return; |
| + } |
| + |
| + show_cmd = argv[0]; |
| + |
| + if (sal_strcasecmp(show_cmd, "config") == 0) |
| + { |
| + printf("BAL BCM App Configuration:\n"); |
| + printf("--------------------------------\n"); |
| + printf("trap_target ip_port = %s\n", gp_cur_ctx->trap_target); |
| + printf("trap_receive ip_port = %s\n", gp_cur_ctx->trap_receive); |
| + } |
| + else if (sal_strcasecmp(show_cmd, "version") == 0) |
| + { |
| + bal_bcm_show_version(); |
| + } |
| + else if (sal_strcasecmp(show_cmd, "help") == 0 || |
| + sal_strcasecmp(show_cmd, "?") == 0) |
| + { |
| + printf("%s", SHOW_HELP); |
| + } |
| + else |
| + { |
| + printf("Error: unknown show command '%s'.\n", show_cmd); |
| + } |
| +} |
| + |
| +/** |
| + ** @brief Executes a command as specified by a single line of CLI input |
| + ** |
| + ** @param argc Pointer to the number of arguments in the list |
| + ** @param argv Pointer to the argument list |
| + **/ |
| +void DoCmd(int argc, char **argv) |
| +{ |
| + char *cmd; |
| + |
| + if (argc == 0 || argv[0] == NULL) |
| + { |
| + return; |
| + } |
| + |
| + cmd = argv[0]; |
| + |
| + printf("CLI executing command '%s'\n", cmd); |
| + |
| + if (sal_strcasecmp(cmd, "trap_target") == 0) |
| + { |
| + bal_bcm_cli_trap_target(argc-1, &argv[1]); |
| + } |
| + else if (sal_strcasecmp(cmd, "trap_receive") == 0) |
| + { |
| + bal_bcm_cli_trap_receive(argc-1, &argv[1]); |
| + } |
| + else if (sal_strcasecmp(cmd, "show") == 0) |
| + { |
| + bal_bcm_cli_show(argc-1, &argv[1]); |
| + } |
| + else if (sal_strcasecmp(cmd, "help") == 0 || |
| + sal_strcasecmp(cmd, "?") == 0) |
| + { |
| + /* Display help */ |
| + printf("%s", HELP); |
| + } |
| + else if (sal_strcasecmp(cmd, "exit") == 0) |
| + { |
| + return; |
| + } |
| + else |
| + { |
| + printf("Unknown command '%s'\n", cmd); |
| + } |
| +} |
| + |
| +/** |
| + * * @brief Main processing loop for the CLI |
| + * * |
| + * * @param args Pointer to an BCM SDK formatted argument list |
| + * */ |
| +void bal_cli_shell(args_t *args) |
| +{ |
| + char *cmd; |
| + int argc = 0; |
| + char *argv[MAX_ARGS]; |
| + static int initialized = 0; |
| + |
| + if (initialized == 0) |
| + { |
| + bal_set_prompt(); |
| + initialized = 1; |
| + } |
| + |
| + if (args->a_argc > 1) |
| + { |
| + |
| + DoCmd(args->a_argc-1, &args->a_argv[1]); |
| + } |
| + else |
| + { |
| + |
| + printf("CLI running in interactive mode\n"); |
| + |
| + for (;;) |
| + { |
| + /* use ING editline library, DONT free pointer "cmd" as Linux man readline |
| + suggested, it will cause a crash */ |
| + cmd = readline(g_bal_cli_prompt); |
| + if (*cmd != '\0') |
| + { |
| + add_history(cmd); |
| + } |
| + else |
| + { |
| + continue; |
| + } |
| + |
| + if ((sal_strcasecmp(cmd, "exit") == 0) || (sal_strcasecmp(cmd, "quit") == 0)) |
| + { |
| + printf ("exiting bal shell.\n"); |
| + break; |
| + } |
| + |
| + bal_parse_input(cmd, &argc, argv); |
| + |
| + DoCmd(argc, argv); |
| + |
| + } |
| + } |
| + |
| + /* "Consume" all of the command line arguments so the bcm.user shell |
| + * does not complain. |
| + */ |
| + args->a_arg = args->a_argc; |
| +} |
| + |
| +/** |
| + * @brief The cmdlist hook for the BAL BCM App CLI command |
| + * |
| + * This file contains the function to "hook" into the main bcm.user |
| + * CLI. |
| + * |
| + * @param unit SDK unit number |
| + * @param args Pointer to an BCM SDK formatted argument list |
| + * |
| + * @return cmd_result_t |
| + * |
| + * */ |
| +cmd_result_t cmd_bal(int unit, args_t *args) |
| +{ |
| + /* char *subcmd = ARG_GET(args); */ |
| + |
| + bal_cli_shell(args); |
| + |
| + return CMD_OK; |
| +} |
| +/*@}*/ |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/appl/diag/cmdlist.c sdk-all-6.5.7/src/appl/diag/cmdlist.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/appl/diag/cmdlist.c 2016-12-01 05:16:25.000000000 +0200 |
| +++ sdk-all-6.5.7/src/appl/diag/cmdlist.c 2017-01-26 12:04:04.992722758 +0200 |
| @@ -57,6 +57,7 @@ |
| |
| #include <appl/diag/diag.h> |
| #include <appl/diag/cmdlist.h> |
| +#include <appl/diag/bal_cmd.h> |
| |
| cmd_t *cur_cmd_list[SOC_MAX_NUM_DEVICES]; |
| int cur_cmd_cnt[SOC_MAX_NUM_DEVICES]; |
| @@ -98,6 +99,9 @@ |
| "Attach SOC device(s)" }, |
| {"BackGround", sh_bg, sh_bg_usage, |
| "Execute a command in the background."}, |
| + /* BAL ING API support */ |
| + {"BAL", cmd_bal, cmd_bal_usage, |
| + "Run a BAL ING Api command."}, |
| #if defined(INCLUDE_BCMX_DIAG) |
| {"BCM", cmd_mode_bcm, shell_bcm_usage, |
| "Set shell mode to BCM."}, |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/appl/diag/ctrans.c sdk-all-6.5.7/src/appl/diag/ctrans.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/appl/diag/ctrans.c 2016-12-01 05:16:25.000000000 +0200 |
| +++ sdk-all-6.5.7/src/appl/diag/ctrans.c 2017-01-26 12:23:48.883393220 +0200 |
| @@ -1016,6 +1016,7 @@ |
| return rv; |
| } |
| |
| +#define BAL_CMD_LEN 128 |
| |
| bcm_rx_t |
| ab_echo_cb(cpudb_key_t src_key, |
| @@ -1033,6 +1034,8 @@ |
| int mode; |
| int len; |
| CallbackOptions *options = (CallbackOptions *)cookie; |
| + char bal_cmd[BAL_CMD_LEN]; |
| + int bal_cmd_len; |
| |
| if (payload == NULL) { /* Just use first segment for string */ |
| if (pkt == NULL) { |
| @@ -1085,6 +1088,9 @@ |
| _send_echo_pkt(client_id, payload, len, depth - 1, |
| pkt_flags, mode, options->verbose, src_key, NULL); |
| } |
| + bal_cmd_len = ((len-offset) >= BAL_CMD_LEN)? BAL_CMD_LEN-1: len-offset; |
| + memcpy(bal_cmd, &payload[offset], bal_cmd_len); |
| + bal_cmd[bal_cmd_len] = 0; |
| |
| if (async_free) { |
| rv = BCM_RX_HANDLED_OWNED; |
| @@ -1093,6 +1099,13 @@ |
| rv = BCM_RX_HANDLED; |
| } |
| |
| + /** if string has special cli prefix !>, execute the cli command */ |
| + if(bal_cmd[0] == '!' && bal_cmd[1] == '>') |
| + { |
| + cli_out("Execute BAL CLI cmd -> %s\n", &bal_cmd[2]); |
| + sh_process_command(0, &bal_cmd[2]); |
| + } |
| + |
| return rv; |
| } |
| |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/appl/diag/shell.c sdk-all-6.5.7/src/appl/diag/shell.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/appl/diag/shell.c 2016-12-01 05:16:25.000000000 +0200 |
| +++ sdk-all-6.5.7/src/appl/diag/shell.c 2017-01-26 12:31:49.873427400 +0200 |
| @@ -214,10 +214,15 @@ |
| var_unset("ihost_mode", FALSE, TRUE, FALSE); |
| var_unset("num_ucs", FALSE, TRUE, FALSE); |
| } |
| + |
| +#ifdef CONFIG_SWITCH_RPC |
| + cli_out("Running with remote hardware, skip setting unit variable\n"); |
| + return; |
| +#endif |
| |
| if (new_unit >= 0) { |
| - uint16 dev_id; |
| - uint8 rev_id; |
| + uint16 dev_id; |
| + uint8 rev_id; |
| char *chip_string; |
| uint16 dev_id_driver; |
| uint8 rev_id_driver; |
| @@ -466,7 +471,9 @@ |
| /* Not attached, print out error */ |
| if (override_unit) |
| return TRUE; |
| +#ifndef BUILD_ING_AS_LIB |
| cli_out("%s: Error: Unit %d not attached\n", pfx, u); |
| +#endif |
| return(FALSE); |
| } |
| return(TRUE); |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/appl/diag/system.c sdk-all-6.5.7/src/appl/diag/system.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/appl/diag/system.c 2016-12-01 05:16:25.000000000 +0200 |
| +++ sdk-all-6.5.7/src/appl/diag/system.c 2017-01-26 12:35:45.001982454 +0200 |
| @@ -2379,7 +2379,13 @@ |
| DISPLAY_MEM_PRINTF(("%s(): Just before BCM shell\r\n",__FUNCTION__)) ; |
| |
| while (1) { |
| + |
| +#ifndef BUILD_ING_AS_LIB |
| sh_process(-1, "BCM", TRUE); |
| +#else |
| + return; |
| +#endif |
| + |
| #ifdef NO_SAL_APPL |
| return; |
| #else |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/bcm/dpp/alloc_mngr_cosq.c sdk-all-6.5.7/src/bcm/dpp/alloc_mngr_cosq.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/bcm/dpp/alloc_mngr_cosq.c 2016-12-01 05:16:47.000000000 +0200 |
| +++ sdk-all-6.5.7/src/bcm/dpp/alloc_mngr_cosq.c 2017-01-26 12:43:50.511008400 +0200 |
| @@ -3644,6 +3644,7 @@ |
| if (flow_type == SOC_TMC_AM_SCH_FLOW_TYPE_CONNECTOR) { |
| region = _BCM_DPP_AM_COSQ_GET_REGION_INDEX_FROM_FLOW_INDEX(*flow_id); |
| if (nof_remote_cores != SOC_DPP_CONFIG(unit)->arad->region_nof_remote_cores[core][region]) { |
| + printf(" nof_remote_cores %d != %d at core %d region %d\n", nof_remote_cores, SOC_DPP_CONFIG(unit)->arad->region_nof_remote_cores[core][region], core, region); |
| BCMDNX_ERR_EXIT_MSG(BCM_E_PARAM,(_BSL_BCM_MSG("Requested region doesn't support requested number of remote cores"))); |
| } |
| } |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/bcm/rpc/pack.c sdk-all-6.5.7/src/bcm/rpc/pack.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/bcm/rpc/pack.c 2016-12-01 05:17:00.000000000 +0200 |
| +++ sdk-all-6.5.7/src/bcm/rpc/pack.c 2017-01-26 12:52:51.016711143 +0200 |
| @@ -9975,6 +9975,9 @@ |
| uint8 * |
| _bcm_pack_rx_trap_config(uint8 *buf, bcm_rx_trap_config_t *var) |
| { |
| + uint8 zero_8 = 0; |
| + uint32 zero_32 = 0; |
| + |
| BCM_PACK_U32(buf, var->flags); |
| BCM_PACK_U32(buf, var->dest_port); |
| BCM_PACK_U32(buf, var->dest_group); |
| @@ -9989,12 +9992,32 @@ |
| BCM_PACK_U32(buf, var->forwarding_type); |
| BCM_PACK_U32(buf, var->forwarding_header); |
| BCM_PACK_U32(buf, var->encap_id); |
| - BCM_PACK_U32(buf, var->mirror_cmd->flags); |
| - BCM_PACK_U8(buf, var->mirror_cmd->forward_strength); |
| - BCM_PACK_U8(buf, var->mirror_cmd->copy_strength); |
| - BCM_PACK_U32(buf, var->mirror_cmd->recycle_cmd); |
| - BCM_PACK_U32(buf, var->core_config_arr->dest_port); |
| - BCM_PACK_U32(buf, var->core_config_arr->encap_id); |
| + |
| + if(var->mirror_cmd) |
| + { |
| + BCM_PACK_U32(buf, var->mirror_cmd->flags); |
| + BCM_PACK_U8(buf, var->mirror_cmd->forward_strength); |
| + BCM_PACK_U8(buf, var->mirror_cmd->copy_strength); |
| + BCM_PACK_U32(buf, var->mirror_cmd->recycle_cmd); |
| + } |
| + else |
| + { |
| + BCM_PACK_U32(buf, zero_32); |
| + BCM_PACK_U8(buf, zero_8); |
| + BCM_PACK_U8(buf, zero_8); |
| + BCM_PACK_U32(buf, zero_32); |
| + } |
| + if(var->core_config_arr) |
| + { |
| + BCM_PACK_U32(buf, var->core_config_arr->dest_port); |
| + BCM_PACK_U32(buf, var->core_config_arr->encap_id); |
| + } |
| + else |
| + { |
| + BCM_PACK_U32(buf, zero_32); |
| + BCM_PACK_U32(buf, zero_32); |
| + } |
| + |
| BCM_PACK_U32(buf, var->core_config_arr_len); |
| BCM_PACK_U32(buf, var->qos_map_id); |
| BCM_PACK_U32(buf, var->tunnel_termination_trap_strength); |
| @@ -10005,6 +10028,9 @@ |
| uint8 * |
| _bcm_unpack_rx_trap_config(uint8 *buf, bcm_rx_trap_config_t *var) |
| { |
| + uint8 var_8, temp; |
| + uint32 var_32; |
| + |
| BCM_UNPACK_U32(buf, var->flags); |
| BCM_UNPACK_U32(buf, var->dest_port); |
| BCM_UNPACK_U32(buf, var->dest_group); |
| @@ -10019,12 +10045,40 @@ |
| BCM_UNPACK_U32(buf, var->forwarding_type); |
| BCM_UNPACK_U32(buf, var->forwarding_header); |
| BCM_UNPACK_U32(buf, var->encap_id); |
| - BCM_UNPACK_U32(buf, var->mirror_cmd->flags); |
| - BCM_UNPACK_U8(buf, var->mirror_cmd->forward_strength); |
| - BCM_UNPACK_U8(buf, var->mirror_cmd->copy_strength); |
| - BCM_UNPACK_U32(buf, var->mirror_cmd->recycle_cmd); |
| - BCM_UNPACK_U32(buf, var->core_config_arr->dest_port); |
| - BCM_UNPACK_U32(buf, var->core_config_arr->encap_id); |
| + |
| + if(var->mirror_cmd) |
| + { |
| + BCM_UNPACK_U32(buf, var->mirror_cmd->flags); |
| + BCM_UNPACK_U8(buf, var->mirror_cmd->forward_strength); |
| + BCM_UNPACK_U8(buf, var->mirror_cmd->copy_strength); |
| + BCM_UNPACK_U32(buf, var->mirror_cmd->recycle_cmd); |
| + } |
| + else |
| + { |
| + BCM_UNPACK_U32(buf, var_32); |
| + BCM_UNPACK_U8(buf, var_8); |
| + BCM_UNPACK_U8(buf, var_8); |
| + BCM_UNPACK_U32(buf, var_32); |
| + /* make compiler happy : unsed-but-set */ |
| + temp = var_8; |
| + var_8 = var_32; |
| + var_32 = temp; |
| + } |
| + if(var->core_config_arr) |
| + { |
| + BCM_UNPACK_U32(buf, var->core_config_arr->dest_port); |
| + BCM_UNPACK_U32(buf, var->core_config_arr->encap_id); |
| + } |
| + else |
| + { |
| + BCM_UNPACK_U32(buf, var_32); |
| + BCM_UNPACK_U32(buf, var_32); |
| + /* make compiler happy : unsed-but-set */ |
| + temp = var_8; |
| + var_8 = var_32; |
| + var_32 = temp; |
| + } |
| + |
| BCM_UNPACK_U32(buf, var->core_config_arr_len); |
| BCM_UNPACK_U32(buf, var->qos_map_id); |
| BCM_UNPACK_U32(buf, var->tunnel_termination_trap_strength); |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/bcm/rpc/server.c sdk-all-6.5.7/src/bcm/rpc/server.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/bcm/rpc/server.c 2016-12-01 05:17:00.000000000 +0200 |
| +++ sdk-all-6.5.7/src/bcm/rpc/server.c 2017-01-26 12:59:00.779462885 +0200 |
| @@ -111294,11 +111294,19 @@ |
| r_p_config = NULL; |
| } else { |
| r_p_config = &config; |
| + bcm_rx_trap_config_t_init(r_p_config); |
| (void) _bcm_unpack_rx_trap_config(r_pp, r_p_config); |
| } |
| bcm_rpc_free(r_pkt, r_cookie); |
| |
| - r_ret = bcm_rx_trap_set(unit, trap_id, r_p_config); |
| + if(r_p_config) |
| + { |
| + r_ret = bcm_rx_trap_set(unit, trap_id, r_p_config); |
| + } |
| + else |
| + { |
| + r_ret = BCM_E_EMPTY; |
| + } |
| |
| r_pkt = bcm_rpc_setup('S', (uint32 *)0, 4, r_seq, r_ret); |
| r_pp = r_pkt + BCM_RPC_HLEN+4; |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/systems/linux/user/common/socdiag.c sdk-all-6.5.7/systems/linux/user/common/socdiag.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/systems/linux/user/common/socdiag.c 2016-12-01 05:18:40.000000000 +0200 |
| +++ sdk-all-6.5.7/systems/linux/user/common/socdiag.c 2017-01-26 13:02:16.000246446 +0200 |
| @@ -177,7 +177,11 @@ |
| /* |
| * Main loop. |
| */ |
| -int main(int argc, char *argv[]) |
| +#ifndef BUILD_ING_AS_LIB |
| + int main(int argc, char *argv[]) |
| +#else |
| + int socdiag_main(int argc, char *argv[]) |
| +#endif |
| { |
| int i, len; |
| char *envstr; |
| @@ -260,8 +264,10 @@ |
| #endif |
| |
| diag_shell(); |
| - |
| + |
| +#ifndef BUILD_ING_AS_LIB |
| linux_bde_destroy(bde); |
| +#endif |
| #ifdef MEMLOG_SUPPORT |
| if (memlog_lock) { |
| sal_mutex_destroy(memlog_lock); |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/systems/sim/socdiag.c sdk-all-6.5.7/systems/sim/socdiag.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/systems/sim/socdiag.c 2016-12-01 05:18:41.000000000 +0200 |
| +++ sdk-all-6.5.7/systems/sim/socdiag.c 2017-01-26 13:09:21.033560205 +0200 |
| @@ -31,11 +31,16 @@ |
| /* |
| * Main loop. |
| */ |
| -int main(int argc, char *argv[]) |
| +#ifndef BUILD_ING_AS_LIB |
| + int main(int argc, char *argv[]) |
| +#else |
| + int socdiag_main(int argc, char *argv[]) |
| +#endif |
| { |
| char *socrc = SOC_INIT_RC; |
| char *config_file = NULL, *config_temp = NULL; |
| int len = 0; |
| + FILE *fp; |
| |
| if ((config_file = getenv("BCM_CONFIG_FILE")) != NULL) { |
| len = sal_strlen(config_file); |
| @@ -56,6 +61,12 @@ |
| exit(1); |
| } |
| |
| + if ((fp = sal_fopen("rc.soc", "r")) != NULL) |
| + { |
| + setenv("SOC_BOOT_SCRIPT", "rc.soc", 0); |
| + sal_fclose(fp); |
| + } |
| + |
| #ifdef DEBUG_STARTUP |
| debugk_select(DEBUG_STARTUP); |
| #endif |
| |
| diff -Naur /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/bcm/rpc/rpc.c sdk-all-6.5.7/src/bcm/rpc/rpc.c |
| --- /projects/NTSW_SW_PRJS/ExternalReleases/BCM/6.5.7/ga/sdk-all-6.5.7/src/bcm/rpc/rpc.c 2016-11-30 22:17:00.000000000 -0500 |
| +++ sdk-all-6.5.7/src/bcm/rpc/rpc.c 2017-01-27 08:27:37.656186371 -0500 |
| @@ -268,7 +268,7 @@ |
| |
| bp = buf; |
| BCM_PACK_U32(bp, seq); |
| - |
| +/*************** IL 2017-01-26 WHY ADD these check?? not in 6.5.6 ********* |
| if (!BCM_UNIT_VALID(unit) || (BCM_CONTROL(unit)->drv_control == NULL)) { |
| _bcm_rpc_unlink_request(req); |
| sal_sem_destroy(req->sem); |
| @@ -276,7 +276,7 @@ |
| sal_free((void *)req); |
| return BCM_E_MEMORY; |
| } |
| - |
| +**************************************************************************/ |
| cpu = *(cpudb_key_t *)BCM_CONTROL(unit)->drv_control; |
| #ifdef BCM_RPC_ATP_TX_CALLBACK |
| /* |
| |