From a9d0ea5a4d3b679ae3316c93b455d2ccc993772d Mon Sep 17 00:00:00 2001 From: Marian Chereji Date: Wed, 11 Nov 2015 11:06:34 +0200 Subject: fmd: Render header manip node statistics available in user space Added a user space interface for the "FM_PCD_ManipGetStatistics" function for retrieving header manipulation nodes statistics (including IP reassembly and fragmentation). Signed-off-by: Marian Chereji 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 9224703..781fd25 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 @@ -2805,6 +2805,77 @@ invalid_port_id: break; } +#if defined(CONFIG_COMPAT) + case FM_PCD_IOC_MANIP_GET_STATS_COMPAT: +#endif + case FM_PCD_IOC_MANIP_GET_STATS: + { + ioc_fm_pcd_manip_get_stats_t param; + +#if defined(CONFIG_COMPAT) + if (compat) + { + ioc_compat_fm_pcd_manip_get_stats_t *compat_param; + + compat_param = (ioc_compat_fm_pcd_manip_get_stats_t *) XX_Malloc( + sizeof(ioc_compat_fm_pcd_manip_get_stats_t)); + if (!compat_param) + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD")); + + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_manip_get_stats_t)); + if (copy_from_user(compat_param, + (ioc_compat_fm_pcd_manip_get_stats_t *)compat_ptr(arg), + sizeof(ioc_compat_fm_pcd_manip_get_stats_t))) + { + XX_Free(compat_param); + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); + } + + compat_copy_fm_pcd_manip_get_stats(compat_param, ¶m, COMPAT_US_TO_K); + + XX_Free(compat_param); + } + else +#endif + { + if (copy_from_user(¶m, (ioc_fm_pcd_manip_get_stats_t *)arg, + sizeof(ioc_fm_pcd_manip_get_stats_t))) + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); + } + + err = FM_PCD_ManipGetStatistics((t_Handle) param.id, + (t_FmPcdManipStats*) ¶m.stats); + +#if defined(CONFIG_COMPAT) + if (compat) + { + ioc_compat_fm_pcd_manip_get_stats_t *compat_param; + + compat_param = (ioc_compat_fm_pcd_manip_get_stats_t*) XX_Malloc( + sizeof(ioc_compat_fm_pcd_manip_get_stats_t)); + if (!compat_param) + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD")); + + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_manip_get_stats_t)); + compat_copy_fm_pcd_manip_get_stats(compat_param, ¶m, COMPAT_K_TO_US); + if (copy_to_user((ioc_compat_fm_pcd_manip_get_stats_t*) compat_ptr(arg), + compat_param, + sizeof(ioc_compat_fm_pcd_manip_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_manip_get_stats_t *)arg, + ¶m, + sizeof(ioc_fm_pcd_manip_get_stats_t))) + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG); + + break; + } + #if (DPAA_VERSION >= 11) #if defined(CONFIG_COMPAT) case FM_PCD_IOC_FRM_REPLIC_GROUP_SET_COMPAT: 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 08752aa..4f428a9 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 @@ -1083,6 +1083,30 @@ void compat_fm_pcd_manip_set_node( } } +void compat_copy_fm_pcd_manip_get_stats( + ioc_compat_fm_pcd_manip_get_stats_t *compat_param, + ioc_fm_pcd_manip_get_stats_t *param, + uint8_t compat) +{ + _fm_cpt_dbg (compat, " {->...\n"); + + if (compat == COMPAT_US_TO_K) + { + param->id = compat_pcd_id2ptr(compat_param->id); + memcpy(¶m->stats, &compat_param->stats, + sizeof(ioc_fm_pcd_manip_stats_t)); + } + else + { + compat_param->id = compat_add_ptr2id(param->id, + FM_MAP_TYPE_PCD_NODE); + memcpy(&compat_param->stats, ¶m->stats, + sizeof(ioc_fm_pcd_manip_stats_t)); + } + + _fm_cpt_dbg (compat, " ...->}\n"); +} + #if (DPAA_VERSION >= 11) void compat_copy_fm_pcd_frm_replic_group_params( ioc_compat_fm_pcd_frm_replic_group_params_t *compat_param, 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 ec2e971..b052984 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 @@ -485,6 +485,11 @@ typedef struct ioc_compat_fm_pcd_manip_params_t { compat_uptr_t id; } ioc_compat_fm_pcd_manip_params_t; +typedef struct ioc_compat_fm_pcd_manip_get_stats_t { + compat_uptr_t id; + ioc_fm_pcd_manip_stats_t stats; +} ioc_compat_fm_pcd_manip_get_stats_t; + #if (DPAA_VERSION >= 11) typedef struct ioc_compat_fm_pcd_frm_replic_group_params_t { uint8_t max_num_of_entries; @@ -666,6 +671,11 @@ void compat_fm_pcd_manip_set_node( ioc_fm_pcd_manip_params_t *param, uint8_t compat); +void compat_copy_fm_pcd_manip_get_stats( + ioc_compat_fm_pcd_manip_get_stats_t *compat_param, + ioc_fm_pcd_manip_get_stats_t *param, + uint8_t compat); + void compat_copy_fm_port_pcd_modify_tree( ioc_compat_fm_obj_t *compat_id, ioc_fm_obj_t *id, diff --git a/include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h b/include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h index a4b5e76..2786666 100644 --- a/include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h +++ b/include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h @@ -2305,6 +2305,14 @@ typedef struct ioc_fm_pcd_manip_stats_t { } u; } ioc_fm_pcd_manip_stats_t; +/**************************************************************************//** + @Description Parameters for acquiring manipulation statistics +*//***************************************************************************/ +typedef struct ioc_fm_pcd_manip_get_stats_t { + void *id; + ioc_fm_pcd_manip_stats_t stats; +} ioc_fm_pcd_manip_get_stats_t; + #if DPAA_VERSION >= 11 /**************************************************************************//** @Description Parameters for defining frame replicator group and its members @@ -2871,6 +2879,23 @@ typedef struct ioc_fm_pcd_cc_tbl_get_stats_t { #define FM_PCD_IOC_MANIP_NODE_DELETE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(44), ioc_fm_obj_t) /**************************************************************************//** + @Function FM_PCD_ManipGetStatistics + + @Description Retrieve the manipulation statistics. + + @Param[in] h_ManipNode A handle to a manipulation node. + @Param[out] p_FmPcdManipStats A structure for retrieving the manipulation statistics + + @Return E_OK on success; Error code otherwise. + + @Cautions Allowed only following FM_PCD_ManipNodeSet(). +*//***************************************************************************/ +#if defined(CONFIG_COMPAT) +#define FM_PCD_IOC_MANIP_GET_STATS_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(50), ioc_compat_fm_pcd_manip_get_stats_t) +#endif +#define FM_PCD_IOC_MANIP_GET_STATS _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(50), ioc_fm_pcd_manip_get_stats_t) + +/**************************************************************************//** @Function FM_PCD_SetAdvancedOffloadSupport @Description This routine must be called in order to support the following features: -- cgit v0.10.2