summaryrefslogtreecommitdiff
path: root/drivers/staging/fsl_dpa_offload
diff options
context:
space:
mode:
authorAurelian Zanoschi <Aurelian.Zanoschi@freescale.com>2013-07-22 13:11:58 (GMT)
committerRivera Jose-B46482 <Jose.G.Rivera@freescale.com>2013-08-13 16:48:46 (GMT)
commitb3ae4204500b7b1dc56b576629dde33b3ba6edf8 (patch)
tree72107ee854aef2b9a6140301bbbfd9b859711c80 /drivers/staging/fsl_dpa_offload
parent6b7db5dc558dcf99f781be85a688abcdf75f2869 (diff)
downloadlinux-fsl-qoriq-b3ae4204500b7b1dc56b576629dde33b3ba6edf8.tar.xz
dpa_offload: Updated the traffic manager counter implementation
Updated the traffic manager implementation based on the QMan CEETM API updates. The compilation warnings problem was also fixed. This commit fixes the statistics selection and checks for counter source and counter type. Change-Id: I329d390b52361dc944fc51c6f4f9c6059cd7a5a9 Signed-off-by: Aurelian Zanoschi <Aurelian.Zanoschi@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/3437 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Floarea Anca Jeanina-B12569 <anca.floarea@freescale.com> Reviewed-by: Rivera Jose-B46482 <Jose.G.Rivera@freescale.com>
Diffstat (limited to 'drivers/staging/fsl_dpa_offload')
-rw-r--r--drivers/staging/fsl_dpa_offload/dpa_stats.c132
1 files changed, 73 insertions, 59 deletions
diff --git a/drivers/staging/fsl_dpa_offload/dpa_stats.c b/drivers/staging/fsl_dpa_offload/dpa_stats.c
index b911732..49ef4cb 100644
--- a/drivers/staging/fsl_dpa_offload/dpa_stats.c
+++ b/drivers/staging/fsl_dpa_offload/dpa_stats.c
@@ -1605,7 +1605,7 @@ static int set_cnt_traffic_mng_cb(struct dpa_stats_cnt_cb *cnt_cb,
struct dpa_stats *dpa_stats = cnt_cb->dpa_stats;
uint32_t cnt_sel = params->traffic_mng_params.cnt_sel;
uint32_t cnt_src = params->traffic_mng_params.src;
- uint64_t frames, bytes;
+ u64 frames = 0, bytes = 0;
int err = 0;
if (!dpa_stats) {
@@ -1618,10 +1618,19 @@ static int set_cnt_traffic_mng_cb(struct dpa_stats_cnt_cb *cnt_cb,
return -EFAULT;
}
- if (cnt_sel == 0 || cnt_sel > DPA_STATS_CNT_NUM_ALL) {
- log_err("Parameter cnt_sel %d must be in range (1 - %d) for "
- "counter id %d\n", cnt_sel, DPA_STATS_CNT_NUM_ALL,
- cnt_cb->id);
+ /* check the counter src */
+ if (cnt_src > DPA_STATS_CNT_TRAFFIC_CG) {
+ log_err("Parameter src %d must be in range (%d - %d) for "
+ "counter id %d\n", cnt_src, DPA_STATS_CNT_TRAFFIC_CLASS,
+ DPA_STATS_CNT_TRAFFIC_CG, cnt_cb->id);
+ return -EINVAL;
+ }
+
+ /* check the counter selection */
+ if (cnt_sel > DPA_STATS_CNT_NUM_ALL) {
+ log_err("Parameter cnt_sel %d must be in range (%d - %d) for "
+ "counter id %d\n", cnt_sel, DPA_STATS_CNT_NUM_OF_BYTES,
+ DPA_STATS_CNT_NUM_ALL, cnt_cb->id);
return -EINVAL;
}
@@ -1659,12 +1668,11 @@ static int set_cnt_traffic_mng_cb(struct dpa_stats_cnt_cb *cnt_cb,
return -EINVAL;
}
- /* Decrease one to obtain the mask for all statistics */
+ /* Set number of statistics that will be written by this counter */
if (cnt_sel == DPA_STATS_CNT_NUM_ALL)
- cnt_sel -= 1;
-
- cnt_sel_to_stats(&cnt_cb->info,
- dpa_stats->stats_sel[DPA_STATS_CNT_TRAFFIC_MNG], cnt_sel);
+ cnt_cb->info.stats_num = 2;
+ else
+ cnt_cb->info.stats_num = 1;
/* Set number of bytes that will be written by this counter */
cnt_cb->bytes_num = STATS_VAL_SIZE * cnt_cb->info.stats_num;
@@ -2241,7 +2249,7 @@ static int set_cls_cnt_traffic_mng_cb(struct dpa_stats_cnt_cb *cnt_cb,
uint32_t cnt_sel = params->traffic_mng_params.cnt_sel;
uint32_t cnt_src = params->traffic_mng_params.src;
uint32_t i = 0;
- uint64_t frames, bytes;
+ u64 frames = 0, bytes = 0;
int err = 0;
if (!dpa_stats) {
@@ -2249,69 +2257,75 @@ static int set_cls_cnt_traffic_mng_cb(struct dpa_stats_cnt_cb *cnt_cb,
return -EFAULT;
}
- /* First check the counter src */
- if (cnt_src > DPA_STATS_CNT_TRAFFIC_CG ||
- cnt_src < DPA_STATS_CNT_TRAFFIC_CLASS) {
- log_err("Parameter src %d must be in range (%d - %d) for "
- "counter id %d\n", cnt_src, DPA_STATS_CNT_TRAFFIC_CLASS,
- DPA_STATS_CNT_TRAFFIC_CG, cnt_cb->id);
- return -EINVAL;
- }
-
- /* Then check the counter selection */
- if (cnt_sel == 0 || cnt_sel > DPA_STATS_CNT_NUM_ALL) {
- log_err("Parameter cnt_sel %d must be in range (1 - %d) for "
- "counter id %d\n", cnt_sel, DPA_STATS_CNT_NUM_ALL,
- cnt_cb->id);
+ /* check the counter selection */
+ if (cnt_sel > DPA_STATS_CNT_NUM_ALL) {
+ log_err("Parameter cnt_sel %d must be in range (%d - %d) for "
+ "counter id %d\n", cnt_sel, DPA_STATS_CNT_NUM_OF_BYTES,
+ DPA_STATS_CNT_NUM_ALL, cnt_cb->id);
return -EINVAL;
}
cnt_cb->members_num = params->class_members;
- /* Check the user provided Traffic Manager object */
- for (i = 0; i < params->class_members; i++) {
- if (!params->traffic_mng_params.traffic_mng[i]) {
- log_err("Parameter traffic_mng handle cannot be NULL "
- "for member %d\n", i);
- return -EFAULT;
- }
- cnt_cb->gen_cb.objs[i] =
+ /* check the counter src and set the get function */
+ switch (cnt_src) {
+ case DPA_STATS_CNT_TRAFFIC_CLASS:
+ cnt_cb->f_get_cnt_stats = get_cnt_traffic_mng_cq_stats;
+ for (i = 0; i < params->class_members; i++) {
+ if (!params->traffic_mng_params.traffic_mng[i]) {
+ log_err("Parameter traffic_mng handle cannot be"
+ " NULL for member %d\n", i);
+ return -EFAULT;
+ }
+ cnt_cb->gen_cb.objs[i] =
params->traffic_mng_params.traffic_mng[i];
-
- switch (cnt_src) {
- case DPA_STATS_CNT_TRAFFIC_CLASS:
- cnt_cb->f_get_cnt_stats = get_cnt_traffic_mng_cq_stats;
+ /* Check the user provided Traffic Manager object */
err = qman_ceetm_cq_get_dequeue_statistics(
- params->traffic_mng_params.traffic_mng[i], 0,
- &frames, &bytes);
+ cnt_cb->gen_cb.objs[i], 0, &frames,
+ &bytes);
if (err < 0) {
log_err("Invalid Traffic Manager qm_ceetm_cq "
"object for counter id %d\n",
cnt_cb->id);
return -EINVAL;
}
- break;
- case DPA_STATS_CNT_TRAFFIC_CG:
- cnt_cb->f_get_cnt_stats = get_cnt_traffic_mng_ccg_stats;
+ }
+ break;
+
+ case DPA_STATS_CNT_TRAFFIC_CG:
+ cnt_cb->f_get_cnt_stats = get_cnt_traffic_mng_ccg_stats;
+ for (i = 0; i < params->class_members; i++) {
+ if (!params->traffic_mng_params.traffic_mng[i]) {
+ log_err("Parameter traffic_mng handle cannot be"
+ " NULL for member %d\n", i);
+ return -EFAULT;
+ }
+ cnt_cb->gen_cb.objs[i] =
+ params->traffic_mng_params.traffic_mng[i];
+ /* Check the user provided Traffic Manager object */
err = qman_ceetm_ccg_get_reject_statistics(
- params->traffic_mng_params.traffic_mng[i], 0,
- &frames, &bytes);
+ cnt_cb->gen_cb.objs[i], 0, &frames,
+ &bytes);
if (err < 0) {
- log_err("Invalid Traffic Manager qm_ceetm_ccg "
- "object for counter id %d\n",
- cnt_cb->id);
+ log_err("Invalid Traffic Manager qm_ceetm_cq "
+ "object for counter id %d\n",
+ cnt_cb->id);
return -EINVAL;
}
- break;
}
+ break;
+ default:
+ log_err("Parameter src %d must be in range (%d - %d) for "
+ "counter id %d\n", cnt_src, DPA_STATS_CNT_TRAFFIC_CLASS,
+ DPA_STATS_CNT_TRAFFIC_CG, cnt_cb->id);
+ return -EINVAL;
}
- /* Decrease one to obtain the mask for all statistics */
+ /* Set number of statistics that will be written by this counter */
if (cnt_sel == DPA_STATS_CNT_NUM_ALL)
- cnt_sel -= 1;
-
- cnt_sel_to_stats(&cnt_cb->info,
- dpa_stats->stats_sel[DPA_STATS_CNT_TRAFFIC_MNG], cnt_sel);
+ cnt_cb->info.stats_num = 2;
+ else
+ cnt_cb->info.stats_num = 1;
/* Set number of bytes that will be written by this counter */
cnt_cb->bytes_num = cnt_cb->members_num *
@@ -2871,14 +2885,14 @@ static int get_cnt_traffic_mng_cq_stats(struct dpa_stats_req_cb *req_cb,
struct dpa_stats_cnt_cb *cnt_cb)
{
uint32_t i = 0;
- uint64_t stats_val[2];
+ u64 stats_val[2];
int err = 0;
for (i = 0; i < cnt_cb->members_num; i++) {
/* Retrieve statistics for the current member */
err = qman_ceetm_cq_get_dequeue_statistics(
cnt_cb->gen_cb.objs[i], 0,
- stats_val[1], stats_val[0]);
+ &stats_val[1], &stats_val[0]);
if (err < 0) {
log_err("Cannot retrieve Traffic Manager Class Queue "
"statistics for counter id %d\n", cnt_cb->id);
@@ -2893,13 +2907,13 @@ static int get_cnt_traffic_mng_ccg_stats(struct dpa_stats_req_cb *req_cb,
struct dpa_stats_cnt_cb *cnt_cb)
{
uint32_t i = 0;
- uint64_t stats_val[2];
+ u64 stats_val[2];
int err = 0;
for (i = 0; i < cnt_cb->members_num; i++) {
err = qman_ceetm_ccg_get_reject_statistics(
cnt_cb->gen_cb.objs[i], 0,
- stats_val[1], stats_val[0]);
+ &stats_val[1], &stats_val[0]);
if (err < 0) {
log_err("Cannot retrieve Traffic Manager Class "
"Congestion Group statistics for counter id "
@@ -3533,8 +3547,8 @@ int dpa_stats_get_counters(struct dpa_stats_cnt_request_params params,
for (i = 0; i < params.cnts_ids_len; i++) {
if (params.cnts_ids[i] == DPA_OFFLD_INVALID_OBJECT_ID ||
params.cnts_ids[i] > dpa_stats->config.max_counters) {
- log_err("Counter id (cnt_ids[%d]) %d is not initialized "
- "or is greater than maximum counters %d\n", i,
+ log_err("Counter id (cnt_ids[%d]) %d is not initialized"
+ " or is greater than maximum counters %d\n", i,
params.cnts_ids[i],
dpa_stats->config.max_counters);
return -EINVAL;