int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ int front_port=0; memset(data, 0, 256); front_port=SFP_MAP_API_2_FRONT_PORT(port); if (set_active_port(front_port) < 0) { AIM_LOG_ERROR("Unable to set active port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } if (deviceNodeReadBinary(SFP_EEPROM_NODE(sfp_eeprom), (char*)data, 256, 256) != 0) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } return ONLP_STATUS_OK; }
static void activate_action (GtkWidget *button, pa_device_port_t *data) { char str[512]; strcpy(str, data->device.description); strcat(str, "\n"); strcat(str, data->port.description); notify_init ("PA device switcher"); NotifyNotification * notification = notify_notification_new ("PA device switcher", str, data->port.description); notify_notification_show (notification, NULL); set_active_port(data->device, data->port); }
int onlp_sfpi_is_present(int port) { /* * Return 1 if present. * Return 0 if not present. * Return < 0 if error. */ int present = 0, front_port=0; front_port=SFP_MAP_API_2_FRONT_PORT(port); if (set_active_port(front_port) < 0) { AIM_LOG_ERROR("Unable to set active port to port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } if (as6700_32x_sfp_node_read_int(SFP_EEPROM_NODE(sfp_is_present), &present, 1) != 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } return present; }
int onlp_sfpi_post_insert(int port, sff_info_t* info) { /* * IF any platform-programming must be performed based * on the actual SFP that was inserted (for example, custom equalizer settings) * then it should be performed by this function. * * If not custom programming must be performed, then do nothing. * This function is optional. */ int front_port=0; sfp_tranceiver_cable_type_t cable_type = SFP_TRANCEIVER_CABLE_TYPE_FIBER; switch(info->media_type) { case SFF_MEDIA_TYPE_FIBER: cable_type = SFP_TRANCEIVER_CABLE_TYPE_FIBER; break; case SFF_MEDIA_TYPE_COPPER: switch(info->length) { case 1: case 2: AIM_LOG_MSG("Port %d EQ 1M", port); cable_type = SFP_TRANCEIVER_CABLE_TYPE_COPPER_1M; break; case 3: case 4: AIM_LOG_MSG("Port %d EQ 3M", port); cable_type = SFP_TRANCEIVER_CABLE_TYPE_COPPER_3M; break; case 5: case 6: AIM_LOG_MSG("Port %d EQ 5M", port); cable_type = SFP_TRANCEIVER_CABLE_TYPE_COPPER_5M; break; case 7: AIM_LOG_MSG("Port %d EQ 7M", port); cable_type = SFP_TRANCEIVER_CABLE_TYPE_COPPER_7M; break; default: AIM_LOG_MSG("Port %d EQ 7M (MAX)", port); /* Nothing beyond 7M is supported. Best we can do is use the 7M settings. */ cable_type = SFP_TRANCEIVER_CABLE_TYPE_COPPER_7M; break; } break; default: AIM_LOG_WARN("port(%d) media_type(%d) length(%d) is not supported\r\n", port, info->media_type, info->length); return ONLP_STATUS_E_INTERNAL; } front_port=SFP_MAP_API_2_FRONT_PORT(port); if (set_active_port(front_port) < 0) { AIM_LOG_ERROR("Unable to set active port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } if (set_equalizer_type(cable_type) < 0) { AIM_LOG_ERROR("Unable to set port(%d) media_type(%d) length(%d)\r\n", port, info->media_type, info->length); return ONLP_STATUS_E_INTERNAL; } return ONLP_STATUS_OK; }