/** NIX policer rate limits */
#define NIX_BPF_MAX_RATE_DIV_EXP 12
-#define NIX_BPF_MAX_RATE_EXPONENT 0xf
+#define NIX_BPF_MAX_RATE_EXPONENT 0x16
#define NIX_BPF_MAX_RATE_MANTISSA 0xff
-#define NIX_BPF_RATE_CONST 2000000ULL
+#define NIX_BPF_RATE_CONST 8000000000ULL
/* NIX rate calculation in Bits/Sec
* PIR_ADD = ((256 + NIX_*_PIR[RATE_MANTISSA])
* << NIX_*_CIR[RATE_EXPONENT]) / 256
* CIR = (2E6 * CIR_ADD / (CCLK_TICKS << NIX_*_CIR[RATE_DIVIDER_EXPONENT]))
*/
-#define NIX_BPF_RATE(exponent, mantissa, div_exp) \
+#define NIX_BPF_RATE(policer_timeunit, exponent, mantissa, div_exp) \
((NIX_BPF_RATE_CONST * ((256 + (mantissa)) << (exponent))) / \
- (((1ull << (div_exp)) * 256)))
+ (((1ull << (div_exp)) * 256 * policer_timeunit)))
/* Meter rate limits in Bits/Sec */
-#define NIX_BPF_RATE_MIN NIX_BPF_RATE(0, 0, NIX_BPF_MAX_RATE_DIV_EXP)
+#define NIX_BPF_RATE_MIN NIX_BPF_RATE(1000000000, 0, 0, 0)
#define NIX_BPF_RATE_MAX \
- NIX_BPF_RATE(NIX_BPF_MAX_RATE_EXPONENT, NIX_BPF_MAX_RATE_MANTISSA, 0)
+ NIX_BPF_RATE(1, NIX_BPF_MAX_RATE_EXPONENT, NIX_BPF_MAX_RATE_MANTISSA, 0)
#define NIX_BPF_DEFAULT_ADJUST_MANTISSA 511
#define NIX_BPF_DEFAULT_ADJUST_EXPONENT 0
M(TIM_ENABLE_RING, 0x803, tim_enable_ring, tim_ring_req, \
tim_enable_rsp) \
M(TIM_DISABLE_RING, 0x804, tim_disable_ring, tim_ring_req, msg_rsp) \
+ M(TIM_GET_MIN_INTVL, 0x805, tim_get_min_intvl, tim_intvl_req, \
+ tim_intvl_rsp) \
/* CPT mbox IDs (range 0xA00 - 0xBFF) */ \
M(CPT_LF_ALLOC, 0xA00, cpt_lf_alloc, cpt_lf_alloc_req_msg, msg_rsp) \
M(CPT_LF_FREE, 0xA01, cpt_lf_free, msg_req, msg_rsp) \
nix_bandprof_alloc_req, nix_bandprof_alloc_rsp) \
M(NIX_BANDPROF_FREE, 0x801e, nix_bandprof_free, nix_bandprof_free_req, \
msg_rsp) \
+ M(NIX_BANDPROF_GET_HWINFO, 0x801f, nix_bandprof_get_hwinfo, msg_req, \
+ nix_bandprof_get_hwinfo_rsp) \
M(NIX_CPT_BP_ENABLE, 0x8020, nix_cpt_bp_enable, nix_bp_cfg_req, \
nix_bp_cfg_rsp) \
M(NIX_CPT_BP_DISABLE, 0x8021, nix_cpt_bp_disable, nix_bp_cfg_req, \
uint16_t __io prof_idx[NIX_RX_BAND_PROF_LAYER_MAX][BANDPROF_PER_PFFUNC];
};
+struct nix_bandprof_get_hwinfo_rsp {
+ struct mbox_msghdr hdr;
+ uint16_t __io prof_count[NIX_RX_BAND_PROF_LAYER_MAX];
+ uint32_t __io policer_timeunit;
+};
+
/* SSO mailbox error codes
* Range 501 - 600.
*/
uint32_t __io chunksize;
uint32_t __io interval;
uint8_t __io gpioedge;
+ uint8_t __io rsvd[7];
+ uint64_t __io intervalns;
+ uint64_t __io clockfreq;
};
struct tim_lf_alloc_rsp {
uint32_t __io currentbucket;
};
+struct tim_intvl_req {
+ struct mbox_msghdr hdr;
+ uint8_t __io clocksource;
+ uint64_t __io clockfreq;
+};
+
+struct tim_intvl_rsp {
+ struct mbox_msghdr hdr;
+ uint64_t __io intvl_cyc;
+ uint64_t __io intvl_ns;
+};
+
struct sdp_node_info {
/* Node to which this PF belons to */
uint8_t __io node_id;
static inline uint64_t
meter_rate_to_nix(uint64_t value, uint64_t *exponent_p, uint64_t *mantissa_p,
- uint64_t *div_exp_p)
+ uint64_t *div_exp_p, uint32_t timeunit_p)
{
uint64_t div_exp, exponent, mantissa;
+ uint32_t time_us = timeunit_p;
/* Boundary checks */
if (value < NIX_BPF_RATE_MIN || value > NIX_BPF_RATE_MAX)
return 0;
- if (value <= NIX_BPF_RATE(0, 0, 0)) {
+ if (value <= NIX_BPF_RATE(time_us, 0, 0, 0)) {
/* Calculate rate div_exp and mantissa using
* the following formula:
*
*mantissa_p = mantissa;
/* Calculate real rate value */
- return NIX_BPF_RATE(exponent, mantissa, div_exp);
+ return NIX_BPF_RATE(time_us, exponent, mantissa, div_exp);
}
static inline uint64_t
return idx;
}
+int
+roc_nix_bpf_timeunit_get(struct roc_nix *roc_nix, uint32_t *time_unit)
+{
+ struct nix_bandprof_get_hwinfo_rsp *rsp;
+ struct mbox *mbox = get_mbox(roc_nix);
+ struct msg_req *req;
+ int rc = -ENOSPC;
+
+ if (roc_model_is_cn9k())
+ return NIX_ERR_HW_NOTSUP;
+
+ req = mbox_alloc_msg_nix_bandprof_get_hwinfo(mbox);
+ if (req == NULL)
+ goto exit;
+
+ rc = mbox_process_msg(mbox, (void *)&rsp);
+ if (rc)
+ goto exit;
+
+ *time_unit = rsp->policer_timeunit;
+
+exit:
+ return rc;
+}
+
int
roc_nix_bpf_count_get(struct roc_nix *roc_nix, uint8_t lvl_mask,
uint16_t count[ROC_NIX_BPF_LEVEL_MAX])
{
uint8_t mask = lvl_mask & NIX_BPF_LEVEL_F_MASK;
+ struct nix_bandprof_get_hwinfo_rsp *rsp;
+ struct mbox *mbox = get_mbox(roc_nix);
uint8_t leaf_idx, mid_idx, top_idx;
-
- PLT_SET_USED(roc_nix);
+ struct msg_req *req;
+ int rc = -ENOSPC;
if (roc_model_is_cn9k())
return NIX_ERR_HW_NOTSUP;
if (!mask)
return NIX_ERR_PARAM;
- /* Currently No MBOX interface is available to get number
- * of bandwidth profiles. So numbers per level are hard coded,
- * considering 3 RPM blocks and each block has 4 LMAC's.
- * So total 12 physical interfaces are in system. Each interface
- * supports following bandwidth profiles.
- */
+ req = mbox_alloc_msg_nix_bandprof_get_hwinfo(mbox);
+ if (req == NULL)
+ goto exit;
+
+ rc = mbox_process_msg(mbox, (void *)&rsp);
+ if (rc)
+ goto exit;
leaf_idx = roc_nix_bpf_level_to_idx(mask & ROC_NIX_BPF_LEVEL_F_LEAF);
mid_idx = roc_nix_bpf_level_to_idx(mask & ROC_NIX_BPF_LEVEL_F_MID);
top_idx = roc_nix_bpf_level_to_idx(mask & ROC_NIX_BPF_LEVEL_F_TOP);
if (leaf_idx != ROC_NIX_BPF_LEVEL_IDX_INVALID)
- count[leaf_idx] = NIX_MAX_BPF_COUNT_LEAF_LAYER;
+ count[leaf_idx] = rsp->prof_count[sw_to_hw_lvl_map[leaf_idx]];
if (mid_idx != ROC_NIX_BPF_LEVEL_IDX_INVALID)
- count[mid_idx] = NIX_MAX_BPF_COUNT_MID_LAYER;
+ count[mid_idx] = rsp->prof_count[sw_to_hw_lvl_map[mid_idx]];
if (top_idx != ROC_NIX_BPF_LEVEL_IDX_INVALID)
- count[top_idx] = NIX_MAX_BPF_COUNT_TOP_LAYER;
+ count[top_idx] = rsp->prof_count[sw_to_hw_lvl_map[top_idx]];
- return 0;
+exit:
+ return rc;
}
int
uint64_t exponent_p = 0, mantissa_p = 0, div_exp_p = 0;
struct mbox *mbox = get_mbox(roc_nix);
struct nix_cn10k_aq_enq_req *aq;
+ uint32_t policer_timeunit;
uint8_t level_idx;
+ int rc;
if (roc_model_is_cn9k())
return NIX_ERR_HW_NOTSUP;
if (!cfg)
return NIX_ERR_PARAM;
+ rc = roc_nix_bpf_timeunit_get(roc_nix, &policer_timeunit);
+ if (rc)
+ return rc;
+
level_idx = roc_nix_bpf_level_to_idx(lvl_flag);
if (level_idx == ROC_NIX_BPF_LEVEL_IDX_INVALID)
return NIX_ERR_PARAM;
switch (cfg->alg) {
case ROC_NIX_BPF_ALGO_2697:
meter_rate_to_nix(cfg->algo2697.cir, &exponent_p, &mantissa_p,
- &div_exp_p);
+ &div_exp_p, policer_timeunit);
aq->prof.cir_mantissa = mantissa_p;
aq->prof.cir_exponent = exponent_p;
case ROC_NIX_BPF_ALGO_2698:
meter_rate_to_nix(cfg->algo2698.cir, &exponent_p, &mantissa_p,
- &div_exp_p);
+ &div_exp_p, policer_timeunit);
aq->prof.cir_mantissa = mantissa_p;
aq->prof.cir_exponent = exponent_p;
meter_rate_to_nix(cfg->algo2698.pir, &exponent_p, &mantissa_p,
- &div_exp_p);
+ &div_exp_p, policer_timeunit);
aq->prof.peir_mantissa = mantissa_p;
aq->prof.peir_exponent = exponent_p;
case ROC_NIX_BPF_ALGO_4115:
meter_rate_to_nix(cfg->algo4115.cir, &exponent_p, &mantissa_p,
- &div_exp_p);
+ &div_exp_p, policer_timeunit);
aq->prof.cir_mantissa = mantissa_p;
aq->prof.cir_exponent = exponent_p;
meter_rate_to_nix(cfg->algo4115.eir, &exponent_p, &mantissa_p,
- &div_exp_p);
+ &div_exp_p, policer_timeunit);
aq->prof.peir_mantissa = mantissa_p;
aq->prof.peir_exponent = exponent_p;