void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, int size, int qidx)
{ struct otx2_lmt_info *lmt_info; struct otx2_nic *pfvf = dev;
u64 val = 0, tar_addr = 0;
lmt_info = per_cpu_ptr(pfvf->hw.lmt_info, smp_processor_id()); /* FIXME: val[0:10] LMT_ID. * [12:15] no of LMTST - 1 in the burst. * [19:63] data size of each LMTST in the burst except first.
*/
val = (lmt_info->lmt_id & 0x7FF); /* Target address for LMTST flush tells HW how many 128bit * words are present. * tar_addr[6:4] size of first LMTST - 1 in units of 128b.
*/
tar_addr |= sq->io_addr | (((size / 16) - 1) & 0x7) << 4;
dma_wmb();
memcpy((u64 *)lmt_info->lmt_addr, sq->sqe_base, size);
cn10k_lmt_flush(val, tar_addr);
sq->head++;
sq->head &= (sq->sqe_cnt - 1);
}
int cn10k_free_all_ipolicers(struct otx2_nic *pfvf)
{ struct nix_bandprof_free_req *req; int rc;
staticvoid cn10k_get_ingress_burst_cfg(u32 burst, u32 *burst_exp,
u32 *burst_mantissa)
{ int tmp;
/* Burst is calculated as * (1+[BURST_MANTISSA]/256)*2^[BURST_EXPONENT] * This is the upper limit on number tokens (bytes) that * can be accumulated in the bucket.
*/
*burst_exp = ilog2(burst); if (burst < 256) { /* No float: can't express mantissa in this case */
*burst_mantissa = 0; return;
}
if (*burst_exp > MAX_RATE_EXP)
*burst_exp = MAX_RATE_EXP;
/* Figure out mantissa, exponent and divider from given max pkt rate * * To achieve desired rate HW adds * (1+[RATE_MANTISSA]/256)*2^[RATE_EXPONENT] tokens (bytes) at every * policer timeunit * 2^rdiv ie 2 * 2^rdiv usecs, to the token bucket. * Here policer timeunit is 2 usecs and rate is in bits per sec. * Since floating point cannot be used below algorithm uses 1000000 * scale factor to support rates upto 100Gbps.
*/
tmp = rate * 32 * 2; if (tmp < 256000000) { while (tmp < 256000000) {
tmp = tmp * 2;
div++;
}
} else { for (exp = 0; tmp >= 512000000 && exp <= MAX_RATE_EXP; exp++)
tmp = tmp / 2;
int cn10k_map_unmap_rq_policer(struct otx2_nic *pfvf, int rq_idx,
u16 policer, bool map)
{ struct nix_cn10k_aq_enq_req *aq;
aq = otx2_mbox_alloc_msg_nix_cn10k_aq_enq(&pfvf->mbox); if (!aq) return -ENOMEM;
/* Enable policing and set the bandwidth profile (policer) index */ if (map)
aq->rq.policer_ena = 1; else
aq->rq.policer_ena = 0;
aq->rq_mask.policer_ena = 1;
/* Get exponent and mantissa values for the desired rate */
cn10k_get_ingress_burst_cfg(burst, &burst_exp, &burst_mantissa);
cn10k_get_ingress_rate_cfg(rate, &rate_exp, &rate_mantissa, &rdiv);
/* Init bandwidth profile */
aq = otx2_mbox_alloc_msg_nix_cn10k_aq_enq(&pfvf->mbox); if (!aq) return -ENOMEM;
/* Set initial color mode to blind */
aq->prof.icolor = 0x03;
aq->prof_mask.icolor = 0x03;
/* Set rate and burst values */
aq->prof.cir_exponent = rate_exp;
aq->prof_mask.cir_exponent = 0x1F;
if (pps) { /* The amount of decremented tokens is calculated according to * the following equation: * max([ LMODE ? 0 : (packet_length - LXPTR)] + * ([ADJUST_MANTISSA]/256 - 1) * 2^[ADJUST_EXPONENT], * 1/256) * if LMODE is 1 then rate limiting will be based on * PPS otherwise bps. * The aim of the ADJUST value is to specify a token cost per * packet in contrary to the packet length that specifies a * cost per byte. To rate limit based on PPS adjust mantissa * is set as 384 and exponent as 1 so that number of tokens * decremented becomes 1 i.e, 1 token per packeet.
*/
aq->prof.adjust_exponent = 1;
aq->prof_mask.adjust_exponent = 0x1F;
/* Two rate three color marker * With PEIR/EIR set to zero, color will be either green or red
*/
aq->prof.meter_algo = 2;
aq->prof_mask.meter_algo = 0x3;
/* Setting exponent value as 24 and mantissa as 0 configures * the bucket with zero values making bucket unused. Peak * information rate and Excess information rate buckets are * unused here.
*/
aq->prof.peir_exponent = 24;
aq->prof_mask.peir_exponent = 0x1F;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.