/**
@brief Calculate the saturation field value required for the requested
       bandwidth and window size.

@param[in] uBandwidth - Bandwidth in bytes/sec
@param[in] uWindowSize - Window size in nanoseconds
@param[in] uQosFreq   - The frequency of the Qos clock

@returns The appropriate saturation field value, will ceiling at max allowed
         field size.
*/
static uint32_t noc_calc_sat_field
(
  uint64_t uBandwidth,
  uint32_t uWindowSize,
  uint32_t uQosFreq
)
{
  uint32_t uSatField = 0;

  /* Shortcut if necessary. */ 
  if( uBandwidth )
  {
	/* Limit to max bandwidth and scale the bandwidth down to 100KB increments.
    * We run the risk of blowing out of 64-bits without it. */ 
    uint64_t uBandwidthScaled = MIN(uBandwidth, MAX_BW(uQosFreq));
    uBandwidthScaled = CEILING_DIV(uBandwidthScaled, 100000);

    /* Calculate the saturation from the window size.
    ** Window size *can* be zero.
    ** Saturation must not exceed the maximum allowed field size.
    ** Note the additional scaling factor in the division, due to units:
    ** 10 for the bandwidth being in 100KB increments (instead of MB)
    ** 1000 for the window size being in ns (instead of us)
    ** 1000 for qos freq being in KHz (instead of MHz)
    ** Total: 10000000ULL
    */
    uSatField = (uint32_t)MIN(CEILING_DIV(uBandwidthScaled * uWindowSize * uQosFreq, 10000000ULL * BW_SCALE * SAT_SCALE), MAX_SAT_FIELD);
  }

  return uSatField;
}
static uint64_t noc_calc_bw_ceil
(
  uint32_t uBwField,
  uint32_t uQosFreq
)
{
  return CEILING_DIV(2ULL * uQosFreq * uBwField, 1000 * BW_SCALE) * 1000000ULL;
}
/**
@brief Calculate the bandwidth field value required for the requested
       bandwidth.

@pre Expects uQosFreq to be non-zero.

@param[in] pBandwidth - The bandwidth structure
@param[in] uQosFreq   - The frequency of the Qos clock

@returns The appropriate bandwidth field value, will ceiling at max allowed
         field size.
*/
static uint32_t noc_calc_bw_field
(
  uint64_t uBandwidth,
  uint32_t uQosFreq
)
{
  uint32_t uBwField = 0;

  /* Shortcut if necessary. */ 
  if( uBandwidth )
  {
    /* Calculate field, and cap to maximum. */
    uint64_t uBandwidthCapped = MIN(uBandwidth, MAX_BW(uQosFreq));
    uBwField = (uint32_t)MIN(CEILING_DIV(BW_SCALE * uBandwidthCapped, 2 * uQosFreq * 1000), MAX_BW_FIELD);
  }

  return uBwField;
}
예제 #4
0
파일: regexp.c 프로젝트: sfraize/TemuTerm
void NegateBitArray(BitArrayRef set, int num_bits) {
    int i;
    for(i=0; i<CEILING_DIV(num_bits, BITS_PER_INT); i++) {
	set[i] = ~set[i];
    }
}
예제 #5
0
파일: regexp.c 프로젝트: sfraize/TemuTerm
void CopyBitArray(BitArrayRef dest, BitArrayRef source, int num_bits) {
    memmove(dest, source, CEILING_DIV(num_bits, CHAR_BIT));
}
예제 #6
0
파일: regexp.c 프로젝트: sfraize/TemuTerm
void SetAllBitArray(BitArrayRef set, int num_bits) {
    memset(set, UCHAR_MAX, CEILING_DIV(num_bits, CHAR_BIT));
}
예제 #7
0
파일: regexp.c 프로젝트: sfraize/TemuTerm
void ZeroOutBitArray(BitArrayRef set, int num_bits) {
    memset(set, 0, CEILING_DIV(num_bits, CHAR_BIT));
}