From 71702d053d60b5d53931f7d8cd62e1a9e37c7939 Mon Sep 17 00:00:00 2001 From: Marian Chereji Date: Thu, 4 Dec 2014 13:05:01 +0200 Subject: fmd: Render match table key statistics accessible from user space The key statistics for match tables are not accessible from user space using fmlib. This update implements the support for the function FM_PCD_MatchTableGetKeyStatistics to be accessible from user space. Signed-off-by: Marian Chereji Change-Id: Ibcf40fdcf7a60afc65b2f926c2a1474513ae8950 Reviewed-on: http://git.am.freescale.net:8181/25376 Tested-by: Review Code-CDREVIEW Reviewed-by: Mandy Lavi Reviewed-by: Honghua Yin diff --git a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm.c b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm.c index 75c628a..ffa1a2d 100644 --- a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm.c +++ b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm.c @@ -1957,62 +1957,138 @@ invalid_port_id: #if defined(CONFIG_COMPAT) + case FM_PCD_IOC_MATCH_TABLE_GET_KEY_STAT_COMPAT: +#endif + case FM_PCD_IOC_MATCH_TABLE_GET_KEY_STAT: + { + ioc_fm_pcd_cc_tbl_get_stats_t param; + +#if defined(CONFIG_COMPAT) + if (compat) + { + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param; + + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t *) XX_Malloc( + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); + if (!compat_param) + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD")); + + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); + if (copy_from_user(compat_param, + (ioc_compat_fm_pcd_cc_tbl_get_stats_t *)compat_ptr(arg), + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t))) + { + XX_Free(compat_param); + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); + } + + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, ¶m, COMPAT_US_TO_K); + + XX_Free(compat_param); + } + else +#endif + { + if (copy_from_user(¶m, (ioc_fm_pcd_cc_tbl_get_stats_t *)arg, + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t))) + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); + } + + + err = FM_PCD_MatchTableGetKeyStatistics((t_Handle) param.id, + param.key_index, + (t_FmPcdCcKeyStatistics *) ¶m.statistics); + +#if defined(CONFIG_COMPAT) + if (compat) + { + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param; + + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t*) XX_Malloc( + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); + if (!compat_param) + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD")); + + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, ¶m, COMPAT_K_TO_US); + if (copy_to_user((ioc_compat_fm_pcd_cc_tbl_get_stats_t*) compat_ptr(arg), + compat_param, + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t))){ + XX_Free(compat_param); + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG); + } + XX_Free(compat_param); + } + else +#endif + { + if (copy_to_user((ioc_fm_pcd_cc_tbl_get_stats_t *)arg, + ¶m, + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t))) + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG); + } + + break; + } + + +#if defined(CONFIG_COMPAT) case FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT_COMPAT: #endif case FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT: { - ioc_fm_pcd_cc_tbl_get_miss_params_t param; + ioc_fm_pcd_cc_tbl_get_stats_t param; #if defined(CONFIG_COMPAT) if (compat) { - ioc_compat_fm_pcd_cc_tbl_get_miss_params_t *compat_param; + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param; - compat_param = (ioc_compat_fm_pcd_cc_tbl_get_miss_params_t *) XX_Malloc( - sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t)); + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t *) XX_Malloc( + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); if (!compat_param) RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD")); - memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t)); + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); if (copy_from_user(compat_param, - (ioc_compat_fm_pcd_cc_tbl_get_miss_params_t *)compat_ptr(arg), - sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t))) + (ioc_compat_fm_pcd_cc_tbl_get_stats_t *)compat_ptr(arg), + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t))) { XX_Free(compat_param); RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); } - compat_copy_fm_pcd_cc_tbl_get_miss(compat_param, ¶m, COMPAT_US_TO_K); + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, ¶m, COMPAT_US_TO_K); XX_Free(compat_param); } else #endif { - if (copy_from_user(¶m, (ioc_fm_pcd_cc_tbl_get_miss_params_t *)arg, - sizeof(ioc_fm_pcd_cc_tbl_get_miss_params_t))) + if (copy_from_user(¶m, (ioc_fm_pcd_cc_tbl_get_stats_t *)arg, + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t))) RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); } err = FM_PCD_MatchTableGetMissStatistics((t_Handle) param.id, - (t_FmPcdCcKeyStatistics *) ¶m.miss_statistics); + (t_FmPcdCcKeyStatistics *) ¶m.statistics); #if defined(CONFIG_COMPAT) if (compat) { - ioc_compat_fm_pcd_cc_tbl_get_miss_params_t *compat_param; + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param; - compat_param = (ioc_compat_fm_pcd_cc_tbl_get_miss_params_t*) XX_Malloc( - sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t)); + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t*) XX_Malloc( + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); if (!compat_param) RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD")); - memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t)); - compat_copy_fm_pcd_cc_tbl_get_miss(compat_param, ¶m, COMPAT_K_TO_US); - if (copy_to_user((ioc_compat_fm_pcd_cc_tbl_get_miss_params_t*) compat_ptr(arg), + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, ¶m, COMPAT_K_TO_US); + if (copy_to_user((ioc_compat_fm_pcd_cc_tbl_get_stats_t*) compat_ptr(arg), compat_param, - sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t))){ + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t))){ XX_Free(compat_param); RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG); } @@ -2021,9 +2097,9 @@ invalid_port_id: else #endif { - if (copy_to_user((ioc_fm_pcd_hash_table_params_t *)arg, + if (copy_to_user((ioc_fm_pcd_cc_tbl_get_stats_t *)arg, ¶m, - sizeof(ioc_fm_pcd_cc_tbl_get_miss_params_t))) + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t))) RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG); } @@ -2036,58 +2112,58 @@ invalid_port_id: #endif case FM_PCD_IOC_HASH_TABLE_GET_MISS_STAT: { - ioc_fm_pcd_cc_tbl_get_miss_params_t param; + ioc_fm_pcd_cc_tbl_get_stats_t param; #if defined(CONFIG_COMPAT) if (compat) { - ioc_compat_fm_pcd_cc_tbl_get_miss_params_t *compat_param; + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param; - compat_param = (ioc_compat_fm_pcd_cc_tbl_get_miss_params_t *) XX_Malloc( - sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t)); + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t *) XX_Malloc( + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); if (!compat_param) RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD")); - memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t)); + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); if (copy_from_user(compat_param, - (ioc_compat_fm_pcd_cc_tbl_get_miss_params_t *)compat_ptr(arg), - sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t))) + (ioc_compat_fm_pcd_cc_tbl_get_stats_t *)compat_ptr(arg), + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t))) { XX_Free(compat_param); RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); } - compat_copy_fm_pcd_cc_tbl_get_miss(compat_param, ¶m, COMPAT_US_TO_K); + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, ¶m, COMPAT_US_TO_K); XX_Free(compat_param); } else #endif { - if (copy_from_user(¶m, (ioc_fm_pcd_cc_tbl_get_miss_params_t *)arg, - sizeof(ioc_fm_pcd_cc_tbl_get_miss_params_t))) + if (copy_from_user(¶m, (ioc_fm_pcd_cc_tbl_get_stats_t *)arg, + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t))) RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); } err = FM_PCD_HashTableGetMissStatistics((t_Handle) param.id, - (t_FmPcdCcKeyStatistics *) ¶m.miss_statistics); + (t_FmPcdCcKeyStatistics *) ¶m.statistics); #if defined(CONFIG_COMPAT) if (compat) { - ioc_compat_fm_pcd_cc_tbl_get_miss_params_t *compat_param; + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param; - compat_param = (ioc_compat_fm_pcd_cc_tbl_get_miss_params_t*) XX_Malloc( - sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t)); + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t*) XX_Malloc( + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); if (!compat_param) RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD")); - memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t)); - compat_copy_fm_pcd_cc_tbl_get_miss(compat_param, ¶m, COMPAT_K_TO_US); - if (copy_to_user((ioc_compat_fm_pcd_cc_tbl_get_miss_params_t*) compat_ptr(arg), + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)); + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, ¶m, COMPAT_K_TO_US); + if (copy_to_user((ioc_compat_fm_pcd_cc_tbl_get_stats_t*) compat_ptr(arg), compat_param, - sizeof(ioc_compat_fm_pcd_cc_tbl_get_miss_params_t))){ + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t))){ XX_Free(compat_param); RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG); } @@ -2096,9 +2172,9 @@ invalid_port_id: else #endif { - if (copy_to_user((ioc_fm_pcd_hash_table_params_t *)arg, + if (copy_to_user((ioc_fm_pcd_cc_tbl_get_stats_t *)arg, ¶m, - sizeof(ioc_fm_pcd_cc_tbl_get_miss_params_t))) + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t))) RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG); } diff --git a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm_compat.c b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm_compat.c index 76e5c4d..b5ffe5c 100644 --- a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm_compat.c +++ b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm_compat.c @@ -849,18 +849,20 @@ void compat_copy_fm_port_vsp_alloc_params( } #endif /* (DPAA_VERSION >= 11) */ -void compat_copy_fm_pcd_cc_tbl_get_miss( - ioc_compat_fm_pcd_cc_tbl_get_miss_params_t *compat_param, - ioc_fm_pcd_cc_tbl_get_miss_params_t *param, +void compat_copy_fm_pcd_cc_tbl_get_stats( + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param, + ioc_fm_pcd_cc_tbl_get_stats_t *param, uint8_t compat) { if (compat == COMPAT_US_TO_K) { param->id = compat_pcd_id2ptr(compat_param->id); - memcpy(¶m->miss_statistics, &compat_param->miss_statistics, sizeof(ioc_fm_pcd_cc_key_statistics_t)); + param->key_index = compat_param->key_index; + memcpy(¶m->statistics, &compat_param->statistics, sizeof(ioc_fm_pcd_cc_key_statistics_t)); } else { compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE); - memcpy(&compat_param->miss_statistics, ¶m->miss_statistics, sizeof(ioc_fm_pcd_cc_key_statistics_t)); + compat_param->key_index = param->key_index; + memcpy(&compat_param->statistics, ¶m->statistics, sizeof(ioc_fm_pcd_cc_key_statistics_t)); } } diff --git a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm_compat.h b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm_compat.h index 7340396..d89a64d 100644 --- a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm_compat.h +++ b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_ioctls_fm_compat.h @@ -544,10 +544,11 @@ typedef struct ioc_compat_fm_ctrl_mon_counters_params_t { compat_uptr_t p_mon; } ioc_compat_fm_ctrl_mon_counters_params_t; -typedef struct ioc_compat_fm_pcd_cc_tbl_get_miss_params_t { +typedef struct ioc_compat_fm_pcd_cc_tbl_get_stats_t { compat_uptr_t id; - ioc_fm_pcd_cc_key_statistics_t miss_statistics; -} ioc_compat_fm_pcd_cc_tbl_get_miss_params_t; + uint16_t key_index; + ioc_fm_pcd_cc_key_statistics_t statistics; +} ioc_compat_fm_pcd_cc_tbl_get_stats_t; /* } pcd compat structures */ @@ -597,9 +598,9 @@ void compat_copy_fm_pcd_cc_tree( ioc_fm_pcd_cc_tree_params_t *param, uint8_t compat); -void compat_copy_fm_pcd_cc_tbl_get_miss( - ioc_compat_fm_pcd_cc_tbl_get_miss_params_t *compat_param, - ioc_fm_pcd_cc_tbl_get_miss_params_t *param, +void compat_copy_fm_pcd_cc_tbl_get_stats( + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param, + ioc_fm_pcd_cc_tbl_get_stats_t *param, uint8_t compat); void compat_fm_pcd_prs_sw( diff --git a/include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h b/include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h index da52749..bc920fb 100644 --- a/include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h +++ b/include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h @@ -2339,11 +2339,40 @@ typedef struct ioc_fm_pcd_cc_key_statistics_t { } ioc_fm_pcd_cc_key_statistics_t; -typedef struct ioc_fm_pcd_cc_tbl_get_miss_params_t { +typedef struct ioc_fm_pcd_cc_tbl_get_stats_t { void *id; - ioc_fm_pcd_cc_key_statistics_t miss_statistics; -} ioc_fm_pcd_cc_tbl_get_miss_params_t; + uint16_t key_index; + ioc_fm_pcd_cc_key_statistics_t statistics; +} ioc_fm_pcd_cc_tbl_get_stats_t; +/**************************************************************************//** + @Function FM_PCD_MatchTableGetKeyStatistics + + @Description This routine may be used to get statistics counters of specific key + in a CC Node. + + If 'e_FM_PCD_CC_STATS_MODE_FRAME' and + 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node, + these counters reflect how many frames passed that were matched + this key; The total frames count will be returned in the counter + of the first range (as only one frame length range was defined). + If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for this node, the total + frame count will be separated to frame length counters, based on + provided frame length ranges. + + @Param[in] h_CcNode A handle to the node + @Param[in] keyIndex Key index for adding + @Param[out] p_KeyStatistics Key statistics counters + + @Return The specific key statistics. + + @Cautions Allowed only following FM_PCD_MatchTableSet(). +*//***************************************************************************/ + +#if defined(CONFIG_COMPAT) +#define FM_PCD_IOC_MATCH_TABLE_GET_KEY_STAT_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(12), ioc_compat_fm_pcd_cc_tbl_get_stats_t) +#endif +#define FM_PCD_IOC_MATCH_TABLE_GET_KEY_STAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(12), ioc_fm_pcd_cc_tbl_get_stats_t) /**************************************************************************//** @Function FM_PCD_MatchTableGetMissStatistics @@ -2367,9 +2396,9 @@ typedef struct ioc_fm_pcd_cc_tbl_get_miss_params_t { *//***************************************************************************/ #if defined(CONFIG_COMPAT) -#define FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(12), ioc_compat_fm_pcd_cc_tbl_get_miss_params_t) +#define FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(13), ioc_compat_fm_pcd_cc_tbl_get_stats_t) #endif -#define FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(12), ioc_fm_pcd_cc_tbl_get_miss_params_t) +#define FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(13), ioc_fm_pcd_cc_tbl_get_stats_t) /**************************************************************************//** @Function FM_PCD_HashTableGetMissStatistics @@ -2391,9 +2420,9 @@ typedef struct ioc_fm_pcd_cc_tbl_get_miss_params_t { *//***************************************************************************/ #if defined(CONFIG_COMPAT) -#define FM_PCD_IOC_HASH_TABLE_GET_MISS_STAT_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(13), ioc_compat_fm_pcd_cc_tbl_get_miss_params_t) +#define FM_PCD_IOC_HASH_TABLE_GET_MISS_STAT_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(14), ioc_compat_fm_pcd_cc_tbl_get_stats_t) #endif -#define FM_PCD_IOC_HASH_TABLE_GET_MISS_STAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(13), ioc_fm_pcd_cc_tbl_get_miss_params_t) +#define FM_PCD_IOC_HASH_TABLE_GET_MISS_STAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(14), ioc_fm_pcd_cc_tbl_get_stats_t) /**************************************************************************//** -- cgit v0.10.2