From d31ab8884b031d63f82f9946c7bf7aaf235c9260 Mon Sep 17 00:00:00 2001 From: Varun Sethi Date: Fri, 16 Aug 2013 00:25:32 +0530 Subject: Check for valid window before proceeding to set the stash or the omi attribute. Signed-off-by: Varun Sethi Change-Id: I6bbad9f1f1240fa23ae6997f5a0cdc6cb49228e1 Reviewed-on: http://git.am.freescale.net:8181/4035 Reviewed-by: Yoder Stuart-B08248 Reviewed-by: Rivera Jose-B46482 Tested-by: Rivera Jose-B46482 diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c index 99c182d..b7b915e 100644 --- a/drivers/iommu/fsl_pamu_domain.c +++ b/drivers/iommu/fsl_pamu_domain.c @@ -800,6 +800,11 @@ static int configure_domain_geometry(struct iommu_domain *domain, void *data) return 0; } +static inline int check_attr_window(u32 wnd, struct fsl_dma_domain *dma_domain) +{ + return ((~wnd != 0) && (wnd >= dma_domain->win_cnt)); +} + /* Set the domain operation mapping attribute */ static int configure_domain_op_map(struct fsl_dma_domain *dma_domain, void *data) @@ -818,7 +823,8 @@ static int configure_domain_op_map(struct fsl_dma_domain *dma_domain, return -ENODEV; } - if (omi_attr->omi >= OMI_MAX) { + if (omi_attr->omi >= OMI_MAX || + check_attr_window(omi_attr->window, dma_domain)) { pr_err("Invalid operation mapping index\n"); spin_unlock_irqrestore(&dma_domain->domain_lock, flags); return -EINVAL; @@ -863,7 +869,8 @@ static int configure_domain_stash(struct fsl_dma_domain *dma_domain, void *data) stash_id = get_stash_id(stash_attr->cache, stash_attr->cpu); - if (~stash_id == 0) { + if ((~stash_id == 0) || + check_attr_window(stash_attr->window, dma_domain)) { pr_err("Invalid stash attributes\n"); spin_unlock_irqrestore(&dma_domain->domain_lock, flags); return -EINVAL; -- cgit v0.10.2 From 03f7a7ce577c7fbe4cb84d23f23009ae21f8880f Mon Sep 17 00:00:00 2001 From: Varun Sethi Date: Fri, 16 Aug 2013 00:28:26 +0530 Subject: Enhance get_stash_id API to get the stashid for DSP L2 cache. The stashid for the DSP cluster L2 cache is programmed by SDOS. Signed-off-by: Varun Sethi Change-Id: I7a8203e2dd99e6ccfeacd25305378a4c33becac2 Reviewed-on: http://git.am.freescale.net:8181/4036 Reviewed-by: Rivera Jose-B46482 Tested-by: Rivera Jose-B46482 diff --git a/arch/powerpc/include/asm/fsl_kibo.h b/arch/powerpc/include/asm/fsl_kibo.h new file mode 100644 index 0000000..f0a4166 --- /dev/null +++ b/arch/powerpc/include/asm/fsl_kibo.h @@ -0,0 +1,90 @@ +/** + * Freecale shared cluster L2 cache (Kibo) + * + * Authors: Varun Sethi + * + * Copyright 2013 Freescale Semiconductor, Inc + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __ASM_POWERPC_FSL_KIBO_H__ +#define __ASM_POWERPC_FSL_KIBO_H__ +#ifdef __KERNEL__ + +/** + * Shared cluster L2 cache(Kibo) Registers. + * + * Shared cluster L2 cache or Kibo is a backside cache shared by e6500 and + * star core DSP cores in a cluster. Kibo is present on Freescale SOCs (T4/B4) + * following the chassis 2 specification. + * + * These registers are memory mapped and can be accessed through the CCSR space. + * + */ + +#define CLUSTER_L2_STASH_MASK 0xff + +struct ccsr_cluster_l2 { + u32 l2csr0; /* 0x000 L2 cache control and status register 0 */ + u32 l2csr1; /* 0x004 L2 cache control and status register 1 */ + u32 l2cfg0; /* 0x008 L2 cache configuration register 0 */ + u8 res_0c[500];/* 0x00c - 0x1ff */ + u32 l2pir0; /* 0x200 L2 cache partitioning ID register 0 */ + u8 res_204[4]; + u32 l2par0; /* 0x208 L2 cache partitioning allocation register 0 */ + u32 l2pwr0; /* 0x20c L2 cache partitioning way register 0 */ + u32 l2pir1; /* 0x210 L2 cache partitioning ID register 1 */ + u8 res_214[4]; + u32 l2par1; /* 0x218 L2 cache partitioning allocation register 1 */ + u32 l2pwr1; /* 0x21c L2 cache partitioning way register 1 */ + u32 u2pir2; /* 0x220 L2 cache partitioning ID register 2 */ + u8 res_224[4]; + u32 l2par2; /* 0x228 L2 cache partitioning allocation register 2 */ + u32 l2pwr2; /* 0x22c L2 cache partitioning way register 2 */ + u32 l2pir3; /* 0x230 L2 cache partitioning ID register 3 */ + u8 res_234[4]; + u32 l2par3; /* 0x238 L2 cache partitining allocation register 3 */ + u32 l2pwr3; /* 0x23c L2 cache partitining way register 3 */ + u32 l2pir4; /* 0x240 L2 cache partitioning ID register 3 */ + u8 res244[4]; + u32 l2par4; /* 0x248 L2 cache partitioning allocation register 3 */ + u32 l2pwr4; /* 0x24c L2 cache partitioning way register 3 */ + u32 l2pir5; /* 0x250 L2 cache partitioning ID register 3 */ + u8 res_254[4]; + u32 l2par5; /* 0x258 L2 cache partitioning allocation register 3 */ + u32 l2pwr5; /* 0x25c L2 cache partitioning way register 3 */ + u32 l2pir6; /* 0x260 L2 cache partitioning ID register 3 */ + u8 res_264[4]; + u32 l2par6; /* 0x268 L2 cache partitioning allocation register 3 */ + u32 l2pwr6; /* 0x26c L2 cache partitioning way register 3 */ + u32 l2pir7; /* 0x270 L2 cache partitioning ID register 3 */ + u8 res274[4]; + u32 l2par7; /* 0x278 L2 cache partitioning allocation register 3 */ + u32 l2pwr7; /* 0x27c L2 cache partitioning way register 3 */ + u8 res_280[0xb80]; /* 0x280 - 0xdff */ + u32 l2errinjhi; /* 0xe00 L2 cache error injection mask high */ + u32 l2errinjlo; /* 0xe04 L2 cache error injection mask low */ + u32 l2errinjctl;/* 0xe08 L2 cache error injection control */ + u8 res_e0c[20]; /* 0xe0c - 0x01f */ + u32 l2captdatahi; /* 0xe20 L2 cache error capture data high */ + u32 l2captdatalo; /* 0xe24 L2 cache error capture data low */ + u32 l2captecc; /* 0xe28 L2 cache error capture ECC syndrome */ + u8 res_e2c[20]; /* 0xe2c - 0xe3f */ + u32 l2errdet; /* 0xe40 L2 cache error detect */ + u32 l2errdis; /* 0xe44 L2 cache error disable */ + u32 l2errinten; /* 0xe48 L2 cache error interrupt enable */ + u32 l2errattr; /* 0xe4c L2 cache error attribute */ + u32 l2erreaddr; /* 0xe50 L2 cache error extended address */ + u32 l2erraddr; /* 0xe54 L2 cache error address */ + u32 l2errctl; /* 0xe58 L2 cache error control */ + u8 res_e5c[0xa4]; /* 0xe5c - 0xf00 */ + u32 l2hdbcr0; /* 0xf00 L2 cache hardware debugcontrol register 0 */ + u32 l2hdbcr1; /* 0xf00 L2 cache hardware debugcontrol register 1 */ + u32 l2hdbcr2; /* 0xf00 L2 cache hardware debugcontrol register 2 */ +}; +#endif /*__KERNEL__ */ +#endif /*__ASM_POWERPC_FSL_KIBO_H__*/ diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c index 4d466d6..e4064cf 100644 --- a/drivers/iommu/fsl_pamu.c +++ b/drivers/iommu/fsl_pamu.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "fsl_pamu.h" @@ -529,6 +530,72 @@ void get_ome_index(u32 *omi_index, struct device *dev) *omi_index = OMI_QMAN_PRIV; } +/* + * We get the stash id programmed by SDOS from the shared + * cluster L2 l2csr1 register. + */ +static u32 get_dsp_l2_stash_id(u32 cluster) +{ + const u32 *prop; + struct device_node *node; + struct device_node *dsp_cpu_node; + struct ccsr_cluster_l2 *l2cache_regs; + u32 stash_id; + + for_each_compatible_node(node, NULL, "fsl,sc3900-cluster") { + prop = of_get_property(node, "reg", 0); + if (!prop) { + pr_err("missing reg property in dsp cluster %s\n", + node->full_name); + of_node_put(node); + return ~(u32)0; + } + + if (*prop == cluster) { + dsp_cpu_node = of_find_compatible_node(node, NULL, "fsl,sc3900"); + if (!dsp_cpu_node) { + pr_err("missing dsp cpu node in dsp cluster %s\n", + node->full_name); + of_node_put(node); + return ~(u32)0; + } + of_node_put(node); + + prop = of_get_property(dsp_cpu_node, "next-level-cache", 0); + if (!prop) { + pr_err("missing next level cache property in dsp cpu %s\n", + node->full_name); + of_node_put(dsp_cpu_node); + return ~(u32)0; + } + of_node_put(dsp_cpu_node); + + node = of_find_node_by_phandle(*prop); + if (!node) { + pr_err("Invalid node for cache hierarchy %s\n", + node->full_name); + return ~(u32)0; + } + + l2cache_regs = of_iomap(node, 0); + if (!l2cache_regs) { + pr_err("failed to map cluster l2 cache registers %s\n", + node->full_name); + of_node_put(node); + return ~(u32)0; + } + + stash_id = in_be32(&l2cache_regs->l2csr1) & + CLUSTER_L2_STASH_MASK; + of_node_put(node); + iounmap(l2cache_regs); + + return stash_id; + } + } + return ~(u32)0; +} + /** * get_stash_id - Returns stash destination id corresponding to a * cache type and vcpu. @@ -546,6 +613,10 @@ u32 get_stash_id(u32 stash_dest_hint, u32 vcpu) int len, found = 0; int i; + /* check for DSP L2 cache */ + if (stash_dest_hint == IOMMU_ATTR_CACHE_DSP_L2) { + return get_dsp_l2_stash_id(vcpu); + } /* Fastpath, exit early if L3/CPC cache is target for stashing */ if (stash_dest_hint == IOMMU_ATTR_CACHE_L3) { node = of_find_matching_node(NULL, l3_device_ids); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 5153c0c..18f0dc5 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -45,6 +45,7 @@ enum stash_target { IOMMU_ATTR_CACHE_L1 = 1, IOMMU_ATTR_CACHE_L2, IOMMU_ATTR_CACHE_L3, + IOMMU_ATTR_CACHE_DSP_L2, }; /* This attribute corresponds to IOMMUs capable of generating -- cgit v0.10.2 From a8b2a8b56e9bce84ef3512c39fc154a7ae082406 Mon Sep 17 00:00:00 2001 From: Varun Sethi Date: Wed, 21 Aug 2013 18:59:54 +0530 Subject: Update the operation mapping settings required by the DSP side for Maple and DMA. For the DSP side the basic requirement for stashing is to prevent device initiated reads and writes going to the DDR. RWNITC and WWSOT operation mappings aid in achieving these objectives. Signed-off-by: Varun Sethi Change-Id: I1634ff877d9c8e7c6a3de95aee4a3848cc149973 Reviewed-on: http://git.am.freescale.net:8181/4128 Reviewed-by: Rivera Jose-B46482 Tested-by: Rivera Jose-B46482 diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c index e4064cf..84a5de7 100644 --- a/drivers/iommu/fsl_pamu.c +++ b/drivers/iommu/fsl_pamu.c @@ -778,26 +778,12 @@ static void __init setup_omt(struct ome *omt) ome->moe[IOE_DIRECT0_IDX] = EOE_LDEC | EOE_VALID; ome->moe[IOE_DIRECT1_IDX] = EOE_LDEC | EOE_VALID; - /* Configure OMI_DMA */ - ome = &omt[OMI_DMA]; - ome->moe[IOE_READ_IDX] = EOE_VALID | EOE_RSA; - ome->moe[IOE_EREAD0_IDX] = EOE_VALID | EOE_RSA; - ome->moe[IOE_WRITE_IDX] = EOE_VALID | EOE_WWSA; - ome->moe[IOE_EWRITE0_IDX] = EOE_VALID | EOE_WWSA; - - /* Configure OMI_DMA_READI */ - ome = &omt[OMI_DMA_READI]; - ome->moe[IOE_READ_IDX] = EOE_VALID | EOE_READI; - ome->moe[IOE_EREAD0_IDX] = EOE_VALID | EOE_READI; - ome->moe[IOE_WRITE_IDX] = EOE_VALID | EOE_WWSA; - ome->moe[IOE_EWRITE0_IDX] = EOE_VALID | EOE_WWSA; - - /* Configure OMI_MAPLE */ - ome = &omt[OMI_MAPLE]; - ome->moe[IOE_READ_IDX] = EOE_VALID | EOE_RSA; - ome->moe[IOE_EREAD0_IDX] = EOE_VALID | EOE_RSA; - ome->moe[IOE_WRITE_IDX] = EOE_VALID | EOE_WWSA; - ome->moe[IOE_EWRITE0_IDX] = EOE_VALID | EOE_WWSA; + /* Configure OMI_DSP */ + ome = &omt[OMI_DSP]; + ome->moe[IOE_READ_IDX] = EOE_VALID | EOE_RWNITC; + ome->moe[IOE_EREAD0_IDX] = EOE_VALID | EOE_RWNITC; + ome->moe[IOE_WRITE_IDX] = EOE_VALID | EOE_WWSAO; + ome->moe[IOE_EWRITE0_IDX] = EOE_VALID | EOE_WWSAO; } /* diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 18f0dc5..992d45a 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -90,9 +90,7 @@ enum omap_index { OMI_QMAN_PRIV, OMI_CAAM, OMI_PMAN, - OMI_DMA, - OMI_DMA_READI, - OMI_MAPLE, + OMI_DSP, OMI_MAX, }; -- cgit v0.10.2 From 658fb7c23113780e96ac8fc2503a058d49377281 Mon Sep 17 00:00:00 2001 From: Aurelian Zanoschi Date: Fri, 23 Aug 2013 19:14:21 +0300 Subject: dpa_offload: Added Traffic Manager user-space counter implementation Added support for Traffic Manager user-space DPA Stats counter in driver. The Traffic Manager counters can be used both from user-space or kernel-space depending on the user needs. If the counter is created from user-space, all the retrieving mechanism is implemented in user-space and same happens for kernel-space case. The counters is marked as a user-space counter and the kernel will provide for this counter only the offset where the user-space library to write the statistics of the counter. This patch corrects some compilation warnings caused by QMan CEETM API changes. Change-Id: I48c4df286ab78efe2a16d46c4fd376d153732944 Signed-off-by: Aurelian Zanoschi Reviewed-on: http://git.am.freescale.net:8181/4196 Tested-by: Review Code-CDREVIEW Reviewed-by: Chereji Marian-Cornel-R27762 Reviewed-by: Rivera Jose-B46482 diff --git a/drivers/staging/fsl_dpa_offload/dpa_stats.c b/drivers/staging/fsl_dpa_offload/dpa_stats.c index f82fcc3..be9b0d5 100644 --- a/drivers/staging/fsl_dpa_offload/dpa_stats.c +++ b/drivers/staging/fsl_dpa_offload/dpa_stats.c @@ -51,6 +51,8 @@ #define CLASSIF_STATS_SHIFT 4 #define WORKQUEUE_MAX_ACTIVE 3 +#define DPA_STATS_US_CNT 0x80000000 + /* Global dpa_stats component */ struct dpa_stats *gbl_dpa_stats; @@ -81,6 +83,9 @@ static int get_cnt_traffic_mng_cq_stats(struct dpa_stats_req_cb *req_cb, static int get_cnt_traffic_mng_ccg_stats(struct dpa_stats_req_cb *req_cb, struct dpa_stats_cnt_cb *cnt_cb); +static int get_cnt_us_stats(struct dpa_stats_req_cb *req_cb, + struct dpa_stats_cnt_cb *cnt_cb); + static void async_req_work_func(struct work_struct *work); /* check that the provided params are valid */ @@ -725,11 +730,18 @@ static int treat_cnts_request(struct dpa_stats *dpa_stats, { struct dpa_stats_cnt_request_params params = req_cb->config; struct dpa_stats_cnt_cb *cnt_cb = NULL; - int id = 0, err = 0; + int id = 0, err = 0, *unblock_cnts; uint32_t i = 0; + unblock_cnts = kzalloc(sizeof(int) * params.cnts_ids_len, GFP_KERNEL); + if (!unblock_cnts) { + log_err("Cannot allocate memory for local counter ids array\n"); + return -ENOMEM; + } + for (i = 0; i < params.cnts_ids_len; i++) { id = params.cnts_ids[i]; + unblock_cnts[i] = id; /* Get counter's control block */ cnt_cb = &dpa_stats->cnts_cb[id]; @@ -760,7 +772,7 @@ static int treat_cnts_request(struct dpa_stats *dpa_stats, mutex_unlock(&cnt_cb->lock); } - unblock_sched_cnts(dpa_stats, params.cnts_ids, params.cnts_ids_len); + unblock_sched_cnts(dpa_stats, unblock_cnts, params.cnts_ids_len); return 0; } @@ -1054,10 +1066,10 @@ static void create_cnt_traffic_mng_stats(struct dpa_stats *dpa_stats) { /* DPA_STATS_CNT_NUM_OF_BYTES */ dpa_stats->stats_sel[DPA_STATS_CNT_TRAFFIC_MNG][0] = - DPA_STATS_CNT_NUM_OF_BYTES; + DPA_STATS_CNT_NUM_OF_BYTES * sizeof(uint64_t); /* DPA_STATS_CNT_NUM_OF_PACKETS */ dpa_stats->stats_sel[DPA_STATS_CNT_TRAFFIC_MNG][1] = - DPA_STATS_CNT_NUM_OF_PACKETS; + DPA_STATS_CNT_NUM_OF_PACKETS * sizeof(uint64_t); } static int copy_key_descriptor(const struct dpa_offload_lookup_key *src, @@ -1217,6 +1229,39 @@ static void cnt_sel_to_stats(struct stats_info *stats_info, stats_info->stats_num = cntPos - 1; } +static int cnt_gen_sel_to_stats(struct dpa_stats_cnt_cb *cnt_cb, + enum dpa_stats_cnt_sel cnt_sel) +{ + struct dpa_stats *dpa_stats = cnt_cb->dpa_stats; + + if (cnt_sel == DPA_STATS_CNT_NUM_OF_BYTES) { + cnt_cb->info.stats_off[0] = + dpa_stats->stats_sel[cnt_cb->type][DPA_STATS_CNT_NUM_OF_BYTES]; + cnt_cb->info.stats_num = 1; + } else if (cnt_sel == DPA_STATS_CNT_NUM_OF_PACKETS) { + cnt_cb->info.stats_off[0] = + dpa_stats->stats_sel[cnt_cb->type][DPA_STATS_CNT_NUM_OF_PACKETS]; + cnt_cb->info.stats_num = 1; + } else if (cnt_sel == DPA_STATS_CNT_NUM_ALL) { + cnt_cb->info.stats_off[0] = + dpa_stats->stats_sel[cnt_cb->type][DPA_STATS_CNT_NUM_OF_BYTES]; + cnt_cb->info.stats_off[1] = + dpa_stats->stats_sel[cnt_cb->type][DPA_STATS_CNT_NUM_OF_PACKETS]; + cnt_cb->info.stats_num = 2; + } else { + 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; + } + + /* Set number of bytes that will be written by this counter */ + cnt_cb->bytes_num = cnt_cb->members_num * + STATS_VAL_SIZE * cnt_cb->info.stats_num; + + return 0; +} + static int set_frag_manip(int td, struct dpa_stats_lookup_key *entry) { struct dpa_cls_tbl_action action; @@ -1665,37 +1710,14 @@ static int set_cnt_ccnode_cb(struct dpa_stats_cnt_cb *cnt_cb, static int set_cnt_ipsec_cb(struct dpa_stats_cnt_cb *cnt_cb, const struct dpa_stats_cnt_params *params) { - struct dpa_stats *dpa_stats = cnt_cb->dpa_stats; struct dpa_ipsec_sa_stats stats; - uint32_t cnt_sel = params->ipsec_params.cnt_sel; int err = 0; - if (!dpa_stats) { + if (!cnt_cb->dpa_stats) { log_err("DPA Stats component is not initialized\n"); return -EFAULT; } - /* Map IPSec counter selection to statistics */ - if (cnt_sel == DPA_STATS_CNT_NUM_OF_BYTES) { - cnt_cb->info.stats_off[0] = dpa_stats->stats_sel[ - DPA_STATS_CNT_IPSEC][DPA_STATS_CNT_NUM_OF_BYTES]; - cnt_cb->info.stats_num = 1; - } else if (cnt_sel == DPA_STATS_CNT_NUM_OF_PACKETS) { - cnt_cb->info.stats_off[0] = dpa_stats->stats_sel[ - DPA_STATS_CNT_IPSEC][DPA_STATS_CNT_NUM_OF_PACKETS]; - cnt_cb->info.stats_num = 1; - } else if (cnt_sel == DPA_STATS_CNT_NUM_ALL) { - cnt_cb->info.stats_off[0] = dpa_stats->stats_sel[ - DPA_STATS_CNT_IPSEC][DPA_STATS_CNT_NUM_OF_BYTES]; - cnt_cb->info.stats_off[1] = dpa_stats->stats_sel[ - DPA_STATS_CNT_IPSEC][DPA_STATS_CNT_NUM_OF_PACKETS]; - cnt_cb->info.stats_num = 2; - } else { - 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->ipsec_cb.sa_id[0] = params->ipsec_params.sa_id; cnt_cb->ipsec_cb.valid[0] = TRUE; @@ -1709,8 +1731,10 @@ static int set_cnt_ipsec_cb(struct dpa_stats_cnt_cb *cnt_cb, return -EINVAL; } - /* Set number of bytes that will be written by this counter */ - cnt_cb->bytes_num = STATS_VAL_SIZE * cnt_cb->info.stats_num; + /* Map IPSec counter selection to statistics */ + err = cnt_gen_sel_to_stats(cnt_cb, params->ipsec_params.cnt_sel); + if (err < 0) + return err; return 0; } @@ -1721,29 +1745,48 @@ 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; + bool us_cnt = FALSE; if (!dpa_stats) { log_err("DPA Stats component is not initialized\n"); return -EFAULT; } - if (!params->traffic_mng_params.traffic_mng) { - log_err("Parameter traffic_mng handle cannot be NULL\n"); - return -EFAULT; + /* Check if this is an users-space counter and if so, reset the flag */ + if (cnt_sel & DPA_STATS_US_CNT) { + us_cnt = TRUE; + cnt_sel &= ~DPA_STATS_US_CNT; } - 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); + if (!params->traffic_mng_params.traffic_mng && !us_cnt) { + log_err("Parameter traffic_mng handle cannot be NULL for " + "counter id %d\n", cnt_cb->id); return -EINVAL; } + /* Check and store the counter source */ + 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; + } cnt_cb->gen_cb.objs[0] = params->traffic_mng_params.traffic_mng; cnt_cb->members_num = 1; + /* Map Traffic Manager counter selection to statistics */ + err = cnt_gen_sel_to_stats(cnt_cb, cnt_sel); + if (err < 0) + return err; + + /* For user-space counters there is a different retrieve function */ + if (us_cnt) { + cnt_cb->f_get_cnt_stats = get_cnt_us_stats; + return 0; + } + /* Check the counter source and the Traffic Manager object */ switch (cnt_src) { case DPA_STATS_CNT_TRAFFIC_CLASS: @@ -1768,23 +1811,8 @@ static int set_cnt_traffic_mng_cb(struct dpa_stats_cnt_cb *cnt_cb, return -EINVAL; } 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 */ - 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); - - /* Set number of bytes that will be written by this counter */ - cnt_cb->bytes_num = STATS_VAL_SIZE * cnt_cb->info.stats_num; - return 0; } @@ -2430,86 +2458,85 @@ static int set_cls_cnt_ipsec_cb(struct dpa_stats_cnt_cb *cnt_cb, static int set_cls_cnt_traffic_mng_cb(struct dpa_stats_cnt_cb *cnt_cb, const struct dpa_stats_cls_cnt_params *params) { - 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; - uint32_t i = 0; - uint64_t frames, bytes; + struct dpa_stats_cls_cnt_traffic_mng prm = params->traffic_mng_params; + uint32_t cnt_sel = prm.cnt_sel, i; + u64 frames = 0, bytes = 0; int err = 0; + bool us_cnt = FALSE; - if (!dpa_stats) { + if (!cnt_cb->dpa_stats) { log_err("DPA Stats component is not initialized\n"); 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); - return -EINVAL; + /* Check if this is an users-space counter and if so, reset the flag */ + if (cnt_sel & DPA_STATS_US_CNT) { + us_cnt = TRUE; + cnt_sel &= ~DPA_STATS_US_CNT; } 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] = - params->traffic_mng_params.traffic_mng[i]; + /* Map Traffic Manager counter selection to statistics */ + err = cnt_gen_sel_to_stats(cnt_cb, cnt_sel); + if (err < 0) + return err; - switch (cnt_src) { - case DPA_STATS_CNT_TRAFFIC_CLASS: - cnt_cb->f_get_cnt_stats = get_cnt_traffic_mng_cq_stats; + /* For user-space counters there is a different retrieve function */ + if (us_cnt) { + cnt_cb->f_get_cnt_stats = get_cnt_us_stats; + return 0; + } + + /* Check the counter source and the Traffic Manager object */ + switch (prm.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 (!prm.traffic_mng[i]) { + log_err("Parameter traffic_mng handle cannot " + "be NULL for member %d\n", i); + return -EFAULT; + } + + /* Check the provided Traffic Manager object */ err = qman_ceetm_cq_get_dequeue_statistics( - params->traffic_mng_params.traffic_mng[i], 0, - &frames, &bytes); + prm.traffic_mng[i], 0, &frames, &bytes); if (err < 0) { - log_err("Invalid Traffic Manager qm_ceetm_cq " - "object for counter id %d\n", - cnt_cb->id); + log_err("Invalid traffic_mng handle 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; + cnt_cb->gen_cb.objs[i] = prm.traffic_mng[i]; + } + 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 (!prm.traffic_mng[i]) { + log_err("Parameter traffic_mng handle cannot" + "be NULL for member %d\n", i); + return -EFAULT; + } + + /* Check the provided Traffic Manager object */ err = qman_ceetm_ccg_get_reject_statistics( - params->traffic_mng_params.traffic_mng[i], 0, - &frames, &bytes); + prm.traffic_mng[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_mng handle for counter" + " id %d\n", cnt_cb->id); return -EINVAL; } - break; + cnt_cb->gen_cb.objs[i] = prm.traffic_mng[i]; } + break; + default: + log_err("Parameter src %d must be in range (%d - %d) for " + "counter id %d\n", prm.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 */ - 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); - - /* Set number of bytes that will be written by this counter */ - cnt_cb->bytes_num = cnt_cb->members_num * - STATS_VAL_SIZE * cnt_cb->info.stats_num; - return 0; } @@ -3113,14 +3140,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); @@ -3135,13 +3162,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 " @@ -3153,6 +3180,23 @@ static int get_cnt_traffic_mng_ccg_stats(struct dpa_stats_req_cb *req_cb, return 0; } +static int get_cnt_us_stats(struct dpa_stats_req_cb *req_cb, + struct dpa_stats_cnt_cb *cnt_cb) +{ + uint32_t i = 0, j = 0; + req_cb->config.cnts_ids[cnt_cb->id] = req_cb->bytes_num; + + for (i = 0; i < cnt_cb->members_num; i++) { + for (j = 0; j < cnt_cb->info.stats_num; j++) { + /* Write the memory location */ + *(uint32_t *)(req_cb->request_area) = 0; + /* Update the memory pointer */ + req_cb->request_area += STATS_VAL_SIZE; + } + } + return 0; +} + static void async_req_work_func(struct work_struct *work) { struct dpa_stats_req_cb *req_cb = NULL; @@ -3833,15 +3877,23 @@ int dpa_stats_get_counters(struct dpa_stats_cnt_request_params params, return err; } - /* Store user-provided request parameters */ - memcpy(req_cb->config.cnts_ids, - params.cnts_ids, params.cnts_ids_len * sizeof(int)); - + req_cb->config.cnts_ids = params.cnts_ids; req_cb->config.reset_cnts = params.reset_cnts; req_cb->config.storage_area_offset = params.storage_area_offset; req_cb->config.cnts_ids_len = params.cnts_ids_len; req_cb->request_done = request_done; + /* Copy user-provided array of counter ids */ + req_cb->cnts_ids = kzalloc(params.cnts_ids_len * sizeof(int), + GFP_KERNEL); + if (!req_cb->cnts_ids) { + log_err("Cannot allocate memory for internal DPA Stats request " + "structure\n"); + return -ENOMEM; + } + memcpy(req_cb->cnts_ids, params.cnts_ids, + params.cnts_ids_len * sizeof(int)); + /* Set memory area where the request should write */ req_cb->request_area = dpa_stats->config.storage_area + params.storage_area_offset; @@ -3910,7 +3962,7 @@ int dpa_stats_reset_counters(int *cnts_ids, unsigned int cnts_ids_len) /* Acquire counter lock */ err = mutex_trylock(&cnt_cb->lock); - if (err == 0) { + if (err != 0) { log_err("Counter id (cnt_ids[%d]) %d is in use\n", i, cnts_ids[i]); unblock_sched_cnts(dpa_stats, diff --git a/drivers/staging/fsl_dpa_offload/dpa_stats.h b/drivers/staging/fsl_dpa_offload/dpa_stats.h index 5843dca..3d682af 100644 --- a/drivers/staging/fsl_dpa_offload/dpa_stats.h +++ b/drivers/staging/fsl_dpa_offload/dpa_stats.h @@ -78,6 +78,7 @@ struct dpa_stats_req_cb { struct work_struct async_req_work; /* Asynchronous request work */ struct dpa_stats_cnt_request_params config; /* Parameters provided to the request */ + int *cnts_ids; /* Copy of user-provided array of counter IDs */ uint32_t id; /* Request id */ int index; /* Request index in the 'used_req_ids'*/ void *request_area; diff --git a/drivers/staging/fsl_dpa_offload/dpa_stats_ioctl.h b/drivers/staging/fsl_dpa_offload/dpa_stats_ioctl.h index d375a0f..a1bd323 100644 --- a/drivers/staging/fsl_dpa_offload/dpa_stats_ioctl.h +++ b/drivers/staging/fsl_dpa_offload/dpa_stats_ioctl.h @@ -240,11 +240,13 @@ struct compat_ioc_dpa_stats_cnts_reset_params { }; struct compat_dpa_stats_event_params { - int dpa_stats_id; - unsigned int storage_area_offset; - unsigned int cnts_written; - int bytes_written; - compat_uptr_t request_done; + int dpa_stats_id; + unsigned int storage_area_offset; + unsigned int cnts_written; + int bytes_written; + compat_uptr_t us_cnt_ids; + unsigned int cnt_ids_len; + compat_uptr_t request_done; }; #endif #define DPA_STATS_IOC_MAGIC 0xde diff --git a/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.c b/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.c index 0fdcdc5..0bacc91 100644 --- a/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.c +++ b/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.c @@ -98,7 +98,8 @@ static int copy_pair_descriptor(struct dpa_offload_lookup_key_pair *src, static int copy_class_members(void *objs, unsigned int size, void *dst); static long store_get_cnts_async_params( - struct ioc_dpa_stats_cnt_request_params *kprm); + struct ioc_dpa_stats_cnt_request_params *kprm, + struct dpa_stats_async_req_ev **async_request_event); #ifdef CONFIG_COMPAT static long wrp_dpa_stats_do_compat_ioctl(struct file *filp, @@ -289,6 +290,15 @@ ssize_t wrp_dpa_stats_read(struct file *file, ev_prm.dpa_stats_id = event->params.dpa_stats_id; ev_prm.storage_area_offset = event->params.storage_area_offset; ev_prm.request_done = ptr_to_compat(event->params.request_done); + ev_prm.us_cnt_ids = event->params.us_cnt_ids; + ev_prm.cnt_ids_len = event->params.cnt_ids_len; + + if (copy_to_user((compat_ptr)(ev_prm.us_cnt_ids), + event->ks_cnt_ids, + (event->params.cnt_ids_len * sizeof(int)))) { + kfree(event); + return -EFAULT; + } if (copy_to_user(buf + c, &ev_prm, sizeof(ev_prm)) != 0) { kfree(event); @@ -498,6 +508,15 @@ void do_ioctl_req_done_cb(int dpa_stats_id, event->params.cnts_written = cnts_written; event->params.bytes_written = bytes_written; event->params.request_done = async_req_ev->request_done; +#ifdef CONFIG_COMPAT + event->ks_cnt_ids = async_req_ev->ks_cnt_ids; + event->params.us_cnt_ids = async_req_ev->us_cnt_ids; + event->params.cnt_ids_len = async_req_ev->cnt_ids_len; +#else + event->ks_cnt_ids = NULL; + event->params.us_cnt_ids = NULL; + event->params.cnt_ids_len = 0; +#endif /* CONFIG_COMPAT */ mutex_unlock(&wrp_dpa_stats.async_req_lock); @@ -755,9 +774,10 @@ static int do_ioctl_stats_compat_create_counter(void *args) sizeof(struct dpa_stats_cnt_ipsec)); break; case DPA_STATS_CNT_TRAFFIC_MNG: - memcpy(&kprm.cnt_params.traffic_mng_params, - &uprm.cnt_params.traffic_mng_params, - sizeof(struct dpa_stats_cnt_traffic_mng)); + kprm.cnt_params.traffic_mng_params.cnt_sel = + uprm.cnt_params.traffic_mng_params.cnt_sel; + kprm.cnt_params.traffic_mng_params.src = + uprm.cnt_params.traffic_mng_params.src; break; default: break; @@ -1107,6 +1127,12 @@ static int do_ioctl_stats_compat_create_class_counter(void *args) if (ret < 0) return ret; break; + case DPA_STATS_CNT_TRAFFIC_MNG: + kprm_cls->traffic_mng_params.cnt_sel = + uprm_cls->traffic_mng_params.cnt_sel; + kprm_cls->traffic_mng_params.src = + uprm_cls->traffic_mng_params.src; + break; default: break; } @@ -1428,7 +1454,7 @@ static int do_ioctl_stats_get_counters(void *args) /* If counters request is asynchronous */ if (prm.request_done) { - ret = store_get_cnts_async_params(&prm); + ret = store_get_cnts_async_params(&prm, NULL); if (ret < 0) return ret; } @@ -1440,9 +1466,6 @@ static int do_ioctl_stats_get_counters(void *args) return ret; } - /* Request was sent, release the array of counter ids */ - kfree(prm.req_params.cnts_ids); - /* If request is synchronous copy counters length to user space */ if (!prm.request_done) { if (wrp_dpa_stats.k_mem) @@ -1462,6 +1485,9 @@ static int do_ioctl_stats_get_counters(void *args) } } + /* Request was sent, release the array of counter ids */ + kfree(prm.req_params.cnts_ids); + return ret; } @@ -1507,9 +1533,14 @@ static int do_ioctl_stats_compat_get_counters(void *args) /* If counters request is asynchronous */ if (kprm.request_done) { - ret = store_get_cnts_async_params(&kprm); + struct dpa_stats_async_req_ev *async_request_ev = NULL; + + ret = store_get_cnts_async_params(&kprm, &async_request_ev); if (ret < 0) return ret; + /* Store user-space pointer to array of ids */ + async_request_ev->us_cnt_ids = uprm.req_params.cnts_ids; + async_request_ev->cnt_ids_len = uprm.req_params.cnts_ids_len; } ret = dpa_stats_get_counters(kprm.req_params, @@ -1519,9 +1550,6 @@ static int do_ioctl_stats_compat_get_counters(void *args) return ret; } - /* Request was sent, release the array of counter ids */ - kfree(kprm.req_params.cnts_ids); - /* If request is synchronous copy counters length to user space */ if (!kprm.request_done) { if (wrp_dpa_stats.k_mem) @@ -1532,16 +1560,28 @@ static int do_ioctl_stats_compat_get_counters(void *args) kprm.cnts_len)) { log_err("Cannot copy counter values to storage " "area\n"); + kfree(kprm.req_params.cnts_ids); return -EINVAL; } uprm.cnts_len = kprm.cnts_len; + if (copy_to_user((compat_ptr)(uprm.req_params.cnts_ids), + kprm.req_params.cnts_ids, + (kprm.req_params.cnts_ids_len * sizeof(int)))) { + log_err("Cannot copy to user the array of requested " + "counter ids\n"); + kfree(kprm.req_params.cnts_ids); + return -EINVAL; + } + if (copy_to_user(args, &uprm, sizeof(uprm))) { log_err("Cannot copy to user the counter parameters\n"); ret = -EINVAL; } } + /* Request was sent, release the array of counter ids */ + kfree(kprm.req_params.cnts_ids); return ret; } @@ -1807,7 +1847,8 @@ static long wrp_dpa_stats_do_compat_ioctl(struct file *filp, #endif static long store_get_cnts_async_params( - struct ioc_dpa_stats_cnt_request_params *kprm) + struct ioc_dpa_stats_cnt_request_params *kprm, + struct dpa_stats_async_req_ev **async_request_event) { struct dpa_stats_async_req_ev *async_req_ev; struct list_head *async_req_grp; @@ -1835,11 +1876,17 @@ static long store_get_cnts_async_params( async_req_ev->request_done = kprm->request_done; async_req_ev->storage_area_offset = kprm->req_params.storage_area_offset; + + async_req_ev->ks_cnt_ids = kprm->req_params.cnts_ids; list_add_tail(&async_req_ev->node, async_req_grp); mutex_unlock(&wrp_dpa_stats.async_req_lock); /* Replace the application callback with wrapper function */ kprm->request_done = do_ioctl_req_done_cb; + + /* If calling function requested, return the pointer to async_req_ev */ + if (async_request_event) + *async_request_event = async_req_ev; return 0; } diff --git a/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.h b/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.h index ef91344..506b02c 100644 --- a/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.h +++ b/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.h @@ -36,6 +36,7 @@ /* Other includes */ #include "linux/fs.h" #include +#include #define DPA_STATS_CDEV "dpa_stats" @@ -61,11 +62,17 @@ long wrp_dpa_stats_compat_ioctl(struct file *filp, unsigned int cmd, #define QUEUE_MAX_EVENTS 2048 struct dpa_stats_event_params { - int dpa_stats_id; - unsigned int storage_area_offset; - unsigned int cnts_written; - int bytes_written; - dpa_stats_request_cb request_done; + int dpa_stats_id; + unsigned int storage_area_offset; + unsigned int cnts_written; + int bytes_written; +#ifdef CONFIG_COMPAT + compat_uptr_t us_cnt_ids; +#else + int *us_cnt_ids; +#endif /* CONFIG_COMPAT */ + unsigned int cnt_ids_len; + dpa_stats_request_cb request_done; }; struct dpa_stats_event_queue { @@ -77,6 +84,7 @@ struct dpa_stats_event_queue { struct dpa_stats_event { struct dpa_stats_event_params params; /* Event data */ struct list_head lh; /* Event queue list head */ + int *ks_cnt_ids; /* Request array of counter ids from kernel-space */ }; struct dpa_stats_async_req_ev { @@ -84,6 +92,11 @@ struct dpa_stats_async_req_ev { unsigned int storage_area_offset; /* Storage offset for this request */ /* Pointers to other async requests in the current set */ struct list_head node; +#ifdef CONFIG_COMPAT + compat_uptr_t us_cnt_ids; /* Request array of counter ids from US */ +#endif /* CONFIG COMPAT */ + int *ks_cnt_ids; /* Request array of counter ids from KS */ + unsigned int cnt_ids_len; /* Number of counter ids in array */ }; struct wrp_dpa_stats_cb { diff --git a/include/linux/fsl_dpa_stats.h b/include/linux/fsl_dpa_stats.h index b8fe850..5ba731e 100644 --- a/include/linux/fsl_dpa_stats.h +++ b/include/linux/fsl_dpa_stats.h @@ -469,7 +469,7 @@ struct dpa_stats_cnt_traffic_mng { enum dpa_stats_cnt_traffic_mng_src src; /* - * Depending on the Traffic Manager source, the 'traffic_obj' has a + * Depending on the Traffic Manager source, the 'traffic_mng' has a * different meaning: it represents a pointer to a structure of type * 'qm_ceetm_cq' in case the traffic source is a "Class Queue" or a * pointer to a structure of type 'qm_ceetm_ccg' in case the traffic @@ -690,7 +690,7 @@ struct dpa_stats_cls_cnt_traffic_mng { enum dpa_stats_cnt_traffic_mng_src src; /* - * Depending on the Traffic Manager source, the 'traffic_obj' has a + * Depending on the Traffic Manager source, the 'traffic_mng' has a * different meaning: it represents an array of pointers to structures * of type 'qm_ceetm_cq' in case the traffic source is a "Class Queue" * or an array of pointers to structures of type 'qm_ceetm_ccg' in case -- cgit v0.10.2 From 3f2f5c5fa5ae9a281f699bfdb090da5477a9f6cd Mon Sep 17 00:00:00 2001 From: Shruti Kanetkar Date: Wed, 21 Aug 2013 11:54:44 -0500 Subject: dpaa_eth/mac: Sync with the unique MDIO bus name for "fixed-link" PHY(s) '9e6c643 phy/fixed: use an unique MDIO bus name' changed the name of the fixed PHY bus to "fixed-0". This update has been already done for the non-dpaa SoC(s) in 'e5c7d1f of/mdio: fix fixed link bus name' Signed-off-by: Shruti Kanetkar Change-Id: Ie2ead771bc74a2b62c26eca6b5618bdebbe1eb61 Reviewed-on: http://git.am.freescale.net:8181/4129 Tested-by: Review Code-CDREVIEW Reviewed-by: Hamciuc Bogdan-BHAMCIU1 Reviewed-by: Rivera Jose-B46482 diff --git a/drivers/net/ethernet/freescale/dpa/mac.c b/drivers/net/ethernet/freescale/dpa/mac.c index 87739e9..9a18804 100644 --- a/drivers/net/ethernet/freescale/dpa/mac.c +++ b/drivers/net/ethernet/freescale/dpa/mac.c @@ -353,7 +353,7 @@ static int __cold mac_probe(struct platform_device *_of_dev) goto _return_dev_set_drvdata; } - sprintf(mac_dev->fixed_bus_id, PHY_ID_FMT, "0", phy_id[0]); + sprintf(mac_dev->fixed_bus_id, PHY_ID_FMT, "fixed-0", phy_id[0]); } _errno = mac_dev->init(mac_dev); -- cgit v0.10.2 From 85be729de02043e1c936c2c1426fb93ce6cba734 Mon Sep 17 00:00:00 2001 From: Haiying Wang Date: Fri, 16 Aug 2013 14:17:44 -0400 Subject: fsl_qman: fix the incorrect return for xsfdr read in debugfs and fix the mask value for correctly getting the XSFDR value. Signed-off-by: Haiying Wang Change-Id: I72ba857bd01b93ca6042e354c7ca8c391f430e83 Reviewed-on: http://git.am.freescale.net:8181/4059 Reviewed-by: Thorpe Geoff-R01361 Tested-by: Review Code-CDREVIEW Reviewed-by: Rivera Jose-B46482 diff --git a/drivers/staging/fsl_qbman/qman_debugfs.c b/drivers/staging/fsl_qbman/qman_debugfs.c index 6b4dc046..ede3d40 100644 --- a/drivers/staging/fsl_qbman/qman_debugfs.c +++ b/drivers/staging/fsl_qbman/qman_debugfs.c @@ -1387,7 +1387,7 @@ static int query_ceetm_xsfdr_show(struct seq_file *file, void *offset) enum qm_dc_portal portal; - if ((qman_ip_rev & 0xFF00) < QMAN_REV31) + if (qman_ip_rev < QMAN_REV31) return -EINVAL; portal = query_ceetm_xsfdr_data.dcp_portal; @@ -1399,7 +1399,7 @@ static int query_ceetm_xsfdr_show(struct seq_file *file, void *offset) } seq_printf(file, "DCP%d: CEETM_XSFDR_IN_USE number is %u\n", portal, - (xsfdr_in_use & 0x1FF)); + (xsfdr_in_use & 0x1FFF)); return 0; } -- cgit v0.10.2 From 2b4c43eb8a35cf889c12b3ee13e7954385b273cf Mon Sep 17 00:00:00 2001 From: Mandy Lavi Date: Wed, 21 Aug 2013 10:00:04 +0300 Subject: fmd: fix muram size for b4860rev2 Signed-off-by: Mandy Lavi Change-Id: Id1be0b2511e5c36fd785f8ee72f4189305c7ac71 Reviewed-on: http://git.am.freescale.net:8181/4105 Reviewed-by: Bucur Madalin-Cristian-B32716 Tested-by: Review Code-CDREVIEW Reviewed-by: Rivera Jose-B46482 diff --git a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.c b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.c index eadb36f..7a56ec0 100644 --- a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.c +++ b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.c @@ -457,6 +457,12 @@ static const struct qe_firmware *FindFmanMicrocode(void) /* Returning NULL here forces the reuse of the IRAM content */ return NULL; } +#define SVR_SECURITY_MASK 0x00080000 +#define SVR_PERSONALITY_MASK 0x0000FF00 +#define SVR_VER_IGNORE_MASK (SVR_SECURITY_MASK | SVR_PERSONALITY_MASK) +#define SVR_B4860_REV1_VALUE 0x86800010 +#define SVR_B4860_REV2_VALUE 0x86800020 + static t_LnxWrpFmDev * ReadFmDevTreeNode (struct platform_device *of_dev) { @@ -512,6 +518,17 @@ static t_LnxWrpFmDev * ReadFmDevTreeNode (struct platform_device *of_dev) return NULL; } + { + uint32_t svr; + + svr = mfspr(SPRN_SVR); + + if ((svr & ~SVR_VER_IGNORE_MASK) == SVR_B4860_REV2_VALUE) { + res.end = 0x80000; + res.start = 0; + } + } + p_LnxWrpFmDev->fmBaseAddr = 0; p_LnxWrpFmDev->fmPhysBaseAddr = res.start; p_LnxWrpFmDev->fmMemSize = res.end + 1 - res.start; -- cgit v0.10.2 From 929fcea7a3b5fc0a5a03720655fdb6cd40d69d92 Mon Sep 17 00:00:00 2001 From: Marian Chereji Date: Tue, 27 Aug 2013 17:35:28 +0300 Subject: dpa_offload: Reduce the size of the IPv4 header options field According to RFC 791, the size of the IPv4 header (options included) is represented on 4 bits (IHL), hence it can be an absolute maximum of 15 * 4 = 60 bytes. The IPv4 options buffer size field in the fsl_dpa_offload.h header file, in the ipv4_header data structure, was declared as an "unsigned int" and this was causing a static analysis warning in dpa_classifier. The field was reduced to uint8_t which is more than enough to store the size of the IPv4 frame options. Signed-off-by: Marian Chereji Change-Id: I69fb1307329b68da652ed85d659aa10e34c5af67 Reviewed-on: http://git.am.freescale.net:8181/4264 Tested-by: Review Code-CDREVIEW Reviewed-by: Bulie Radu-Andrei-B37577 Reviewed-by: Rivera Jose-B46482 diff --git a/include/linux/fsl_dpa_offload.h b/include/linux/fsl_dpa_offload.h index c85c4c6..b5f4e6e 100644 --- a/include/linux/fsl_dpa_offload.h +++ b/include/linux/fsl_dpa_offload.h @@ -162,7 +162,7 @@ struct ipv4_header { uint8_t *options; /* Size of IPv4 options buffer. Zero for no options. */ - unsigned int options_size; + uint8_t options_size; }; /* Description of the VLAN header */ -- cgit v0.10.2 From 1d6fb60b71a6c8f99ec9e24275718f07c101fc37 Mon Sep 17 00:00:00 2001 From: Rivera Jose-B46482 Date: Thu, 29 Aug 2013 19:14:49 -0500 Subject: Revert "dpa_offload: Added Traffic Manager user-space counter implementation" This reverts commit 658fb7c23113780e96ac8fc2503a058d49377281 This change has a bug related to misuse of the mutex_trylock() API (see line 3965) and causes non-obvious merge conflicts when merging to sdk-v1.4.x. Please rework this patch to ensure these issues are solved. Change-Id: If6be2d7fc98e3b3f0689b8c8abd241216adfd2f9 Reviewed-on: http://git.am.freescale.net:8181/4327 Tested-by: Review Code-CDREVIEW Reviewed-by: Rivera Jose-B46482 diff --git a/drivers/staging/fsl_dpa_offload/dpa_stats.c b/drivers/staging/fsl_dpa_offload/dpa_stats.c index be9b0d5..f82fcc3 100644 --- a/drivers/staging/fsl_dpa_offload/dpa_stats.c +++ b/drivers/staging/fsl_dpa_offload/dpa_stats.c @@ -51,8 +51,6 @@ #define CLASSIF_STATS_SHIFT 4 #define WORKQUEUE_MAX_ACTIVE 3 -#define DPA_STATS_US_CNT 0x80000000 - /* Global dpa_stats component */ struct dpa_stats *gbl_dpa_stats; @@ -83,9 +81,6 @@ static int get_cnt_traffic_mng_cq_stats(struct dpa_stats_req_cb *req_cb, static int get_cnt_traffic_mng_ccg_stats(struct dpa_stats_req_cb *req_cb, struct dpa_stats_cnt_cb *cnt_cb); -static int get_cnt_us_stats(struct dpa_stats_req_cb *req_cb, - struct dpa_stats_cnt_cb *cnt_cb); - static void async_req_work_func(struct work_struct *work); /* check that the provided params are valid */ @@ -730,18 +725,11 @@ static int treat_cnts_request(struct dpa_stats *dpa_stats, { struct dpa_stats_cnt_request_params params = req_cb->config; struct dpa_stats_cnt_cb *cnt_cb = NULL; - int id = 0, err = 0, *unblock_cnts; + int id = 0, err = 0; uint32_t i = 0; - unblock_cnts = kzalloc(sizeof(int) * params.cnts_ids_len, GFP_KERNEL); - if (!unblock_cnts) { - log_err("Cannot allocate memory for local counter ids array\n"); - return -ENOMEM; - } - for (i = 0; i < params.cnts_ids_len; i++) { id = params.cnts_ids[i]; - unblock_cnts[i] = id; /* Get counter's control block */ cnt_cb = &dpa_stats->cnts_cb[id]; @@ -772,7 +760,7 @@ static int treat_cnts_request(struct dpa_stats *dpa_stats, mutex_unlock(&cnt_cb->lock); } - unblock_sched_cnts(dpa_stats, unblock_cnts, params.cnts_ids_len); + unblock_sched_cnts(dpa_stats, params.cnts_ids, params.cnts_ids_len); return 0; } @@ -1066,10 +1054,10 @@ static void create_cnt_traffic_mng_stats(struct dpa_stats *dpa_stats) { /* DPA_STATS_CNT_NUM_OF_BYTES */ dpa_stats->stats_sel[DPA_STATS_CNT_TRAFFIC_MNG][0] = - DPA_STATS_CNT_NUM_OF_BYTES * sizeof(uint64_t); + DPA_STATS_CNT_NUM_OF_BYTES; /* DPA_STATS_CNT_NUM_OF_PACKETS */ dpa_stats->stats_sel[DPA_STATS_CNT_TRAFFIC_MNG][1] = - DPA_STATS_CNT_NUM_OF_PACKETS * sizeof(uint64_t); + DPA_STATS_CNT_NUM_OF_PACKETS; } static int copy_key_descriptor(const struct dpa_offload_lookup_key *src, @@ -1229,39 +1217,6 @@ static void cnt_sel_to_stats(struct stats_info *stats_info, stats_info->stats_num = cntPos - 1; } -static int cnt_gen_sel_to_stats(struct dpa_stats_cnt_cb *cnt_cb, - enum dpa_stats_cnt_sel cnt_sel) -{ - struct dpa_stats *dpa_stats = cnt_cb->dpa_stats; - - if (cnt_sel == DPA_STATS_CNT_NUM_OF_BYTES) { - cnt_cb->info.stats_off[0] = - dpa_stats->stats_sel[cnt_cb->type][DPA_STATS_CNT_NUM_OF_BYTES]; - cnt_cb->info.stats_num = 1; - } else if (cnt_sel == DPA_STATS_CNT_NUM_OF_PACKETS) { - cnt_cb->info.stats_off[0] = - dpa_stats->stats_sel[cnt_cb->type][DPA_STATS_CNT_NUM_OF_PACKETS]; - cnt_cb->info.stats_num = 1; - } else if (cnt_sel == DPA_STATS_CNT_NUM_ALL) { - cnt_cb->info.stats_off[0] = - dpa_stats->stats_sel[cnt_cb->type][DPA_STATS_CNT_NUM_OF_BYTES]; - cnt_cb->info.stats_off[1] = - dpa_stats->stats_sel[cnt_cb->type][DPA_STATS_CNT_NUM_OF_PACKETS]; - cnt_cb->info.stats_num = 2; - } else { - 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; - } - - /* Set number of bytes that will be written by this counter */ - cnt_cb->bytes_num = cnt_cb->members_num * - STATS_VAL_SIZE * cnt_cb->info.stats_num; - - return 0; -} - static int set_frag_manip(int td, struct dpa_stats_lookup_key *entry) { struct dpa_cls_tbl_action action; @@ -1710,14 +1665,37 @@ static int set_cnt_ccnode_cb(struct dpa_stats_cnt_cb *cnt_cb, static int set_cnt_ipsec_cb(struct dpa_stats_cnt_cb *cnt_cb, const struct dpa_stats_cnt_params *params) { + struct dpa_stats *dpa_stats = cnt_cb->dpa_stats; struct dpa_ipsec_sa_stats stats; + uint32_t cnt_sel = params->ipsec_params.cnt_sel; int err = 0; - if (!cnt_cb->dpa_stats) { + if (!dpa_stats) { log_err("DPA Stats component is not initialized\n"); return -EFAULT; } + /* Map IPSec counter selection to statistics */ + if (cnt_sel == DPA_STATS_CNT_NUM_OF_BYTES) { + cnt_cb->info.stats_off[0] = dpa_stats->stats_sel[ + DPA_STATS_CNT_IPSEC][DPA_STATS_CNT_NUM_OF_BYTES]; + cnt_cb->info.stats_num = 1; + } else if (cnt_sel == DPA_STATS_CNT_NUM_OF_PACKETS) { + cnt_cb->info.stats_off[0] = dpa_stats->stats_sel[ + DPA_STATS_CNT_IPSEC][DPA_STATS_CNT_NUM_OF_PACKETS]; + cnt_cb->info.stats_num = 1; + } else if (cnt_sel == DPA_STATS_CNT_NUM_ALL) { + cnt_cb->info.stats_off[0] = dpa_stats->stats_sel[ + DPA_STATS_CNT_IPSEC][DPA_STATS_CNT_NUM_OF_BYTES]; + cnt_cb->info.stats_off[1] = dpa_stats->stats_sel[ + DPA_STATS_CNT_IPSEC][DPA_STATS_CNT_NUM_OF_PACKETS]; + cnt_cb->info.stats_num = 2; + } else { + 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->ipsec_cb.sa_id[0] = params->ipsec_params.sa_id; cnt_cb->ipsec_cb.valid[0] = TRUE; @@ -1731,10 +1709,8 @@ static int set_cnt_ipsec_cb(struct dpa_stats_cnt_cb *cnt_cb, return -EINVAL; } - /* Map IPSec counter selection to statistics */ - err = cnt_gen_sel_to_stats(cnt_cb, params->ipsec_params.cnt_sel); - if (err < 0) - return err; + /* Set number of bytes that will be written by this counter */ + cnt_cb->bytes_num = STATS_VAL_SIZE * cnt_cb->info.stats_num; return 0; } @@ -1745,48 +1721,29 @@ 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; - u64 frames = 0, bytes = 0; + uint64_t frames, bytes; int err = 0; - bool us_cnt = FALSE; if (!dpa_stats) { log_err("DPA Stats component is not initialized\n"); return -EFAULT; } - /* Check if this is an users-space counter and if so, reset the flag */ - if (cnt_sel & DPA_STATS_US_CNT) { - us_cnt = TRUE; - cnt_sel &= ~DPA_STATS_US_CNT; + if (!params->traffic_mng_params.traffic_mng) { + log_err("Parameter traffic_mng handle cannot be NULL\n"); + return -EFAULT; } - if (!params->traffic_mng_params.traffic_mng && !us_cnt) { - log_err("Parameter traffic_mng handle cannot be NULL for " - "counter id %d\n", cnt_cb->id); + 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); return -EINVAL; } - /* Check and store the counter source */ - 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; - } cnt_cb->gen_cb.objs[0] = params->traffic_mng_params.traffic_mng; cnt_cb->members_num = 1; - /* Map Traffic Manager counter selection to statistics */ - err = cnt_gen_sel_to_stats(cnt_cb, cnt_sel); - if (err < 0) - return err; - - /* For user-space counters there is a different retrieve function */ - if (us_cnt) { - cnt_cb->f_get_cnt_stats = get_cnt_us_stats; - return 0; - } - /* Check the counter source and the Traffic Manager object */ switch (cnt_src) { case DPA_STATS_CNT_TRAFFIC_CLASS: @@ -1811,8 +1768,23 @@ static int set_cnt_traffic_mng_cb(struct dpa_stats_cnt_cb *cnt_cb, return -EINVAL; } 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 */ + 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); + + /* Set number of bytes that will be written by this counter */ + cnt_cb->bytes_num = STATS_VAL_SIZE * cnt_cb->info.stats_num; + return 0; } @@ -2458,85 +2430,86 @@ static int set_cls_cnt_ipsec_cb(struct dpa_stats_cnt_cb *cnt_cb, static int set_cls_cnt_traffic_mng_cb(struct dpa_stats_cnt_cb *cnt_cb, const struct dpa_stats_cls_cnt_params *params) { - struct dpa_stats_cls_cnt_traffic_mng prm = params->traffic_mng_params; - uint32_t cnt_sel = prm.cnt_sel, i; - u64 frames = 0, bytes = 0; + 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; + uint32_t i = 0; + uint64_t frames, bytes; int err = 0; - bool us_cnt = FALSE; - if (!cnt_cb->dpa_stats) { + if (!dpa_stats) { log_err("DPA Stats component is not initialized\n"); return -EFAULT; } - /* Check if this is an users-space counter and if so, reset the flag */ - if (cnt_sel & DPA_STATS_US_CNT) { - us_cnt = TRUE; - cnt_sel &= ~DPA_STATS_US_CNT; + /* 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; } - cnt_cb->members_num = params->class_members; - - /* Map Traffic Manager counter selection to statistics */ - err = cnt_gen_sel_to_stats(cnt_cb, cnt_sel); - if (err < 0) - return err; - - /* For user-space counters there is a different retrieve function */ - if (us_cnt) { - cnt_cb->f_get_cnt_stats = get_cnt_us_stats; - return 0; + /* 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); + return -EINVAL; } - /* Check the counter source and the Traffic Manager object */ - switch (prm.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 (!prm.traffic_mng[i]) { - log_err("Parameter traffic_mng handle cannot " - "be NULL for member %d\n", i); - return -EFAULT; - } + cnt_cb->members_num = params->class_members; - /* Check the provided Traffic Manager object */ + /* 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] = + 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; err = qman_ceetm_cq_get_dequeue_statistics( - prm.traffic_mng[i], 0, &frames, &bytes); + params->traffic_mng_params.traffic_mng[i], 0, + &frames, &bytes); if (err < 0) { - log_err("Invalid traffic_mng handle 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; } - cnt_cb->gen_cb.objs[i] = prm.traffic_mng[i]; - } - 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 (!prm.traffic_mng[i]) { - log_err("Parameter traffic_mng handle cannot" - "be NULL for member %d\n", i); - return -EFAULT; - } - - /* Check the provided Traffic Manager object */ + break; + case DPA_STATS_CNT_TRAFFIC_CG: + cnt_cb->f_get_cnt_stats = get_cnt_traffic_mng_ccg_stats; err = qman_ceetm_ccg_get_reject_statistics( - prm.traffic_mng[i], 0, &frames, &bytes); + params->traffic_mng_params.traffic_mng[i], 0, + &frames, &bytes); if (err < 0) { - log_err("Invalid traffic_mng handle for counter" - " id %d\n", cnt_cb->id); + log_err("Invalid Traffic Manager qm_ceetm_ccg " + "object for counter id %d\n", + cnt_cb->id); return -EINVAL; } - cnt_cb->gen_cb.objs[i] = prm.traffic_mng[i]; + break; } - break; - default: - log_err("Parameter src %d must be in range (%d - %d) for " - "counter id %d\n", prm.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 */ + 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); + + /* Set number of bytes that will be written by this counter */ + cnt_cb->bytes_num = cnt_cb->members_num * + STATS_VAL_SIZE * cnt_cb->info.stats_num; + return 0; } @@ -3140,14 +3113,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; - u64 stats_val[2]; + uint64_t 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); @@ -3162,13 +3135,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; - u64 stats_val[2]; + uint64_t 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 " @@ -3180,23 +3153,6 @@ static int get_cnt_traffic_mng_ccg_stats(struct dpa_stats_req_cb *req_cb, return 0; } -static int get_cnt_us_stats(struct dpa_stats_req_cb *req_cb, - struct dpa_stats_cnt_cb *cnt_cb) -{ - uint32_t i = 0, j = 0; - req_cb->config.cnts_ids[cnt_cb->id] = req_cb->bytes_num; - - for (i = 0; i < cnt_cb->members_num; i++) { - for (j = 0; j < cnt_cb->info.stats_num; j++) { - /* Write the memory location */ - *(uint32_t *)(req_cb->request_area) = 0; - /* Update the memory pointer */ - req_cb->request_area += STATS_VAL_SIZE; - } - } - return 0; -} - static void async_req_work_func(struct work_struct *work) { struct dpa_stats_req_cb *req_cb = NULL; @@ -3877,23 +3833,15 @@ int dpa_stats_get_counters(struct dpa_stats_cnt_request_params params, return err; } - req_cb->config.cnts_ids = params.cnts_ids; + /* Store user-provided request parameters */ + memcpy(req_cb->config.cnts_ids, + params.cnts_ids, params.cnts_ids_len * sizeof(int)); + req_cb->config.reset_cnts = params.reset_cnts; req_cb->config.storage_area_offset = params.storage_area_offset; req_cb->config.cnts_ids_len = params.cnts_ids_len; req_cb->request_done = request_done; - /* Copy user-provided array of counter ids */ - req_cb->cnts_ids = kzalloc(params.cnts_ids_len * sizeof(int), - GFP_KERNEL); - if (!req_cb->cnts_ids) { - log_err("Cannot allocate memory for internal DPA Stats request " - "structure\n"); - return -ENOMEM; - } - memcpy(req_cb->cnts_ids, params.cnts_ids, - params.cnts_ids_len * sizeof(int)); - /* Set memory area where the request should write */ req_cb->request_area = dpa_stats->config.storage_area + params.storage_area_offset; @@ -3962,7 +3910,7 @@ int dpa_stats_reset_counters(int *cnts_ids, unsigned int cnts_ids_len) /* Acquire counter lock */ err = mutex_trylock(&cnt_cb->lock); - if (err != 0) { + if (err == 0) { log_err("Counter id (cnt_ids[%d]) %d is in use\n", i, cnts_ids[i]); unblock_sched_cnts(dpa_stats, diff --git a/drivers/staging/fsl_dpa_offload/dpa_stats.h b/drivers/staging/fsl_dpa_offload/dpa_stats.h index 3d682af..5843dca 100644 --- a/drivers/staging/fsl_dpa_offload/dpa_stats.h +++ b/drivers/staging/fsl_dpa_offload/dpa_stats.h @@ -78,7 +78,6 @@ struct dpa_stats_req_cb { struct work_struct async_req_work; /* Asynchronous request work */ struct dpa_stats_cnt_request_params config; /* Parameters provided to the request */ - int *cnts_ids; /* Copy of user-provided array of counter IDs */ uint32_t id; /* Request id */ int index; /* Request index in the 'used_req_ids'*/ void *request_area; diff --git a/drivers/staging/fsl_dpa_offload/dpa_stats_ioctl.h b/drivers/staging/fsl_dpa_offload/dpa_stats_ioctl.h index a1bd323..d375a0f 100644 --- a/drivers/staging/fsl_dpa_offload/dpa_stats_ioctl.h +++ b/drivers/staging/fsl_dpa_offload/dpa_stats_ioctl.h @@ -240,13 +240,11 @@ struct compat_ioc_dpa_stats_cnts_reset_params { }; struct compat_dpa_stats_event_params { - int dpa_stats_id; - unsigned int storage_area_offset; - unsigned int cnts_written; - int bytes_written; - compat_uptr_t us_cnt_ids; - unsigned int cnt_ids_len; - compat_uptr_t request_done; + int dpa_stats_id; + unsigned int storage_area_offset; + unsigned int cnts_written; + int bytes_written; + compat_uptr_t request_done; }; #endif #define DPA_STATS_IOC_MAGIC 0xde diff --git a/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.c b/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.c index 0bacc91..0fdcdc5 100644 --- a/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.c +++ b/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.c @@ -98,8 +98,7 @@ static int copy_pair_descriptor(struct dpa_offload_lookup_key_pair *src, static int copy_class_members(void *objs, unsigned int size, void *dst); static long store_get_cnts_async_params( - struct ioc_dpa_stats_cnt_request_params *kprm, - struct dpa_stats_async_req_ev **async_request_event); + struct ioc_dpa_stats_cnt_request_params *kprm); #ifdef CONFIG_COMPAT static long wrp_dpa_stats_do_compat_ioctl(struct file *filp, @@ -290,15 +289,6 @@ ssize_t wrp_dpa_stats_read(struct file *file, ev_prm.dpa_stats_id = event->params.dpa_stats_id; ev_prm.storage_area_offset = event->params.storage_area_offset; ev_prm.request_done = ptr_to_compat(event->params.request_done); - ev_prm.us_cnt_ids = event->params.us_cnt_ids; - ev_prm.cnt_ids_len = event->params.cnt_ids_len; - - if (copy_to_user((compat_ptr)(ev_prm.us_cnt_ids), - event->ks_cnt_ids, - (event->params.cnt_ids_len * sizeof(int)))) { - kfree(event); - return -EFAULT; - } if (copy_to_user(buf + c, &ev_prm, sizeof(ev_prm)) != 0) { kfree(event); @@ -508,15 +498,6 @@ void do_ioctl_req_done_cb(int dpa_stats_id, event->params.cnts_written = cnts_written; event->params.bytes_written = bytes_written; event->params.request_done = async_req_ev->request_done; -#ifdef CONFIG_COMPAT - event->ks_cnt_ids = async_req_ev->ks_cnt_ids; - event->params.us_cnt_ids = async_req_ev->us_cnt_ids; - event->params.cnt_ids_len = async_req_ev->cnt_ids_len; -#else - event->ks_cnt_ids = NULL; - event->params.us_cnt_ids = NULL; - event->params.cnt_ids_len = 0; -#endif /* CONFIG_COMPAT */ mutex_unlock(&wrp_dpa_stats.async_req_lock); @@ -774,10 +755,9 @@ static int do_ioctl_stats_compat_create_counter(void *args) sizeof(struct dpa_stats_cnt_ipsec)); break; case DPA_STATS_CNT_TRAFFIC_MNG: - kprm.cnt_params.traffic_mng_params.cnt_sel = - uprm.cnt_params.traffic_mng_params.cnt_sel; - kprm.cnt_params.traffic_mng_params.src = - uprm.cnt_params.traffic_mng_params.src; + memcpy(&kprm.cnt_params.traffic_mng_params, + &uprm.cnt_params.traffic_mng_params, + sizeof(struct dpa_stats_cnt_traffic_mng)); break; default: break; @@ -1127,12 +1107,6 @@ static int do_ioctl_stats_compat_create_class_counter(void *args) if (ret < 0) return ret; break; - case DPA_STATS_CNT_TRAFFIC_MNG: - kprm_cls->traffic_mng_params.cnt_sel = - uprm_cls->traffic_mng_params.cnt_sel; - kprm_cls->traffic_mng_params.src = - uprm_cls->traffic_mng_params.src; - break; default: break; } @@ -1454,7 +1428,7 @@ static int do_ioctl_stats_get_counters(void *args) /* If counters request is asynchronous */ if (prm.request_done) { - ret = store_get_cnts_async_params(&prm, NULL); + ret = store_get_cnts_async_params(&prm); if (ret < 0) return ret; } @@ -1466,6 +1440,9 @@ static int do_ioctl_stats_get_counters(void *args) return ret; } + /* Request was sent, release the array of counter ids */ + kfree(prm.req_params.cnts_ids); + /* If request is synchronous copy counters length to user space */ if (!prm.request_done) { if (wrp_dpa_stats.k_mem) @@ -1485,9 +1462,6 @@ static int do_ioctl_stats_get_counters(void *args) } } - /* Request was sent, release the array of counter ids */ - kfree(prm.req_params.cnts_ids); - return ret; } @@ -1533,14 +1507,9 @@ static int do_ioctl_stats_compat_get_counters(void *args) /* If counters request is asynchronous */ if (kprm.request_done) { - struct dpa_stats_async_req_ev *async_request_ev = NULL; - - ret = store_get_cnts_async_params(&kprm, &async_request_ev); + ret = store_get_cnts_async_params(&kprm); if (ret < 0) return ret; - /* Store user-space pointer to array of ids */ - async_request_ev->us_cnt_ids = uprm.req_params.cnts_ids; - async_request_ev->cnt_ids_len = uprm.req_params.cnts_ids_len; } ret = dpa_stats_get_counters(kprm.req_params, @@ -1550,6 +1519,9 @@ static int do_ioctl_stats_compat_get_counters(void *args) return ret; } + /* Request was sent, release the array of counter ids */ + kfree(kprm.req_params.cnts_ids); + /* If request is synchronous copy counters length to user space */ if (!kprm.request_done) { if (wrp_dpa_stats.k_mem) @@ -1560,28 +1532,16 @@ static int do_ioctl_stats_compat_get_counters(void *args) kprm.cnts_len)) { log_err("Cannot copy counter values to storage " "area\n"); - kfree(kprm.req_params.cnts_ids); return -EINVAL; } uprm.cnts_len = kprm.cnts_len; - if (copy_to_user((compat_ptr)(uprm.req_params.cnts_ids), - kprm.req_params.cnts_ids, - (kprm.req_params.cnts_ids_len * sizeof(int)))) { - log_err("Cannot copy to user the array of requested " - "counter ids\n"); - kfree(kprm.req_params.cnts_ids); - return -EINVAL; - } - if (copy_to_user(args, &uprm, sizeof(uprm))) { log_err("Cannot copy to user the counter parameters\n"); ret = -EINVAL; } } - /* Request was sent, release the array of counter ids */ - kfree(kprm.req_params.cnts_ids); return ret; } @@ -1847,8 +1807,7 @@ static long wrp_dpa_stats_do_compat_ioctl(struct file *filp, #endif static long store_get_cnts_async_params( - struct ioc_dpa_stats_cnt_request_params *kprm, - struct dpa_stats_async_req_ev **async_request_event) + struct ioc_dpa_stats_cnt_request_params *kprm) { struct dpa_stats_async_req_ev *async_req_ev; struct list_head *async_req_grp; @@ -1876,17 +1835,11 @@ static long store_get_cnts_async_params( async_req_ev->request_done = kprm->request_done; async_req_ev->storage_area_offset = kprm->req_params.storage_area_offset; - - async_req_ev->ks_cnt_ids = kprm->req_params.cnts_ids; list_add_tail(&async_req_ev->node, async_req_grp); mutex_unlock(&wrp_dpa_stats.async_req_lock); /* Replace the application callback with wrapper function */ kprm->request_done = do_ioctl_req_done_cb; - - /* If calling function requested, return the pointer to async_req_ev */ - if (async_request_event) - *async_request_event = async_req_ev; return 0; } diff --git a/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.h b/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.h index 506b02c..ef91344 100644 --- a/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.h +++ b/drivers/staging/fsl_dpa_offload/wrp_dpa_stats.h @@ -36,7 +36,6 @@ /* Other includes */ #include "linux/fs.h" #include -#include #define DPA_STATS_CDEV "dpa_stats" @@ -62,17 +61,11 @@ long wrp_dpa_stats_compat_ioctl(struct file *filp, unsigned int cmd, #define QUEUE_MAX_EVENTS 2048 struct dpa_stats_event_params { - int dpa_stats_id; - unsigned int storage_area_offset; - unsigned int cnts_written; - int bytes_written; -#ifdef CONFIG_COMPAT - compat_uptr_t us_cnt_ids; -#else - int *us_cnt_ids; -#endif /* CONFIG_COMPAT */ - unsigned int cnt_ids_len; - dpa_stats_request_cb request_done; + int dpa_stats_id; + unsigned int storage_area_offset; + unsigned int cnts_written; + int bytes_written; + dpa_stats_request_cb request_done; }; struct dpa_stats_event_queue { @@ -84,7 +77,6 @@ struct dpa_stats_event_queue { struct dpa_stats_event { struct dpa_stats_event_params params; /* Event data */ struct list_head lh; /* Event queue list head */ - int *ks_cnt_ids; /* Request array of counter ids from kernel-space */ }; struct dpa_stats_async_req_ev { @@ -92,11 +84,6 @@ struct dpa_stats_async_req_ev { unsigned int storage_area_offset; /* Storage offset for this request */ /* Pointers to other async requests in the current set */ struct list_head node; -#ifdef CONFIG_COMPAT - compat_uptr_t us_cnt_ids; /* Request array of counter ids from US */ -#endif /* CONFIG COMPAT */ - int *ks_cnt_ids; /* Request array of counter ids from KS */ - unsigned int cnt_ids_len; /* Number of counter ids in array */ }; struct wrp_dpa_stats_cb { diff --git a/include/linux/fsl_dpa_stats.h b/include/linux/fsl_dpa_stats.h index 5ba731e..b8fe850 100644 --- a/include/linux/fsl_dpa_stats.h +++ b/include/linux/fsl_dpa_stats.h @@ -469,7 +469,7 @@ struct dpa_stats_cnt_traffic_mng { enum dpa_stats_cnt_traffic_mng_src src; /* - * Depending on the Traffic Manager source, the 'traffic_mng' has a + * Depending on the Traffic Manager source, the 'traffic_obj' has a * different meaning: it represents a pointer to a structure of type * 'qm_ceetm_cq' in case the traffic source is a "Class Queue" or a * pointer to a structure of type 'qm_ceetm_ccg' in case the traffic @@ -690,7 +690,7 @@ struct dpa_stats_cls_cnt_traffic_mng { enum dpa_stats_cnt_traffic_mng_src src; /* - * Depending on the Traffic Manager source, the 'traffic_mng' has a + * Depending on the Traffic Manager source, the 'traffic_obj' has a * different meaning: it represents an array of pointers to structures * of type 'qm_ceetm_cq' in case the traffic source is a "Class Queue" * or an array of pointers to structures of type 'qm_ceetm_ccg' in case -- cgit v0.10.2 From 2baf518cf0005757c3851f9c2ce18904d2a0218e Mon Sep 17 00:00:00 2001 From: Catalin Udma Date: Mon, 5 Aug 2013 13:31:10 +0300 Subject: powerpc: Update KBUILD_AFLAGS with core specific options Update also KBUILD_AFLAGS specifying the target core for CONFIG_E500 -mcpu=e5500/e500mc/8540 Add also -msoft-float. Signed-off-by: Catalin Udma Change-Id: Ibaf93105792b84dae836c7020ff708ed7afbad6a Reviewed-on: http://git.am.freescale.net:8181/3764 Tested-by: Review Code-CDREVIEW Reviewed-by: Wood Scott-B07421 Reviewed-by: Rivera Jose-B46482 diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 82808b5..1893fb9 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -101,7 +101,7 @@ CFLAGS-$(CONFIG_POWER7_CPU) += $(call cc-option,-mcpu=power7) CFLAGS-$(CONFIG_TUNE_CELL) += $(call cc-option,-mtune=cell) KBUILD_CPPFLAGS += -Iarch/$(ARCH) -KBUILD_AFLAGS += -Iarch/$(ARCH) +KBUILD_AFLAGS += -msoft-float -Iarch/$(ARCH) KBUILD_CFLAGS += -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y) CPP = $(CC) -E $(KBUILD_CFLAGS) @@ -143,11 +143,14 @@ endif ifeq ($(CONFIG_E500),y) ifeq ($(CONFIG_64BIT),y) KBUILD_CFLAGS += -mcpu=e5500 +KBUILD_AFLAGS += -mcpu=e5500 else ifeq ($(CONFIG_PPC_E500MC),y) KBUILD_CFLAGS += -mcpu=e500mc +KBUILD_AFLAGS += -mcpu=e500mc else KBUILD_CFLAGS += -mcpu=8540 +KBUILD_AFLAGS += -mcpu=8540 endif endif endif -- cgit v0.10.2