Esempio n. 1
0
const uint8_t* QsfpModule::getQsfpValuePtr(int dataAddress, int offset,
                                           int length) const {
  /* if the cached values are not correct */
  if (!cacheIsValid()) {
    throw FbossError("Qsfp is either not present or the data is not read");
  }
  if (dataAddress == QsfpPages::LOWER) {
    CHECK_LE(offset + length, sizeof(qsfpIdprom_));
    /* Copy data from the cache */
    return(qsfpIdprom_ + offset);
  } else {
    offset -= MAX_QSFP_PAGE_SIZE;
    CHECK_GE(offset, 0);
    CHECK_LE(offset, MAX_QSFP_PAGE_SIZE);
    if (dataAddress == QsfpPages::PAGE0) {
      CHECK_LE(offset + length, sizeof(qsfpPage0_));
      /* Copy data from the cache */
      return(qsfpPage0_ + offset);
    } else if (dataAddress == QsfpPages::PAGE3 && !flatMem_) {
      CHECK_LE(offset + length, sizeof(qsfpPage3_));
      /* Copy data from the cache */
      return(qsfpPage3_ + offset);
    } else {
      throw FbossError("Invalid Data Address 0x%d", dataAddress);
    }
  }
}
Esempio n. 2
0
void QsfpModule::getTransceiverInfo(TransceiverInfo &info) {
    lock_guard<std::mutex> g(qsfpModuleMutex_);
    info.present = present_;
    info.transceiver = type();
    info.port = qsfpImpl_->getNum();
    if (!cacheIsValid()) {
        return;
    }

    if (getSensorInfo(info.sensor)) {
        info.__isset.sensor = true;
    }
    if (getVendorInfo(info.vendor)) {
        info.__isset.vendor = true;
    }
    if (getCableInfo(info.cable)) {
        info.__isset.cable = true;
    }
    if (getThresholdInfo(info.thresholds)) {
        info.__isset.thresholds = true;
    }
    for (int i = 0; i < CHANNEL_COUNT; i++) {
        Channel chan;
        chan.channel = i;
        info.channels.push_back(chan);
    }

    if (getSensorsPerChanInfo(info.channels)) {
        info.__isset.channels = true;
    } else {
        info.channels.clear();
    }
}
Esempio n. 3
0
// Must be called with lock held on qsfpModuleMutex_
void QsfpModule::refreshCacheIfPossibleLocked() {
  // Check whether we should refresh data
  if (std::time(nullptr) - lastReadTime_.load() > kQsfpMinReadIntervalSecs) {
    dirty_ = true;
  }
  if (!cacheIsValid()) {
    detectTransceiverLocked();
  }
}
Esempio n. 4
0
void ScopedStyleTree::popStyleCache(const ContainerNode* scopingNode)
{
    if (!cacheIsValid(scopingNode))
        return;

    if (m_cache.scopedResolver && m_cache.scopedResolver->scopingNode() == scopingNode)
        m_cache.scopedResolver = m_cache.scopedResolver->parent();
    m_cache.nodeForScopedStyles = scopingNode->parentOrShadowHostNode();
}
Esempio n. 5
0
void ScopedStyleTree::pushStyleCache(const ContainerNode* scopingNode, const ContainerNode* parent)
{
    if (m_authorStyles.isEmpty())
        return;

    if (!cacheIsValid(parent)) {
        resolveStyleCache(scopingNode);
        return;
    }

    ScopedStyleResolver* scopedResolver = scopedStyleResolverFor(scopingNode);
    if (scopedResolver)
        m_cache.scopedResolver = scopedResolver;
    m_cache.nodeForScopedStyles = scopingNode;
}
Esempio n. 6
0
int QsfpModule::getFieldValue(SffField fieldName,
                              uint8_t* fieldValue) {
  lock_guard<std::mutex> g(qsfpModuleMutex_);
  int offset;
  int length;
  int dataAddress;

  /* Determine if QSFP is present */
  if (cacheIsValid()) {
    try {
      getQsfpFieldAddress(fieldName, dataAddress, offset, length);
      getQsfpValue(dataAddress, offset, length, fieldValue);
    } catch (const std::exception& ex) {
      LOG(ERROR) << "Error reading field value for transceiver:" <<
             folly::to<std::string>(qsfpImpl_->getName()) << " " << ex.what();
    }
  }
  return -1;
}