cmicx_link.h (3244B)
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 * File: cmicx_link.h 8 * Purpose: cmicx m0 linkscan management 9 */ 10 11 #ifndef __CMICX_LINK_H__ 12 #define __CMICX_LINK_H__ 13 #include <bcm/types.h> 14 #if defined(BCM_CMICX_SUPPORT) || defined(CMICX_FW_BUILD) 15 #include <shared/cmicfw/iproc_mbox.h> 16 #include <shared/cmicfw/cmicx_link_defs.h> 17 #define MAX_LS_RETRY 50 18 #define LS_HW_INTERVAL 30 /* in msecs */ 19 #define CMICX_LS_ALIVE 1 20 #define CMICX_LS_NOTALIVE 2 21 22 /* CMICx Linkscan shared memory define. */ 23 #define CMICX_LS_SHMEM_OFFSET_DEFAULT (512) 24 #define CMICX_LS_SHMEM_SIZE (64) 25 26 typedef enum ls_msgtype_e { 27 LS_HW_CONFIG = 1, 28 LS_HW_HEARTBEAT, 29 LS_PAUSE, 30 LS_CONTINUE, 31 LS_LINK_STATUS_CHANGE 32 } ls_msgtype_t; 33 34 typedef struct soc_ls_heartbeat_s { 35 uint32 m0_fw_version; 36 uint32 host_fw_version; 37 }__attribute__ ((packed)) soc_ls_heartbeat_t; 38 39 #ifndef CMICX_FW_BUILD 40 typedef int (*soc_iproc_linkscan_sm_t)(soc_iproc_mbox_info_t *chan, soc_iproc_mbox_msg_t *msg); 41 extern int soc_cmicx_linkscan_hw_init(int unit); 42 extern int soc_cmicx_linkscan_hw_deinit(int unit); 43 extern int soc_cmicx_linkscan_config(int unit, soc_pbmp_t *hw_mii_pbm); 44 extern int soc_cmicx_linkscan_heartbeat(int unit, soc_ls_heartbeat_t *ls_heartbeat); 45 extern int soc_cmicx_linkscan_hw_link_get(int unit, soc_pbmp_t *hw_link); 46 extern int soc_cmicx_linkscan_pause(int unit); 47 extern int soc_cmicx_linkscan_continue(int unit); 48 extern int soc_cmicx_link_fw_config_init(int unit); 49 extern void cmicx_esw_linkscan_hw_interrupt(int unit); 50 extern void cmicx_common_linkscan_hw_interrupt(int unit); 51 extern int soc_cmicx_linkscan_hw_link_cache_get(int unit, soc_pbmp_t *hw_link); 52 #endif 53 #endif /*defined(BCM_CMICX_SUPPORT) || defined(CMICX_FW_BUILD)*/ 54 55 /* 56 Define a maximun physical port number for link scan 57 Reserve some headroom for future 58 */ 59 #define LS_PHY_PBMP_PORT_MAX 384 60 61 #define LS_PHY_PBMP_WORD_MAX ((LS_PHY_PBMP_PORT_MAX + 31) / 32) 62 63 typedef struct ls_phy_pbmp_s { 64 uint32 pbits[LS_PHY_PBMP_WORD_MAX]; 65 } ls_phy_pbmp_t; 66 67 #define LS_PHY_PBMP_WORD_GET(bm, word) ((bm).pbits[(word)]) 68 #define LS_PHY_PBMP_WORD_SET(bm, word, val) ((bm).pbits[(word)] = (val)) 69 #define LS_PHY_PBMP_PORT_ADD(bm, port) do { \ 70 if ((port) < LS_PHY_PBMP_PORT_MAX) { \ 71 (LS_PHY_PBMP_WORD_GET((bm), ((port)/32)) |= (1 << ((port)%32))); \ 72 } \ 73 } while(0) 74 75 #define LS_PHY_PBMP_PORT_REMOVE(bm, port) do { \ 76 if ((port) < LS_PHY_PBMP_PORT_MAX) { \ 77 (LS_PHY_PBMP_WORD_GET((bm), ((port)/32)) &= ~((uint32) (1 << ((port)%32)))); \ 78 } \ 79 } while(0) 80 81 #define LS_PHY_PBMP_CLEAR(bm) do { \ 82 int _w; \ 83 for (_w = 0; _w < LS_PHY_PBMP_WORD_MAX; _w++) { \ 84 LS_PHY_PBMP_WORD_SET(bm, _w, 0); \ 85 } \ 86 } while(0) 87 88 #define LS_PHY_PBMP_MEMBER(bm, port) \ 89 (LS_PHY_PBMP_WORD_GET((bm), ((port)/32)) & (1 << ((port)%32))) 90 91 #define LS_PHY_PBMP_ITER(bm, port) \ 92 for ((port) = 0; (port) < LS_PHY_PBMP_PORT_MAX; (port)++) \ 93 if (LS_PHY_PBMP_MEMBER((bm), (port))) 94 95 #endif /* __CMICX_LINK_H__ */