Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * <:copyright-BRCM:2016:DUAL/GPL:standard |
| 4 | * |
| 5 | * Copyright (c) 2016 Broadcom |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * Unless you and Broadcom execute a separate written software license |
| 9 | * agreement governing use of this software, this software is licensed |
| 10 | * to you under the terms of the GNU General Public License version 2 |
| 11 | * (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, |
| 12 | * with the following added to such license: |
| 13 | * |
| 14 | * As a special exception, the copyright holders of this software give |
| 15 | * you permission to link this software with independent modules, and |
| 16 | * to copy and distribute the resulting executable under terms of your |
| 17 | * choice, provided that you also meet, for each linked independent |
| 18 | * module, the terms and conditions of the license of that module. |
| 19 | * An independent module is a module which is not derived from this |
| 20 | * software. The special exception does not apply to any modifications |
| 21 | * of the software. |
| 22 | * |
| 23 | * Not withstanding the above, under no circumstances may you combine |
| 24 | * this software in any way with any other Broadcom software provided |
| 25 | * under a license other than the GPL, without Broadcom's express prior |
| 26 | * written consent. |
| 27 | * |
| 28 | * :> |
| 29 | * |
| 30 | *****************************************************************************/ |
| 31 | |
| 32 | #ifndef TEST_SW_UTIL_LOOPBACK |
| 33 | |
| 34 | #include <bal_common.h> |
| 35 | #include <bcm_dev_log.h> |
| 36 | #include <bal_msg.h> |
| 37 | #include "bal_switch_util.h" |
| 38 | #include "bal_switch_acc_term.h" |
| 39 | #include "bal_esw_acc_term.h" |
| 40 | |
| 41 | #include <bcm/types.h> |
| 42 | #include <bcm/port.h> |
| 43 | |
| 44 | /** |
| 45 | * @file bal_esw_acc_term.c |
| 46 | * @brief BAL Switch util functions that handle access terminal requests on Enterprise SWitch |
| 47 | * @addtogroup sw_util |
| 48 | * |
| 49 | */ |
| 50 | |
| 51 | /*@{*/ |
| 52 | |
| 53 | |
| 54 | /** |
| 55 | * @brief Connect access terminal with ESW as part of the components |
| 56 | * |
| 57 | * This routine is called by sw_util_access_terminal_connect in the BAL core |
| 58 | * to execute ESW specific API for access_terminal_connect request |
| 59 | * |
| 60 | * @param p_net_map Pointer to the net ports mapping from logical numbrer to physical number |
| 61 | * @param p_pon_map Pointer to the pon ports mapping from logical numbrer to physical number |
| 62 | * @return bcmos_errno |
| 63 | */ |
| 64 | bcmos_errno sw_util_esw_acc_term_connect(bal_swapp_port *p_net_map, bal_swapp_port *p_pon_map ) |
| 65 | { |
| 66 | bcmos_errno ret = BCM_ERR_OK; |
| 67 | int rc = 0; |
| 68 | bal_swapp_port *port; |
| 69 | bcm_pbmp_t pon_pbmp, net_pbmp; |
| 70 | |
| 71 | BCM_LOG(INFO, log_id_sw_util, " KT2 - Got a access terminal CONNECT\n"); |
| 72 | |
| 73 | BCM_PBMP_CLEAR(pon_pbmp); |
| 74 | BCM_PBMP_CLEAR(net_pbmp); |
| 75 | |
| 76 | /* setup the device ID - This is very hardware specific */ |
| 77 | port = p_net_map; |
| 78 | /* -1 indicate the end of table */ |
| 79 | while(port->pbm_id != -1) |
| 80 | { |
| 81 | /* add port to the net list */ |
| 82 | BCM_PBMP_PORT_ADD(net_pbmp, port->pbm_id); |
| 83 | port++; |
| 84 | } |
| 85 | |
| 86 | port = p_pon_map; |
| 87 | while(port->pbm_id != -1) |
| 88 | { |
| 89 | /* add port to the pon list */ |
| 90 | BCM_PBMP_PORT_ADD(pon_pbmp, port->pbm_id); |
| 91 | port++; |
| 92 | } |
| 93 | |
| 94 | /* set up the valid egress ports for pon facing ports */ |
| 95 | port = p_pon_map; |
| 96 | while(port->pbm_id != -1) |
| 97 | { |
| 98 | rc = bcm_port_egress_set(port->device_id, port->pbm_id, 0, /* modid */ net_pbmp); |
| 99 | if (rc) |
| 100 | { |
| 101 | BCM_LOG(ERROR, log_id_sw_util, " ESW - Add port %d to pon interface failed\n", port->pbm_id ); |
| 102 | } |
| 103 | port++; |
| 104 | } |
| 105 | |
| 106 | /* set up the valid egress ports for net facing ports */ |
| 107 | port = p_net_map; |
| 108 | while(port->pbm_id != -1) |
| 109 | { |
| 110 | rc = bcm_port_egress_set(port->device_id, port->pbm_id, 0, /* modid */ pon_pbmp); |
| 111 | if (rc) |
| 112 | { |
| 113 | BCM_LOG(ERROR, log_id_sw_util, |
| 114 | " ESW - Add port %d to net interface failed\n", port->pbm_id ); |
| 115 | } |
| 116 | port++; |
| 117 | } |
| 118 | |
| 119 | /* translate ING error code to BAL error code */ |
| 120 | if (rc) |
| 121 | { |
| 122 | ret = BCM_ERR_INTERNAL; |
| 123 | } |
| 124 | else |
| 125 | { |
| 126 | ret = BCM_ERR_OK; |
| 127 | } |
| 128 | return ret; |
| 129 | } |
| 130 | |
| 131 | /*@}*/ |
| 132 | #endif /* #ifndef TEST_SW_UTIL_LOOPBACK */ |