int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { unsigned char val; val = cpld_base__[CPLD_REG_SFP_PRESENT]; AIM_BITMAP_MOD(dst, 48, (val & CPLD_SFP_1_BIT_MASK) ? 0 : 1); AIM_BITMAP_MOD(dst, 49, (val & CPLD_SFP_2_BIT_MASK) ? 0 : 1); AIM_BITMAP_MOD(dst, 50, (val & CPLD_SFP_3_BIT_MASK) ? 0 : 1); AIM_BITMAP_MOD(dst, 51, (val & CPLD_SFP_4_BIT_MASK) ? 0 : 1); return ONLP_STATUS_OK; }
int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { unsigned char val; val = cpld_base__[CPLD_REG_SFP_RX_LOSS]; AIM_BITMAP_MOD(dst, 48, (val & CPLD_SFP_1_BIT_MASK) ? 1 : 0); AIM_BITMAP_MOD(dst, 49, (val & CPLD_SFP_2_BIT_MASK) ? 1 : 0); AIM_BITMAP_MOD(dst, 50, (val & CPLD_SFP_3_BIT_MASK) ? 1 : 0); AIM_BITMAP_MOD(dst, 51, (val & CPLD_SFP_4_BIT_MASK) ? 1 : 0); return ONLP_STATUS_OK; }
int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t presence_all[2] = {0}; int port, ret, index; for (port = 0, index = 0; port < NUM_OF_SFP_PORT; port++) { if (port == 32) { index = 1; } ret = onlp_sfpi_is_present(port); if (ret == 1) { presence_all[index] |= (1<<port); } else if (ret == 0) { presence_all[index] &= ~(1<<port); } else { AIM_LOG_ERROR("Unable to read present status of port(%d).", port); } } /* Populate bitmap */ for(port = 0, index = 0; port < NUM_OF_SFP_PORT; port++) { if (port == 32) { index = 1; } AIM_BITMAP_MOD(dst, port, (presence_all[index] & 1)); presence_all[index] >>= 1; } return ONLP_STATUS_OK; }
int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[8], *ptr = NULL; FILE* fp; int addr; ptr = bytes; for (addr = 61; addr <= 62; addr++) { /* Read present status of port 0~53 */ char file[64] = {0}; int bus = (addr == 61) ? 10 : 11; sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); fp = fopen(file, "r"); if(fp == NULL) { AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD."); return ONLP_STATUS_E_INTERNAL; } int count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); fclose(fp); if(count != 4) { /* Likely a CPLD read timeout. */ AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD."); return ONLP_STATUS_E_INTERNAL; } ptr += count; } /* Mask out non-existant QSFP ports */ bytes[3] &= 0x1F; bytes[7] &= 0x1; /* Convert to 64 bit integer in port order */ int i = 0; uint64_t presence_all = 0 ; for(i = 7; i >= 4; i--) { presence_all <<= 8; presence_all |= bytes[i]; } presence_all <<= 5; presence_all |= bytes[3]; for(i = 2; i >= 0; i--) { presence_all <<= 8; presence_all |= bytes[i]; } /* Populate bitmap */ for(i = 0; presence_all; i++) { AIM_BITMAP_MOD(dst, i, (presence_all & 1)); presence_all >>= 1; } return ONLP_STATUS_OK; }
int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { int p = 1; int rc = 0; for (p = 1; p <= QSFP_NUM; p++) { rc = onlp_sfpi_is_present(p); AIM_BITMAP_MOD(dst, p, (1 == rc) ? 1 : 0); } return ONLP_STATUS_OK; }
int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { int ii = 1; int rc = 0; for (;ii <= NUM_OF_SFP_PORT; ii++) { rc = onlp_sfpi_is_present(ii); AIM_BITMAP_MOD(dst, ii, (1 == rc) ? 1 : 0); } return ONLP_STATUS_OK; }
int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[7]; char* path; FILE* fp; path = as5812_54x_sfp_get_port_path(0, "sfp_is_present_all"); fp = fopen(path, "r"); if(fp == NULL) { AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); return ONLP_STATUS_E_INTERNAL; } int count = fscanf(fp, "%x %x %x %x %x %x %x", bytes+0, bytes+1, bytes+2, bytes+3, bytes+4, bytes+5, bytes+6 ); fclose(fp); if(count != AIM_ARRAYSIZE(bytes)) { /* Likely a CPLD read timeout. */ AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); return ONLP_STATUS_E_INTERNAL; } /* Mask out non-existant QSFP ports */ bytes[6] &= 0x3F; /* Convert to 64 bit integer in port order */ int i = 0; uint64_t presence_all = 0 ; for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { presence_all <<= 8; presence_all |= bytes[i]; } /* Populate bitmap */ for(i = 0; presence_all; i++) { int p; port_qsfp_cpld_map__(i, &p); AIM_BITMAP_MOD(dst, p, (presence_all & 1)); presence_all >>= 1; } return ONLP_STATUS_OK; }
int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[6]; uint32_t *ptr = bytes; FILE* fp; /* Read present status of port 0~23 */ int addr, i = 0; for (addr = 62; addr <= 64; addr+=2) { if (addr == 62) { fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); } else { fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD3, "r"); } if(fp == NULL) { AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); return ONLP_STATUS_E_INTERNAL; } int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); fclose(fp); if(count != 3) { /* Likely a CPLD read timeout. */ AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); return ONLP_STATUS_E_INTERNAL; } ptr += count; } /* Convert to 64 bit integer in port order */ i = 0; uint64_t rx_los_all = 0 ; for(i = 5; i >= 0; i--) { rx_los_all <<= 8; rx_los_all |= bytes[i]; } /* Populate bitmap */ for(i = 0; rx_los_all; i++) { AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); rx_los_all >>= 1; } return ONLP_STATUS_OK; }
int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[7]; char* path; FILE* fp; path = as5812_54x_sfp_get_port_path(0, "sfp_rx_los_all"); fp = fopen(path, "r"); if(fp == NULL) { AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); return ONLP_STATUS_E_INTERNAL; } int count = fscanf(fp, "%x %x %x %x %x %x", bytes+0, bytes+1, bytes+2, bytes+3, bytes+4, bytes+5 ); fclose(fp); if(count != 6) { AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); return ONLP_STATUS_E_INTERNAL; } /* Convert to 64 bit integer in port order */ int i = 0; uint64_t rx_los_all = 0 ; for(i = 5; i >= 0; i--) { rx_los_all <<= 8; rx_los_all |= bytes[i]; } /* Populate bitmap */ for(i = 0; rx_los_all; i++) { int p; port_qsfp_cpld_map__(i, &p); AIM_BITMAP_MOD(dst, p, (rx_los_all & 1)); rx_los_all >>= 1; } return ONLP_STATUS_OK; }
int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[4]; FILE* fp = fopen(SFP_EEPROM_NODE(sfp_is_present_all), "r"); if(fp == NULL) { AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); return ONLP_STATUS_E_INTERNAL; } int count = fscanf(fp, "%x %x %x %x", bytes+0, bytes+1, bytes+2, bytes+3 ); fclose(fp); if(count != AIM_ARRAYSIZE(bytes)) { /* Likely a CPLD read timeout. */ AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); return ONLP_STATUS_E_INTERNAL; } /* Convert to 64 bit integer in port order */ int i = 0; uint32_t presence_all = 0 ; for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { presence_all <<= 8; presence_all |= bytes[i]; } /* Populate bitmap */ for(i = 0; presence_all; i++) { AIM_BITMAP_MOD(dst, i, (presence_all & 1)); presence_all >>= 1; } return ONLP_STATUS_OK; }
int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[8]; int i = 0; uint64_t rx_los_all = 0; bytes[0]=bytes[1]=bytes[2]=bytes[3]=bytes[4]=bytes[5]=0x0; bytes[6]=0x0f; bytes[7]=0x0; for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { rx_los_all <<= 8; rx_los_all |= bytes[i]; } /* Populate bitmap */ for(i = 0; rx_los_all; i++) { AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); rx_los_all >>= 1; } return ONLP_STATUS_OK; }