wlan.c (8529B)
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 * All Rights Reserved.$ 7 * 8 * WLAN module 9 */ 10 #ifdef INCLUDE_L3 11 12 #include <sal/core/libc.h> 13 14 #include <soc/defs.h> 15 #include <soc/drv.h> 16 #include <soc/mem.h> 17 #include <soc/l2u.h> 18 #include <soc/util.h> 19 #include <soc/debug.h> 20 #include <bcm/l2.h> 21 #include <bcm/l3.h> 22 #include <bcm/port.h> 23 #include <bcm/error.h> 24 #include <bcm/vlan.h> 25 #include <bcm/rate.h> 26 #include <bcm/ipmc.h> 27 #include <bcm/wlan.h> 28 #include <bcm/stack.h> 29 #include <bcm/topo.h> 30 31 #include <bcm_int/esw/mbcm.h> 32 #include <bcm_int/esw/l3.h> 33 #include <bcm_int/esw_dispatch.h> 34 #include <bcm_int/esw/xgs3.h> 35 #if defined(BCM_TRIUMPH2_SUPPORT) 36 #include <bcm_int/esw/field.h> 37 #include <bcm_int/esw/triumph2.h> 38 #endif /* BCM_TRIUMPH2_SUPPORT */ 39 #if defined(BCM_TRIUMPH3_SUPPORT) 40 #include <bcm_int/esw/triumph3.h> 41 #endif /* BCM_TRIUMPH3_SUPPORT */ 42 43 /* Initialize the WLAN module. */ 44 int 45 bcm_esw_wlan_init(int unit) 46 { 47 int rv = BCM_E_UNAVAIL; 48 49 if (!soc_feature(unit, soc_feature_wlan)) { 50 return rv; 51 } 52 53 #if defined(BCM_TRIUMPH3_SUPPORT) 54 if (soc_feature(unit, soc_feature_axp)) { 55 rv = bcm_tr3_wlan_init(unit); 56 } else 57 #endif /* BCM_TRIUMPH3_SUPPORT */ 58 59 #ifdef BCM_TRIUMPH2_SUPPORT 60 rv = bcm_tr2_wlan_init(unit); 61 #endif 62 return rv; 63 } 64 65 /* Detach the WLAN module. */ 66 int 67 bcm_esw_wlan_detach(int unit) 68 { 69 int rv = BCM_E_NONE; 70 71 if (!soc_feature(unit, soc_feature_wlan)) { 72 return rv; 73 } 74 75 #if defined(BCM_TRIUMPH3_SUPPORT) 76 if (soc_feature(unit, soc_feature_axp)) { 77 rv = bcm_tr3_wlan_detach(unit); 78 } else 79 #endif /* BCM_TRIUMPH3_SUPPORT */ 80 81 #ifdef BCM_TRIUMPH2_SUPPORT 82 rv = bcm_tr2_wlan_detach(unit); 83 #endif 84 return rv; 85 } 86 87 /* Add a WLAN client to the database. */ 88 int 89 bcm_esw_wlan_client_add(int unit, bcm_wlan_client_t *info) 90 { 91 int rv = BCM_E_UNAVAIL; 92 93 if (!soc_feature(unit, soc_feature_wlan)) { 94 return rv; 95 } 96 97 #if defined(BCM_TRIUMPH3_SUPPORT) 98 if (soc_feature(unit, soc_feature_axp)) { 99 rv = bcm_tr3_wlan_client_add(unit, info); 100 } else 101 #endif /* BCM_TRIUMPH3_SUPPORT */ 102 103 #ifdef BCM_TRIUMPH2_SUPPORT 104 rv = bcm_tr2_wlan_client_add(unit, info); 105 #endif 106 return rv; 107 } 108 109 /* Delete a WLAN client from the database. */ 110 int 111 bcm_esw_wlan_client_delete(int unit, bcm_mac_t mac) 112 { 113 int rv = BCM_E_UNAVAIL; 114 115 if (!soc_feature(unit, soc_feature_wlan)) { 116 return rv; 117 } 118 119 #if defined(BCM_TRIUMPH3_SUPPORT) 120 if (soc_feature(unit, soc_feature_axp)) { 121 rv = bcm_tr3_wlan_client_delete(unit, mac); 122 } else 123 #endif /* BCM_TRIUMPH3_SUPPORT */ 124 125 #ifdef BCM_TRIUMPH2_SUPPORT 126 rv = bcm_tr2_wlan_client_delete(unit, mac); 127 #endif 128 return rv; 129 } 130 131 132 /* Delete all WLAN clients. */ 133 int 134 bcm_esw_wlan_client_delete_all(int unit) 135 { 136 int rv = BCM_E_UNAVAIL; 137 138 if (!soc_feature(unit, soc_feature_wlan)) { 139 return rv; 140 } 141 142 #if defined(BCM_TRIUMPH3_SUPPORT) 143 if (soc_feature(unit, soc_feature_axp)) { 144 rv = bcm_tr3_wlan_client_delete_all(unit); 145 } else 146 #endif /* BCM_TRIUMPH3_SUPPORT */ 147 148 #ifdef BCM_TRIUMPH2_SUPPORT 149 rv = bcm_tr2_wlan_client_delete_all(unit); 150 #endif 151 return rv; 152 } 153 154 /* Get a WLAN client by MAC. */ 155 int 156 bcm_esw_wlan_client_get(int unit, bcm_mac_t mac, bcm_wlan_client_t *info) 157 { 158 int rv = BCM_E_UNAVAIL; 159 160 if (!soc_feature(unit, soc_feature_wlan)) { 161 return rv; 162 } 163 164 #if defined(BCM_TRIUMPH3_SUPPORT) 165 if (soc_feature(unit, soc_feature_axp)) { 166 rv = bcm_tr3_wlan_client_get(unit, mac, info); 167 } else 168 #endif /* BCM_TRIUMPH3_SUPPORT */ 169 170 #ifdef BCM_TRIUMPH2_SUPPORT 171 rv = bcm_tr2_wlan_client_get(unit, mac, info); 172 #endif 173 return rv; 174 } 175 176 /* bcm_wlan_client_traverse */ 177 int 178 bcm_esw_wlan_client_traverse(int unit, bcm_wlan_client_traverse_cb cb, 179 void *user_data) 180 { 181 int rv = BCM_E_UNAVAIL; 182 183 if (!soc_feature(unit, soc_feature_wlan)) { 184 return rv; 185 } 186 187 #if defined(BCM_TRIUMPH3_SUPPORT) 188 if (soc_feature(unit, soc_feature_axp)) { 189 rv = bcm_tr3_wlan_client_traverse(unit, cb, user_data); 190 } else 191 #endif /* BCM_TRIUMPH3_SUPPORT */ 192 193 #ifdef BCM_TRIUMPH2_SUPPORT 194 rv = bcm_tr2_wlan_client_traverse(unit, cb, user_data); 195 #endif 196 return rv; 197 } 198 199 /* bcm_wlan_port_add */ 200 int 201 bcm_esw_wlan_port_add(int unit, bcm_wlan_port_t *info) 202 { 203 int rv = BCM_E_UNAVAIL; 204 205 if (!soc_feature(unit, soc_feature_wlan)) { 206 return rv; 207 } 208 209 #if defined(BCM_TRIUMPH3_SUPPORT) 210 if (soc_feature(unit, soc_feature_axp)) { 211 rv = bcm_tr3_wlan_port_add(unit, info); 212 } else 213 #endif /* BCM_TRIUMPH3_SUPPORT */ 214 215 #ifdef BCM_TRIUMPH2_SUPPORT 216 rv = bcm_tr2_wlan_port_add(unit, info); 217 #endif 218 return rv; 219 } 220 221 /* bcm_wlan_port_delete */ 222 int 223 bcm_esw_wlan_port_delete(int unit, bcm_gport_t wlan_port_id) 224 { 225 int rv = BCM_E_UNAVAIL; 226 227 if (!soc_feature(unit, soc_feature_wlan)) { 228 return rv; 229 } 230 231 #if defined(BCM_TRIUMPH3_SUPPORT) 232 if (soc_feature(unit, soc_feature_axp)) { 233 rv = bcm_tr3_wlan_port_delete(unit, wlan_port_id); 234 } else 235 #endif /* BCM_TRIUMPH3_SUPPORT */ 236 237 #ifdef BCM_TRIUMPH2_SUPPORT 238 rv = bcm_tr2_wlan_port_delete(unit, wlan_port_id); 239 #endif 240 return rv; 241 } 242 243 /* bcm_wlan_port_delete_all */ 244 int 245 bcm_esw_wlan_port_delete_all(int unit) 246 { 247 int rv = BCM_E_UNAVAIL; 248 249 if (!soc_feature(unit, soc_feature_wlan)) { 250 return rv; 251 } 252 253 #if defined(BCM_TRIUMPH3_SUPPORT) 254 if (soc_feature(unit, soc_feature_axp)) { 255 rv = bcm_tr3_wlan_port_delete_all(unit); 256 } else 257 #endif /* BCM_TRIUMPH3_SUPPORT */ 258 259 #ifdef BCM_TRIUMPH2_SUPPORT 260 rv = bcm_tr2_wlan_port_delete_all(unit); 261 #endif 262 return rv; 263 } 264 265 /* bcm_wlan_port_get */ 266 int 267 bcm_esw_wlan_port_get(int unit, bcm_gport_t wlan_port_id, bcm_wlan_port_t *info) 268 { 269 int rv = BCM_E_UNAVAIL; 270 271 if (!soc_feature(unit, soc_feature_wlan)) { 272 return rv; 273 } 274 275 #if defined(BCM_TRIUMPH3_SUPPORT) 276 if (soc_feature(unit, soc_feature_axp)) { 277 rv = bcm_tr3_wlan_port_get(unit, wlan_port_id, info); 278 } else 279 #endif /* BCM_TRIUMPH3_SUPPORT */ 280 281 #ifdef BCM_TRIUMPH2_SUPPORT 282 rv = bcm_tr2_wlan_port_get(unit, wlan_port_id, info); 283 #endif 284 return rv; 285 } 286 287 /* bcm_wlan_port_traverse */ 288 int 289 bcm_esw_wlan_port_traverse(int unit, bcm_wlan_port_traverse_cb cb, 290 void *user_data) 291 { 292 int rv = BCM_E_UNAVAIL; 293 294 if (!soc_feature(unit, soc_feature_wlan)) { 295 return rv; 296 } 297 298 #if defined(BCM_TRIUMPH3_SUPPORT) 299 if (soc_feature(unit, soc_feature_axp)) { 300 rv = bcm_tr3_wlan_port_traverse(unit, cb, user_data); 301 } else 302 #endif /* BCM_TRIUMPH3_SUPPORT */ 303 304 #ifdef BCM_TRIUMPH2_SUPPORT 305 rv = bcm_tr2_wlan_port_traverse(unit, cb, user_data); 306 #endif 307 return rv; 308 } 309 310 /* WLAN tunnel initiator create */ 311 int 312 bcm_esw_wlan_tunnel_initiator_create(int unit, bcm_tunnel_initiator_t *info) 313 { 314 int rv = BCM_E_UNAVAIL; 315 316 if (!soc_feature(unit, soc_feature_wlan)) { 317 return rv; 318 } 319 320 #if defined(BCM_TRIUMPH3_SUPPORT) 321 if (soc_feature(unit, soc_feature_axp)) { 322 rv = bcm_tr3_wlan_tunnel_initiator_create(unit, info); 323 } else 324 #endif /* BCM_TRIUMPH3_SUPPORT */ 325 326 #ifdef BCM_TRIUMPH2_SUPPORT 327 rv = bcm_tr2_wlan_tunnel_initiator_create(unit, info); 328 #endif 329 return rv; 330 } 331 332 /* WLAN tunnel initiator destroy */ 333 int 334 bcm_esw_wlan_tunnel_initiator_destroy(int unit, bcm_gport_t wlan_tunnel_id) 335 { 336 int rv = BCM_E_UNAVAIL; 337 338 if (!soc_feature(unit, soc_feature_wlan)) { 339 return rv; 340 } 341 342 #if defined(BCM_TRIUMPH3_SUPPORT) 343 if (soc_feature(unit, soc_feature_axp)) { 344 rv = bcm_tr3_wlan_tunnel_initiator_destroy(unit, wlan_tunnel_id); 345 } else 346 #endif /* BCM_TRIUMPH3_SUPPORT */ 347 348 #ifdef BCM_TRIUMPH2_SUPPORT 349 rv = bcm_tr2_wlan_tunnel_initiator_destroy(unit, wlan_tunnel_id); 350 #endif 351 return rv; 352 } 353 354 /* WLAN tunnel initiator get */ 355 int 356 bcm_esw_wlan_tunnel_initiator_get(int unit, bcm_tunnel_initiator_t *info) 357 { 358 int rv = BCM_E_UNAVAIL; 359 360 if (!soc_feature(unit, soc_feature_wlan)) { 361 return rv; 362 } 363 364 #if defined(BCM_TRIUMPH3_SUPPORT) 365 if (soc_feature(unit, soc_feature_axp)) { 366 rv = bcm_tr3_wlan_tunnel_initiator_get(unit, info); 367 } else 368 #endif /* BCM_TRIUMPH3_SUPPORT */ 369 370 #ifdef BCM_TRIUMPH2_SUPPORT 371 rv = bcm_tr2_wlan_tunnel_initiator_get(unit, info); 372 #endif 373 return rv; 374 } 375 376 #else /* INCLUDE_L3 */ 377 int _bcm_esw_wlan_not_empty; 378 #endif /* INCLUDE_L3 */