示例#1
0
文件: BcmPort.cpp 项目: XPliant/fboss
BcmPort::BcmPort(BcmSwitch* hw, opennsl_port_t port,
                 BcmPlatformPort* platformPort)
    : hw_(hw),
      port_(port),
      platformPort_(platformPort),
      unit_(hw->getUnit()) {
  // Obtain the gport handle from the port handle.
  int rv = opennsl_port_gport_get(unit_, port_, &gport_);
  bcmCheckError(rv, "Failed to get gport for BCM port ", port_);

  disablePause();

  // Initialize our stats data structures
  auto statMap = fbData->getStatMap();
  const auto expType = stats::AVG;
  outQueueLen_ = statMap->getLockAndStatItem(statName("out_queue_length"),
                                             &expType);
  auto histMap = fbData->getHistogramMap();
  stats::ExportedHistogram pktLenHist(1, 0, kInPktLengthStats.size());
  inPktLengths_ = histMap->getOrCreateUnlocked(statName("in_pkt_lengths"),
                                               &pktLenHist);
  outPktLengths_ = histMap->getOrCreateUnlocked(statName("out_pkt_lengths"),
                                                &pktLenHist);

  setConfiguredMaxSpeed();

  VLOG(2) << "created BCM port:" << port_ << ", gport:" << gport_
          << ", FBOSS PortID:" << platformPort_->getPortID();
}
示例#2
0
void BcmPort::reinitPortStats() {
  if (!shouldReportStats()) {
    return;
  }

  reinitPortStat(kInBytes);
  reinitPortStat(kInUnicastPkts);
  reinitPortStat(kInMulticastPkts);
  reinitPortStat(kInBroadcastPkts);
  reinitPortStat(kInDiscards);
  reinitPortStat(kInErrors);
  reinitPortStat(kInPause);
  reinitPortStat(kInIpv4HdrErrors);
  reinitPortStat(kInIpv6HdrErrors);
  reinitPortStat(kInNonPauseDiscards);

  reinitPortStat(kOutBytes);
  reinitPortStat(kOutUnicastPkts);
  reinitPortStat(kOutMulticastPkts);
  reinitPortStat(kOutBroadcastPkts);
  reinitPortStat(kOutDiscards);
  reinitPortStat(kOutErrors);
  reinitPortStat(kOutPause);
  reinitPortStat(kOutCongestionDiscards);

  // (re) init out queue length
  auto statMap = fbData->getStatMap();
  const auto expType = stats::AVG;
  outQueueLen_ = statMap->getLockableStat(statName("out_queue_length"),
                                          &expType);
  // (re) init histograms
  auto histMap = fbData->getHistogramMap();
  stats::ExportedHistogram pktLenHist(1, 0, kInPktLengthStats.size());
  inPktLengths_ = histMap->getOrCreateLockableHistogram(
      statName("in_pkt_lengths"), &pktLenHist);
  outPktLengths_ = histMap->getOrCreateLockableHistogram(
      statName("out_pkt_lengths"), &pktLenHist);
}