bondoptions.c (1877B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * Utility routines for Bond Options Init & De-Init 8 */ 9 10 #include <shared/bsl.h> 11 12 #include <soc/defs.h> 13 14 #if defined(BCM_ESW_SUPPORT) && defined(BCM_IPROC_SUPPORT) 15 16 #include <soc/drv.h> 17 #include <soc/error.h> 18 #include <soc/bondoptions.h> 19 20 soc_bond_info_t *soc_bond_info[SOC_MAX_NUM_DEVICES]; 21 22 23 24 /* 25 * Function: 26 * soc_bond_info_init 27 * Purpose: 28 * Initialize SOC bond options information cache. 29 * Parameters: 30 * unit - StrataSwitch unit #. 31 * Returns: 32 * SOC_E_XXX 33 */ 34 int 35 soc_bond_info_init(int unit) 36 { 37 int rv = SOC_E_NONE; 38 uint16 dev_id, driver_dev_id; 39 uint8 rev_id, driver_rev_id; 40 41 42 if (SOC_BOND_INFO(unit) == NULL) { 43 SOC_BOND_INFO(unit) = sal_alloc(sizeof(soc_bond_info_t), "SOC Bond Info Structure"); 44 if (SOC_BOND_INFO(unit) == NULL) { 45 return SOC_E_MEMORY; 46 } 47 } 48 49 sal_memset(SOC_BOND_INFO(unit), 0, (sizeof(soc_bond_info_t))); 50 51 soc_cm_get_id(unit, &dev_id, &rev_id); 52 soc_cm_get_id_driver(dev_id, rev_id, &driver_dev_id, &driver_rev_id); 53 54 /* Call bond_options_init function only if defined */ 55 if (SOC_FUNCTIONS(unit)->soc_bond_options_init) { 56 rv = SOC_FUNCTIONS(unit)->soc_bond_options_init(unit); 57 } 58 59 return rv; 60 } 61 62 63 /* 64 * Function: 65 * soc_bond_info_deinit 66 * Purpose: 67 * UnInitialize/Deallocate SOC bond options information cache. 68 * Parameters: 69 * unit - StrataSwitch unit #. 70 * Returns: 71 * SOC_E_XXX 72 */ 73 int 74 soc_bond_info_deinit(int unit) 75 { 76 sal_free(SOC_BOND_INFO(unit)); 77 SOC_BOND_INFO(unit) = NULL; 78 79 return SOC_E_NONE; 80 } 81 82 #else 83 int _soc_common_bondoptionc_c_not_empty; 84 #endif /* BCM_ESW_SUPPORT && BCM_IPROC_SUPPORT */ 85