void BcmPort::init(bool warmBoot) { bool up = false; if (warmBoot) { // Get port status from HW on warm boot. // All ports are initially down on a cold boot. int linkStatus; opennsl_port_link_status_get(unit_, port_, &linkStatus); up = (linkStatus == OPENNSL_PORT_LINK_STATUS_UP); } else { // In open source code, we don't have any guarantees for the // state of the port at startup. Bringing them down guarantees // that things are in a known state. // // We should only be doing this on cold boot, since warm booting // should be initializing the state for us. auto rv = opennsl_port_enable_set(unit_, port_, false); bcmCheckError(rv, "failed to set port to known state: ", port_); } // Notify platform port of initial state/speed getPlatformPort()->linkSpeedChanged(getSpeed()); getPlatformPort()->linkStatusChanged(up, isEnabled()); enableLinkscan(); }
void BcmPort::init(bool warmBoot) { bool up = false; if (warmBoot) { // Get port status from HW on warm boot. // All ports are initially down on a cold boot. int linkStatus; opennsl_port_link_status_get(unit_, port_, &linkStatus); up = (linkStatus == OPENNSL_PORT_LINK_STATUS_UP); } else { // In open source code, we don't have any guarantees for the // state of the port at startup. Bringing them down guarantees // that things are in a known state. // // We should only be doing this on cold boot, since warm booting // should be initializing the state for us. auto rv = opennsl_port_enable_set(unit_, port_, false); bcmCheckError(rv, "failed to set port to known state: ", port_); } setPortStatus(up); // Linkscan should be enabled if the port is enabled already auto linkscan = isEnabled() ? OPENNSL_LINKSCAN_MODE_SW : OPENNSL_LINKSCAN_MODE_NONE; auto rv = opennsl_linkscan_mode_set(unit_, port_, linkscan); bcmCheckError(rv, "failed to set initial linkscan mode on port ", port_); }
bool BcmPort::isUp() { if (!isEnabled()) { return false; } int linkStatus; auto rv = opennsl_port_link_status_get(hw_->getUnit(), port_, &linkStatus); bcmCheckError(rv, "could not find if the port ", port_, " is up or down..."); return linkStatus == OPENNSL_PORT_LINK_STATUS_UP; }