b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | From 60f5101cdfbabd4cc29c02d69aa43a84fab52cf7 Mon Sep 17 00:00:00 2001 |
| 2 | From: Iordache Florinel-R70177 <florinel.iordache@nxp.com> |
| 3 | Date: Thu, 12 Oct 2017 11:13:41 +0300 |
| 4 | Subject: [PATCH] Extend FM MAC Statistics with frame size counters (request |
| 5 | from Nokia) |
| 6 | |
| 7 | Signed-off-by: Iordache Florinel-R70177 <florinel.iordache@nxp.com> |
| 8 | --- |
| 9 | .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c | 1 + |
| 10 | .../freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c | 16 ++++++ |
| 11 | .../freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h | 1 + |
| 12 | .../sdk_fman/Peripherals/FM/MAC/fman_memac.c | 21 ++++++++ |
| 13 | .../freescale/sdk_fman/Peripherals/FM/MAC/memac.c | 57 ++++++++++++++++++++++ |
| 14 | .../freescale/sdk_fman/Peripherals/FM/MAC/tgec.c | 42 ++++++++++++++++ |
| 15 | .../sdk_fman/inc/Peripherals/fm_mac_ext.h | 28 +++++++++++ |
| 16 | .../freescale/sdk_fman/inc/flib/fsl_fman_memac.h | 7 +++ |
| 17 | .../sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h | 2 + |
| 18 | .../sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c | 41 ++++++++++++++++ |
| 19 | .../uapi/linux/fmd/Peripherals/fm_port_ioctls.h | 25 ++++++++++ |
| 20 | 11 files changed, 241 insertions(+) |
| 21 | |
| 22 | --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c |
| 23 | +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c |
| 24 | @@ -1389,6 +1389,7 @@ static void InitFmMacControllerDriver(t_ |
| 25 | |
| 26 | p_FmMacControllerDriver->f_FM_MAC_ResetCounters = DtsecResetCounters; |
| 27 | p_FmMacControllerDriver->f_FM_MAC_GetStatistics = DtsecGetStatistics; |
| 28 | + p_FmMacControllerDriver->f_FM_MAC_GetFrameSizeCounters = NULL; |
| 29 | |
| 30 | p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr = DtsecModifyMacAddress; |
| 31 | p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr = DtsecAddHashMacAddress; |
| 32 | --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c |
| 33 | +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c |
| 34 | @@ -461,6 +461,22 @@ t_Error FM_MAC_GetStatistics (t_Handle h |
| 35 | |
| 36 | /* ......................................................................... */ |
| 37 | |
| 38 | +t_Error FM_MAC_GetFrameSizeCounters(t_Handle h_FmMac, t_FmMacFrameSizeCounters *p_FrameSizeCounters, e_CommMode type) |
| 39 | +{ |
| 40 | + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac; |
| 41 | + |
| 42 | + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE); |
| 43 | + |
| 44 | + memset(p_FrameSizeCounters, 0, sizeof(t_FmMacFrameSizeCounters)); |
| 45 | + |
| 46 | + if (p_FmMacControllerDriver->f_FM_MAC_GetFrameSizeCounters) |
| 47 | + return p_FmMacControllerDriver->f_FM_MAC_GetFrameSizeCounters(h_FmMac, p_FrameSizeCounters, type); |
| 48 | + |
| 49 | + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG); |
| 50 | +} |
| 51 | + |
| 52 | +/* ......................................................................... */ |
| 53 | + |
| 54 | t_Error FM_MAC_ModifyMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr) |
| 55 | { |
| 56 | t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac; |
| 57 | --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h |
| 58 | +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h |
| 59 | @@ -106,6 +106,7 @@ typedef struct { |
| 60 | |
| 61 | t_Error (*f_FM_MAC_ResetCounters) (t_Handle h_FmMac); |
| 62 | t_Error (*f_FM_MAC_GetStatistics) (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics); |
| 63 | + t_Error (*f_FM_MAC_GetFrameSizeCounters) (t_Handle h_FmMac, t_FmMacFrameSizeCounters *p_FrameSizeCounters, e_CommMode type); |
| 64 | |
| 65 | t_Error (*f_FM_MAC_ModifyMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr); |
| 66 | t_Error (*f_FM_MAC_AddHashMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr); |
| 67 | --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_memac.c |
| 68 | +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_memac.c |
| 69 | @@ -360,24 +360,45 @@ uint64_t fman_memac_get_counter(struct m |
| 70 | case E_MEMAC_COUNTER_R64: |
| 71 | ret_val = GET_MEMAC_CNTR_64(r64); |
| 72 | break; |
| 73 | + case E_MEMAC_COUNTER_T64: |
| 74 | + ret_val = GET_MEMAC_CNTR_64(t64); |
| 75 | + break; |
| 76 | case E_MEMAC_COUNTER_R127: |
| 77 | ret_val = GET_MEMAC_CNTR_64(r127); |
| 78 | break; |
| 79 | + case E_MEMAC_COUNTER_T127: |
| 80 | + ret_val = GET_MEMAC_CNTR_64(t127); |
| 81 | + break; |
| 82 | case E_MEMAC_COUNTER_R255: |
| 83 | ret_val = GET_MEMAC_CNTR_64(r255); |
| 84 | break; |
| 85 | + case E_MEMAC_COUNTER_T255: |
| 86 | + ret_val = GET_MEMAC_CNTR_64(t255); |
| 87 | + break; |
| 88 | case E_MEMAC_COUNTER_R511: |
| 89 | ret_val = GET_MEMAC_CNTR_64(r511); |
| 90 | break; |
| 91 | + case E_MEMAC_COUNTER_T511: |
| 92 | + ret_val = GET_MEMAC_CNTR_64(t511); |
| 93 | + break; |
| 94 | case E_MEMAC_COUNTER_R1023: |
| 95 | ret_val = GET_MEMAC_CNTR_64(r1023); |
| 96 | break; |
| 97 | + case E_MEMAC_COUNTER_T1023: |
| 98 | + ret_val = GET_MEMAC_CNTR_64(t1023); |
| 99 | + break; |
| 100 | case E_MEMAC_COUNTER_R1518: |
| 101 | ret_val = GET_MEMAC_CNTR_64(r1518); |
| 102 | break; |
| 103 | + case E_MEMAC_COUNTER_T1518: |
| 104 | + ret_val = GET_MEMAC_CNTR_64(t1518); |
| 105 | + break; |
| 106 | case E_MEMAC_COUNTER_R1519X: |
| 107 | ret_val = GET_MEMAC_CNTR_64(r1519x); |
| 108 | break; |
| 109 | + case E_MEMAC_COUNTER_T1519X: |
| 110 | + ret_val = GET_MEMAC_CNTR_64(t1519x); |
| 111 | + break; |
| 112 | case E_MEMAC_COUNTER_RFRG: |
| 113 | ret_val = GET_MEMAC_CNTR_64(rfrg); |
| 114 | break; |
| 115 | --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c |
| 116 | +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c |
| 117 | @@ -593,6 +593,62 @@ static t_Error MemacGetStatistics(t_Hand |
| 118 | |
| 119 | /* ......................................................................... */ |
| 120 | |
| 121 | +static t_Error MemacGetFrameSizeCounters(t_Handle h_Memac, t_FmMacFrameSizeCounters *p_FrameSizeCounters, e_CommMode type) |
| 122 | +{ |
| 123 | + t_Memac *p_Memac = (t_Memac *)h_Memac; |
| 124 | + |
| 125 | + SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER); |
| 126 | + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE); |
| 127 | + SANITY_CHECK_RETURN_ERROR(p_FrameSizeCounters, E_NULL_POINTER); |
| 128 | + |
| 129 | + switch (type) |
| 130 | + { |
| 131 | + case e_COMM_MODE_NONE: |
| 132 | + break; |
| 133 | + |
| 134 | + case e_COMM_MODE_RX: |
| 135 | + p_FrameSizeCounters->count_pkts_64 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R64); |
| 136 | + p_FrameSizeCounters->count_pkts_65_to_127 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R127); |
| 137 | + p_FrameSizeCounters->count_pkts_128_to_255 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R255); |
| 138 | + p_FrameSizeCounters->count_pkts_256_to_511 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R511); |
| 139 | + p_FrameSizeCounters->count_pkts_512_to_1023 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1023); |
| 140 | + p_FrameSizeCounters->count_pkts_1024_to_1518 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1518); |
| 141 | + p_FrameSizeCounters->count_pkts_1519_to_1522 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1519X); |
| 142 | + break; |
| 143 | + |
| 144 | + case e_COMM_MODE_TX: |
| 145 | + p_FrameSizeCounters->count_pkts_64 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T64); |
| 146 | + p_FrameSizeCounters->count_pkts_65_to_127 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T127); |
| 147 | + p_FrameSizeCounters->count_pkts_128_to_255 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T255); |
| 148 | + p_FrameSizeCounters->count_pkts_256_to_511 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T511); |
| 149 | + p_FrameSizeCounters->count_pkts_512_to_1023 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1023); |
| 150 | + p_FrameSizeCounters->count_pkts_1024_to_1518 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1518); |
| 151 | + p_FrameSizeCounters->count_pkts_1519_to_1522 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1519X); |
| 152 | + break; |
| 153 | + |
| 154 | + case e_COMM_MODE_RX_AND_TX: |
| 155 | + p_FrameSizeCounters->count_pkts_64 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R64) |
| 156 | + + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T64); |
| 157 | + p_FrameSizeCounters->count_pkts_65_to_127 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R127) |
| 158 | + + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T127); |
| 159 | + p_FrameSizeCounters->count_pkts_128_to_255 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R255) |
| 160 | + + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T255); |
| 161 | + p_FrameSizeCounters->count_pkts_256_to_511 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R511) |
| 162 | + + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T511); |
| 163 | + p_FrameSizeCounters->count_pkts_512_to_1023 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1023) |
| 164 | + + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1023); |
| 165 | + p_FrameSizeCounters->count_pkts_1024_to_1518 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1518) |
| 166 | + + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1518); |
| 167 | + p_FrameSizeCounters->count_pkts_1519_to_1522 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1519X) |
| 168 | + + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1519X); |
| 169 | + break; |
| 170 | + } |
| 171 | + |
| 172 | + return E_OK; |
| 173 | +} |
| 174 | + |
| 175 | +/* ......................................................................... */ |
| 176 | + |
| 177 | static t_Error MemacModifyMacAddress (t_Handle h_Memac, t_EnetAddr *p_EnetAddr) |
| 178 | { |
| 179 | t_Memac *p_Memac = (t_Memac *)h_Memac; |
| 180 | @@ -1025,6 +1081,7 @@ static void InitFmMacControllerDriver(t_ |
| 181 | |
| 182 | p_FmMacControllerDriver->f_FM_MAC_ResetCounters = MemacResetCounters; |
| 183 | p_FmMacControllerDriver->f_FM_MAC_GetStatistics = MemacGetStatistics; |
| 184 | + p_FmMacControllerDriver->f_FM_MAC_GetFrameSizeCounters = MemacGetFrameSizeCounters; |
| 185 | |
| 186 | p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr = MemacModifyMacAddress; |
| 187 | p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr = MemacAddHashMacAddress; |
| 188 | --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.c |
| 189 | +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.c |
| 190 | @@ -438,6 +438,47 @@ static t_Error TgecGetStatistics(t_Handl |
| 191 | |
| 192 | /* ......................................................................... */ |
| 193 | |
| 194 | +static t_Error TgecGetFrameSizeCounters(t_Handle h_Tgec, t_FmMacFrameSizeCounters *p_FrameSizeCounters, e_CommMode type) |
| 195 | +{ |
| 196 | + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec; |
| 197 | + struct tgec_regs *p_TgecMemMap; |
| 198 | + |
| 199 | + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_NULL_POINTER); |
| 200 | + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE); |
| 201 | + SANITY_CHECK_RETURN_ERROR(p_FrameSizeCounters, E_NULL_POINTER); |
| 202 | + |
| 203 | + p_TgecMemMap = p_Tgec->p_MemMap; |
| 204 | + |
| 205 | + switch (type) |
| 206 | + { |
| 207 | + case e_COMM_MODE_NONE: |
| 208 | + break; |
| 209 | + |
| 210 | + case e_COMM_MODE_RX: |
| 211 | + p_FrameSizeCounters->count_pkts_64 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R64); |
| 212 | + p_FrameSizeCounters->count_pkts_65_to_127 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R127); |
| 213 | + p_FrameSizeCounters->count_pkts_128_to_255 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R255); |
| 214 | + p_FrameSizeCounters->count_pkts_256_to_511 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R511); |
| 215 | + p_FrameSizeCounters->count_pkts_512_to_1023 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1023); |
| 216 | + p_FrameSizeCounters->count_pkts_1024_to_1518 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1518); |
| 217 | + p_FrameSizeCounters->count_pkts_1519_to_1522 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1519X); |
| 218 | + break; |
| 219 | + |
| 220 | + case e_COMM_MODE_TX: |
| 221 | + //Tx counters not supported |
| 222 | + break; |
| 223 | + |
| 224 | + case e_COMM_MODE_RX_AND_TX: |
| 225 | + //Tx counters not supported |
| 226 | + break; |
| 227 | + } |
| 228 | + |
| 229 | + return E_OK; |
| 230 | +} |
| 231 | + |
| 232 | + |
| 233 | +/* ......................................................................... */ |
| 234 | + |
| 235 | static t_Error TgecEnable1588TimeStamp(t_Handle h_Tgec) |
| 236 | { |
| 237 | t_Tgec *p_Tgec = (t_Tgec *)h_Tgec; |
| 238 | @@ -905,6 +946,7 @@ static void InitFmMacControllerDriver(t_ |
| 239 | |
| 240 | p_FmMacControllerDriver->f_FM_MAC_ResetCounters = TgecResetCounters; |
| 241 | p_FmMacControllerDriver->f_FM_MAC_GetStatistics = TgecGetStatistics; |
| 242 | + p_FmMacControllerDriver->f_FM_MAC_GetFrameSizeCounters = TgecGetFrameSizeCounters; |
| 243 | |
| 244 | p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr = TgecModifyMacAddress; |
| 245 | p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr = TgecAddHashMacAddress; |
| 246 | --- a/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_mac_ext.h |
| 247 | +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_mac_ext.h |
| 248 | @@ -197,6 +197,19 @@ typedef struct t_FmMacStatistics { |
| 249 | - Other */ |
| 250 | } t_FmMacStatistics; |
| 251 | |
| 252 | +/**************************************************************************//** |
| 253 | + @Description FM MAC Frame Size Counters |
| 254 | +*//***************************************************************************/ |
| 255 | +typedef struct t_FmMacFrameSizeCounters { |
| 256 | + |
| 257 | + uint64_t count_pkts_64; /**< 64 byte frame counter */ |
| 258 | + uint64_t count_pkts_65_to_127; /**< 65 to 127 byte frame counter */ |
| 259 | + uint64_t count_pkts_128_to_255; /**< 128 to 255 byte frame counter */ |
| 260 | + uint64_t count_pkts_256_to_511; /**< 256 to 511 byte frame counter */ |
| 261 | + uint64_t count_pkts_512_to_1023; /**< 512 to 1023 byte frame counter */ |
| 262 | + uint64_t count_pkts_1024_to_1518; /**< 1024 to 1518 byte frame counter */ |
| 263 | + uint64_t count_pkts_1519_to_1522; /**< 1519 to 1522 byte good frame count */ |
| 264 | +} t_FmMacFrameSizeCounters; |
| 265 | |
| 266 | /**************************************************************************//** |
| 267 | @Group FM_mac_init_grp FM MAC Initialization Unit |
| 268 | @@ -654,6 +667,21 @@ t_Error FM_MAC_SetStatistics(t_Handle h_ |
| 269 | t_Error FM_MAC_GetStatistics(t_Handle h_FmMac, t_FmMacStatistics *p_Statistics); |
| 270 | |
| 271 | /**************************************************************************//** |
| 272 | + @Function FM_MAC_GetFrameSizeCounters |
| 273 | + |
| 274 | + @Description get MAC statistics counters for different frame size |
| 275 | + |
| 276 | + @Param[in] h_FmMac - A handle to a FM MAC Module. |
| 277 | + @Param[in] p_FrameSizeCounters - Structure with counters |
| 278 | + @Param[in] type - Type of counters to be read |
| 279 | + |
| 280 | + @Return E_OK on success; Error code otherwise. |
| 281 | + |
| 282 | + @Cautions Allowed only following FM_Init(). |
| 283 | +*//***************************************************************************/ |
| 284 | +t_Error FM_MAC_GetFrameSizeCounters(t_Handle h_FmMac, t_FmMacFrameSizeCounters *p_FrameSizeCounters, e_CommMode type); |
| 285 | + |
| 286 | +/**************************************************************************//** |
| 287 | @Function FM_MAC_ModifyMacAddr |
| 288 | |
| 289 | @Description Replace the main MAC Address |
| 290 | --- a/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_memac.h |
| 291 | +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_memac.h |
| 292 | @@ -146,12 +146,19 @@ _val &= ~TX_FIFO_SECTIONS_TX_EMPTY_MASK; |
| 293 | |
| 294 | enum memac_counters { |
| 295 | E_MEMAC_COUNTER_R64, |
| 296 | + E_MEMAC_COUNTER_T64, |
| 297 | E_MEMAC_COUNTER_R127, |
| 298 | + E_MEMAC_COUNTER_T127, |
| 299 | E_MEMAC_COUNTER_R255, |
| 300 | + E_MEMAC_COUNTER_T255, |
| 301 | E_MEMAC_COUNTER_R511, |
| 302 | + E_MEMAC_COUNTER_T511, |
| 303 | E_MEMAC_COUNTER_R1023, |
| 304 | + E_MEMAC_COUNTER_T1023, |
| 305 | E_MEMAC_COUNTER_R1518, |
| 306 | + E_MEMAC_COUNTER_T1518, |
| 307 | E_MEMAC_COUNTER_R1519X, |
| 308 | + E_MEMAC_COUNTER_T1519X, |
| 309 | E_MEMAC_COUNTER_RFRG, |
| 310 | E_MEMAC_COUNTER_RJBR, |
| 311 | E_MEMAC_COUNTER_RDRP, |
| 312 | --- a/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h |
| 313 | +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h |
| 314 | @@ -123,6 +123,8 @@ EXPORT_SYMBOL(FM_PCD_SetAdvancedOffloadS |
| 315 | /* FMAN MAC exported routines */ |
| 316 | EXPORT_SYMBOL(FM_MAC_GetStatistics); |
| 317 | |
| 318 | +EXPORT_SYMBOL(FM_MAC_GetFrameSizeCounters); |
| 319 | + |
| 320 | EXPORT_SYMBOL(FM_GetSpecialOperationCoding); |
| 321 | |
| 322 | #endif /* __LNXWRP_EXP_SYM_H */ |
| 323 | --- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c |
| 324 | +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c |
| 325 | @@ -4608,6 +4608,47 @@ t_Error LnxwrpFmPortIOCTL(t_LnxWrpFmPort |
| 326 | break; |
| 327 | } |
| 328 | |
| 329 | + case FM_PORT_IOC_GET_MAC_FRAME_SIZE_COUNTERS: |
| 330 | + { |
| 331 | + t_LnxWrpFmDev *p_LnxWrpFmDev = |
| 332 | + (t_LnxWrpFmDev *)p_LnxWrpFmPortDev->h_LnxWrpFmDev; |
| 333 | + ioc_fm_port_mac_frame_size_counters_t param; |
| 334 | + t_FmMacFrameSizeCounters frameSizeCounters; |
| 335 | + int mac_id = p_LnxWrpFmPortDev->id; |
| 336 | + |
| 337 | + if (!p_LnxWrpFmDev) |
| 338 | + RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Port not initialized or other error!")); |
| 339 | + |
| 340 | + if (&p_LnxWrpFmDev->txPorts[mac_id] != p_LnxWrpFmPortDev && |
| 341 | + &p_LnxWrpFmDev->rxPorts[mac_id] != p_LnxWrpFmPortDev) |
| 342 | + mac_id += FM_MAX_NUM_OF_1G_MACS; /* 10G port */ |
| 343 | + |
| 344 | + if (!p_LnxWrpFmDev->macs[mac_id].h_Dev) |
| 345 | + RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Port not initialized or other error!")); |
| 346 | + |
| 347 | + if (copy_from_user(¶m, (ioc_fm_port_mac_frame_size_counters_t *)arg, |
| 348 | + sizeof(ioc_fm_port_mac_frame_size_counters_t))) |
| 349 | + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); |
| 350 | + |
| 351 | + if (FM_MAC_GetFrameSizeCounters(p_LnxWrpFmDev->macs[mac_id].h_Dev, |
| 352 | + &frameSizeCounters, param.type)) |
| 353 | + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); |
| 354 | + |
| 355 | + param.count_pkts_64 = frameSizeCounters.count_pkts_64; |
| 356 | + param.count_pkts_65_to_127 = frameSizeCounters.count_pkts_65_to_127; |
| 357 | + param.count_pkts_128_to_255 = frameSizeCounters.count_pkts_128_to_255; |
| 358 | + param.count_pkts_256_to_511 = frameSizeCounters.count_pkts_256_to_511; |
| 359 | + param.count_pkts_512_to_1023 = frameSizeCounters.count_pkts_512_to_1023; |
| 360 | + param.count_pkts_1024_to_1518 = frameSizeCounters.count_pkts_1024_to_1518; |
| 361 | + param.count_pkts_1519_to_1522 = frameSizeCounters.count_pkts_1519_to_1522; |
| 362 | + |
| 363 | + if (copy_to_user((ioc_fm_port_mac_frame_size_counters_t *)arg, ¶m, |
| 364 | + sizeof(ioc_fm_port_mac_frame_size_counters_t))) |
| 365 | + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG); |
| 366 | + |
| 367 | + break; |
| 368 | + } |
| 369 | + |
| 370 | case FM_PORT_IOC_GET_BMI_COUNTERS: |
| 371 | { |
| 372 | t_LnxWrpFmDev *p_LnxWrpFmDev = |
| 373 | --- a/include/uapi/linux/fmd/Peripherals/fm_port_ioctls.h |
| 374 | +++ b/include/uapi/linux/fmd/Peripherals/fm_port_ioctls.h |
| 375 | @@ -939,6 +939,31 @@ typedef struct ioc_fm_port_vsp_alloc_par |
| 376 | |
| 377 | #define FM_PORT_IOC_GET_BMI_COUNTERS _IOR(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(42), ioc_fm_port_bmi_stats_t) |
| 378 | |
| 379 | +typedef struct ioc_fm_port_mac_frame_size_counters_t { |
| 380 | + |
| 381 | + e_CommMode type; |
| 382 | + uint64_t count_pkts_64; /**< 64 byte frame counter */ |
| 383 | + uint64_t count_pkts_65_to_127; /**< 65 to 127 byte frame counter */ |
| 384 | + uint64_t count_pkts_128_to_255; /**< 128 to 255 byte frame counter */ |
| 385 | + uint64_t count_pkts_256_to_511; /**< 256 to 511 byte frame counter */ |
| 386 | + uint64_t count_pkts_512_to_1023; /**< 512 to 1023 byte frame counter */ |
| 387 | + uint64_t count_pkts_1024_to_1518; /**< 1024 to 1518 byte frame counter */ |
| 388 | + uint64_t count_pkts_1519_to_1522; /**< 1519 to 1522 byte good frame count */ |
| 389 | +} ioc_fm_port_mac_frame_size_counters_t; |
| 390 | + |
| 391 | +/**************************************************************************//** |
| 392 | + @Function FM_MAC_GetFrameSizeCounters |
| 393 | + |
| 394 | + @Description get MAC statistics counters for different frame size |
| 395 | + |
| 396 | + @Param[out] ioc_fm_port_mac_frame_size_counters_t A structure holding the counters |
| 397 | + |
| 398 | + @Return E_OK on success; Error code otherwise. |
| 399 | + |
| 400 | + @Cautions Allowed only following FM_Init(). |
| 401 | +*//***************************************************************************/ |
| 402 | +#define FM_PORT_IOC_GET_MAC_FRAME_SIZE_COUNTERS _IOR(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(43), ioc_fm_port_mac_frame_size_counters_t) |
| 403 | + |
| 404 | |
| 405 | /** @} */ /* end of lnx_ioctl_FM_PORT_pcd_runtime_control_grp group */ |
| 406 | /** @} */ /* end of lnx_ioctl_FM_PORT_runtime_control_grp group */ |