aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0034-Extend-FM-MAC-Statistics-with-frame-size-counters-re.patch
blob: d880cc8aa67ec7dfaf7046eb0f081b5762667f81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
From 60f5101cdfbabd4cc29c02d69aa43a84fab52cf7 Mon Sep 17 00:00:00 2001
From: Iordache Florinel-R70177 <florinel.iordache@nxp.com>
Date: Thu, 12 Oct 2017 11:13:41 +0300
Subject: [PATCH] Extend FM MAC Statistics with frame size counters (request
 from Nokia)

Signed-off-by: Iordache Florinel-R70177 <florinel.iordache@nxp.com>
---
 .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c  |  1 +
 .../freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c | 16 ++++++
 .../freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h |  1 +
 .../sdk_fman/Peripherals/FM/MAC/fman_memac.c       | 21 ++++++++
 .../freescale/sdk_fman/Peripherals/FM/MAC/memac.c  | 57 ++++++++++++++++++++++
 .../freescale/sdk_fman/Peripherals/FM/MAC/tgec.c   | 42 ++++++++++++++++
 .../sdk_fman/inc/Peripherals/fm_mac_ext.h          | 28 +++++++++++
 .../freescale/sdk_fman/inc/flib/fsl_fman_memac.h   |  7 +++
 .../sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h      |  2 +
 .../sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c        | 41 ++++++++++++++++
 .../uapi/linux/fmd/Peripherals/fm_port_ioctls.h    | 25 ++++++++++
 11 files changed, 241 insertions(+)

--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
@@ -1389,6 +1389,7 @@ static void InitFmMacControllerDriver(t_
 
     p_FmMacControllerDriver->f_FM_MAC_ResetCounters             = DtsecResetCounters;
     p_FmMacControllerDriver->f_FM_MAC_GetStatistics             = DtsecGetStatistics;
+    p_FmMacControllerDriver->f_FM_MAC_GetFrameSizeCounters		= NULL;
 
     p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr             = DtsecModifyMacAddress;
     p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr            = DtsecAddHashMacAddress;
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c
@@ -461,6 +461,22 @@ t_Error FM_MAC_GetStatistics (t_Handle h
 
 /* ......................................................................... */
 
+t_Error FM_MAC_GetFrameSizeCounters(t_Handle h_FmMac, t_FmMacFrameSizeCounters *p_FrameSizeCounters, e_CommMode type)
+{
+    t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
+
+    SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
+
+    memset(p_FrameSizeCounters, 0, sizeof(t_FmMacFrameSizeCounters));
+
+    if (p_FmMacControllerDriver->f_FM_MAC_GetFrameSizeCounters)
+        return p_FmMacControllerDriver->f_FM_MAC_GetFrameSizeCounters(h_FmMac, p_FrameSizeCounters, type);
+
+    RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+/* ......................................................................... */
+
 t_Error FM_MAC_ModifyMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
 {
     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h
@@ -106,6 +106,7 @@ typedef struct {
 
     t_Error (*f_FM_MAC_ResetCounters) (t_Handle h_FmMac);
     t_Error (*f_FM_MAC_GetStatistics) (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics);
+    t_Error (*f_FM_MAC_GetFrameSizeCounters) (t_Handle h_FmMac, t_FmMacFrameSizeCounters *p_FrameSizeCounters, e_CommMode type);
 
     t_Error (*f_FM_MAC_ModifyMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
     t_Error (*f_FM_MAC_AddHashMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_memac.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_memac.c
@@ -360,24 +360,45 @@ uint64_t fman_memac_get_counter(struct m
     case E_MEMAC_COUNTER_R64:
         ret_val = GET_MEMAC_CNTR_64(r64);
         break;
+    case E_MEMAC_COUNTER_T64:
+        ret_val = GET_MEMAC_CNTR_64(t64);
+        break;
     case E_MEMAC_COUNTER_R127:
         ret_val = GET_MEMAC_CNTR_64(r127);
         break;
+    case E_MEMAC_COUNTER_T127:
+        ret_val = GET_MEMAC_CNTR_64(t127);
+        break;
     case E_MEMAC_COUNTER_R255:
         ret_val = GET_MEMAC_CNTR_64(r255);
         break;
+    case E_MEMAC_COUNTER_T255:
+        ret_val = GET_MEMAC_CNTR_64(t255);
+        break;
     case E_MEMAC_COUNTER_R511:
         ret_val = GET_MEMAC_CNTR_64(r511);
         break;
+    case E_MEMAC_COUNTER_T511:
+        ret_val = GET_MEMAC_CNTR_64(t511);
+        break;
     case E_MEMAC_COUNTER_R1023:
         ret_val = GET_MEMAC_CNTR_64(r1023);
         break;
+    case E_MEMAC_COUNTER_T1023:
+        ret_val = GET_MEMAC_CNTR_64(t1023);
+        break;
     case E_MEMAC_COUNTER_R1518:
         ret_val = GET_MEMAC_CNTR_64(r1518);
         break;
+    case E_MEMAC_COUNTER_T1518:
+        ret_val = GET_MEMAC_CNTR_64(t1518);
+        break;
     case E_MEMAC_COUNTER_R1519X:
         ret_val = GET_MEMAC_CNTR_64(r1519x);
         break;
+    case E_MEMAC_COUNTER_T1519X:
+        ret_val = GET_MEMAC_CNTR_64(t1519x);
+        break;
     case E_MEMAC_COUNTER_RFRG:
         ret_val = GET_MEMAC_CNTR_64(rfrg);
         break;
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c
@@ -593,6 +593,62 @@ static t_Error MemacGetStatistics(t_Hand
 
 /* ......................................................................... */
 
+static t_Error MemacGetFrameSizeCounters(t_Handle h_Memac, t_FmMacFrameSizeCounters *p_FrameSizeCounters, e_CommMode type)
+{
+    t_Memac     *p_Memac = (t_Memac *)h_Memac;
+
+    SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);
+    SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+    SANITY_CHECK_RETURN_ERROR(p_FrameSizeCounters, E_NULL_POINTER);
+
+    switch (type)
+    {
+    case e_COMM_MODE_NONE:
+    	break;
+
+    case e_COMM_MODE_RX:
+        p_FrameSizeCounters->count_pkts_64             = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R64);
+        p_FrameSizeCounters->count_pkts_65_to_127      = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R127);
+        p_FrameSizeCounters->count_pkts_128_to_255     = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R255);
+        p_FrameSizeCounters->count_pkts_256_to_511     = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R511);
+        p_FrameSizeCounters->count_pkts_512_to_1023    = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1023);
+        p_FrameSizeCounters->count_pkts_1024_to_1518   = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1518);
+        p_FrameSizeCounters->count_pkts_1519_to_1522   = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1519X);
+    	break;
+
+    case e_COMM_MODE_TX:
+        p_FrameSizeCounters->count_pkts_64             = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T64);
+        p_FrameSizeCounters->count_pkts_65_to_127      = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T127);
+        p_FrameSizeCounters->count_pkts_128_to_255     = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T255);
+        p_FrameSizeCounters->count_pkts_256_to_511     = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T511);
+        p_FrameSizeCounters->count_pkts_512_to_1023    = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1023);
+        p_FrameSizeCounters->count_pkts_1024_to_1518   = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1518);
+        p_FrameSizeCounters->count_pkts_1519_to_1522   = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1519X);
+    	break;
+
+    case e_COMM_MODE_RX_AND_TX:
+        p_FrameSizeCounters->count_pkts_64             = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R64)
+                                                       + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T64);
+        p_FrameSizeCounters->count_pkts_65_to_127      = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R127)
+                                                       + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T127);
+        p_FrameSizeCounters->count_pkts_128_to_255     = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R255)
+                                                       + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T255);
+        p_FrameSizeCounters->count_pkts_256_to_511     = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R511)
+                                                       + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T511);
+        p_FrameSizeCounters->count_pkts_512_to_1023    = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1023)
+                                                       + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1023);
+        p_FrameSizeCounters->count_pkts_1024_to_1518   = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1518)
+                                                       + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1518);
+        p_FrameSizeCounters->count_pkts_1519_to_1522   = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1519X)
+                                                       + fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_T1519X);
+    	break;
+    }
+
+    return E_OK;
+}
+
+/* ......................................................................... */
+
 static t_Error MemacModifyMacAddress (t_Handle h_Memac, t_EnetAddr *p_EnetAddr)
 {
     t_Memac     *p_Memac = (t_Memac *)h_Memac;
@@ -1025,6 +1081,7 @@ static void InitFmMacControllerDriver(t_
 
     p_FmMacControllerDriver->f_FM_MAC_ResetCounters             = MemacResetCounters;
     p_FmMacControllerDriver->f_FM_MAC_GetStatistics             = MemacGetStatistics;
+    p_FmMacControllerDriver->f_FM_MAC_GetFrameSizeCounters      = MemacGetFrameSizeCounters;
 
     p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr             = MemacModifyMacAddress;
     p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr            = MemacAddHashMacAddress;
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.c
@@ -438,6 +438,47 @@ static t_Error TgecGetStatistics(t_Handl
 
 /* ......................................................................... */
 
+static t_Error TgecGetFrameSizeCounters(t_Handle h_Tgec, t_FmMacFrameSizeCounters *p_FrameSizeCounters, e_CommMode type)
+{
+    t_Tgec              *p_Tgec = (t_Tgec *)h_Tgec;
+    struct tgec_regs    *p_TgecMemMap;
+
+    SANITY_CHECK_RETURN_ERROR(p_Tgec, E_NULL_POINTER);
+    SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
+    SANITY_CHECK_RETURN_ERROR(p_FrameSizeCounters, E_NULL_POINTER);
+
+    p_TgecMemMap = p_Tgec->p_MemMap;
+
+    switch (type)
+    {
+    case e_COMM_MODE_NONE:
+    	break;
+
+    case e_COMM_MODE_RX:
+        p_FrameSizeCounters->count_pkts_64             = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R64);
+        p_FrameSizeCounters->count_pkts_65_to_127      = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R127);
+        p_FrameSizeCounters->count_pkts_128_to_255     = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R255);
+        p_FrameSizeCounters->count_pkts_256_to_511     = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R511);
+        p_FrameSizeCounters->count_pkts_512_to_1023    = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1023);
+        p_FrameSizeCounters->count_pkts_1024_to_1518   = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1518);
+        p_FrameSizeCounters->count_pkts_1519_to_1522   = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1519X);
+    	break;
+
+    case e_COMM_MODE_TX:
+    	//Tx counters not supported
+    	break;
+
+    case e_COMM_MODE_RX_AND_TX:
+    	//Tx counters not supported
+    	break;
+    }
+
+    return E_OK;
+}
+
+
+/* ......................................................................... */
+
 static t_Error TgecEnable1588TimeStamp(t_Handle h_Tgec)
 {
     t_Tgec      *p_Tgec = (t_Tgec *)h_Tgec;
@@ -905,6 +946,7 @@ static void InitFmMacControllerDriver(t_
 
     p_FmMacControllerDriver->f_FM_MAC_ResetCounters             = TgecResetCounters;
     p_FmMacControllerDriver->f_FM_MAC_GetStatistics             = TgecGetStatistics;
+    p_FmMacControllerDriver->f_FM_MAC_GetFrameSizeCounters      = TgecGetFrameSizeCounters;
 
     p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr             = TgecModifyMacAddress;
     p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr            = TgecAddHashMacAddress;
--- a/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_mac_ext.h
+++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_mac_ext.h
@@ -197,6 +197,19 @@ typedef struct t_FmMacStatistics {
                                                - Other */
 } t_FmMacStatistics;
 
+/**************************************************************************//**
+ @Description   FM MAC Frame Size Counters
+*//***************************************************************************/
+typedef struct t_FmMacFrameSizeCounters {
+
+        uint64_t  count_pkts_64;            /**< 64 byte frame counter */
+        uint64_t  count_pkts_65_to_127;     /**< 65 to 127 byte frame counter */
+        uint64_t  count_pkts_128_to_255;    /**< 128 to 255 byte frame counter */
+        uint64_t  count_pkts_256_to_511;    /**< 256 to 511 byte frame counter */
+        uint64_t  count_pkts_512_to_1023;   /**< 512 to 1023 byte frame counter */
+        uint64_t  count_pkts_1024_to_1518;  /**< 1024 to 1518 byte frame counter */
+        uint64_t  count_pkts_1519_to_1522;  /**< 1519 to 1522 byte good frame count */
+} t_FmMacFrameSizeCounters;
 
 /**************************************************************************//**
  @Group         FM_mac_init_grp FM MAC Initialization Unit
@@ -654,6 +667,21 @@ t_Error FM_MAC_SetStatistics(t_Handle h_
 t_Error FM_MAC_GetStatistics(t_Handle h_FmMac, t_FmMacStatistics *p_Statistics);
 
 /**************************************************************************//**
+ @Function      FM_MAC_GetFrameSizeCounters
+
+ @Description   get MAC statistics counters for different frame size
+
+ @Param[in]     h_FmMac       -  A handle to a FM MAC Module.
+ @Param[in]     p_FrameSizeCounters  -  Structure with counters
+ @Param[in]     type  				-  Type of counters to be read
+
+ @Return        E_OK on success; Error code otherwise.
+
+ @Cautions      Allowed only following FM_Init().
+*//***************************************************************************/
+t_Error FM_MAC_GetFrameSizeCounters(t_Handle h_FmMac, t_FmMacFrameSizeCounters *p_FrameSizeCounters, e_CommMode type);
+
+/**************************************************************************//**
  @Function      FM_MAC_ModifyMacAddr
 
  @Description   Replace the main MAC Address
--- a/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_memac.h
+++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_memac.h
@@ -146,12 +146,19 @@ _val &= ~TX_FIFO_SECTIONS_TX_EMPTY_MASK;
 
 enum memac_counters {
 	E_MEMAC_COUNTER_R64,
+	E_MEMAC_COUNTER_T64,
 	E_MEMAC_COUNTER_R127,
+	E_MEMAC_COUNTER_T127,
 	E_MEMAC_COUNTER_R255,
+	E_MEMAC_COUNTER_T255,
 	E_MEMAC_COUNTER_R511,
+	E_MEMAC_COUNTER_T511,
 	E_MEMAC_COUNTER_R1023,
+	E_MEMAC_COUNTER_T1023,
 	E_MEMAC_COUNTER_R1518,
+	E_MEMAC_COUNTER_T1518,
 	E_MEMAC_COUNTER_R1519X,
+	E_MEMAC_COUNTER_T1519X,
 	E_MEMAC_COUNTER_RFRG,
 	E_MEMAC_COUNTER_RJBR,
 	E_MEMAC_COUNTER_RDRP,
--- a/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h
@@ -123,6 +123,8 @@ EXPORT_SYMBOL(FM_PCD_SetAdvancedOffloadS
 /* FMAN MAC exported routines */
 EXPORT_SYMBOL(FM_MAC_GetStatistics);
 
+EXPORT_SYMBOL(FM_MAC_GetFrameSizeCounters);
+
 EXPORT_SYMBOL(FM_GetSpecialOperationCoding);
 
 #endif /* __LNXWRP_EXP_SYM_H */
--- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c
@@ -4608,6 +4608,47 @@ t_Error LnxwrpFmPortIOCTL(t_LnxWrpFmPort
             break;
         }
 
+        case FM_PORT_IOC_GET_MAC_FRAME_SIZE_COUNTERS:
+        {
+            t_LnxWrpFmDev *p_LnxWrpFmDev =
+                    (t_LnxWrpFmDev *)p_LnxWrpFmPortDev->h_LnxWrpFmDev;
+            ioc_fm_port_mac_frame_size_counters_t param;
+            t_FmMacFrameSizeCounters frameSizeCounters;
+            int mac_id = p_LnxWrpFmPortDev->id;
+
+            if (!p_LnxWrpFmDev)
+                RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Port not initialized or other error!"));
+
+            if (&p_LnxWrpFmDev->txPorts[mac_id] != p_LnxWrpFmPortDev &&
+                &p_LnxWrpFmDev->rxPorts[mac_id] != p_LnxWrpFmPortDev)
+                mac_id += FM_MAX_NUM_OF_1G_MACS; /* 10G port */
+
+            if (!p_LnxWrpFmDev->macs[mac_id].h_Dev)
+                RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Port not initialized or other error!"));
+
+            if (copy_from_user(&param, (ioc_fm_port_mac_frame_size_counters_t *)arg,
+                        sizeof(ioc_fm_port_mac_frame_size_counters_t)))
+                RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
+
+            if (FM_MAC_GetFrameSizeCounters(p_LnxWrpFmDev->macs[mac_id].h_Dev,
+                        &frameSizeCounters, param.type))
+                RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
+
+            param.count_pkts_64 = frameSizeCounters.count_pkts_64;
+            param.count_pkts_65_to_127 = frameSizeCounters.count_pkts_65_to_127;
+            param.count_pkts_128_to_255 = frameSizeCounters.count_pkts_128_to_255;
+            param.count_pkts_256_to_511 = frameSizeCounters.count_pkts_256_to_511;
+            param.count_pkts_512_to_1023 = frameSizeCounters.count_pkts_512_to_1023;
+            param.count_pkts_1024_to_1518 = frameSizeCounters.count_pkts_1024_to_1518;
+            param.count_pkts_1519_to_1522 = frameSizeCounters.count_pkts_1519_to_1522;
+
+            if (copy_to_user((ioc_fm_port_mac_frame_size_counters_t *)arg, &param,
+                        sizeof(ioc_fm_port_mac_frame_size_counters_t)))
+                RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
+
+            break;
+        }
+
         case FM_PORT_IOC_GET_BMI_COUNTERS:
         {
             t_LnxWrpFmDev *p_LnxWrpFmDev =
--- a/include/uapi/linux/fmd/Peripherals/fm_port_ioctls.h
+++ b/include/uapi/linux/fmd/Peripherals/fm_port_ioctls.h
@@ -939,6 +939,31 @@ typedef struct ioc_fm_port_vsp_alloc_par
 
 #define FM_PORT_IOC_GET_BMI_COUNTERS _IOR(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(42), ioc_fm_port_bmi_stats_t)
 
+typedef struct ioc_fm_port_mac_frame_size_counters_t {
+
+        e_CommMode type;
+        uint64_t  count_pkts_64;            /**< 64 byte frame counter */
+        uint64_t  count_pkts_65_to_127;     /**< 65 to 127 byte frame counter */
+        uint64_t  count_pkts_128_to_255;    /**< 128 to 255 byte frame counter */
+        uint64_t  count_pkts_256_to_511;    /**< 256 to 511 byte frame counter */
+        uint64_t  count_pkts_512_to_1023;   /**< 512 to 1023 byte frame counter */
+        uint64_t  count_pkts_1024_to_1518;  /**< 1024 to 1518 byte frame counter */
+        uint64_t  count_pkts_1519_to_1522;  /**< 1519 to 1522 byte good frame count */
+} ioc_fm_port_mac_frame_size_counters_t;
+
+/**************************************************************************//**
+ @Function      FM_MAC_GetFrameSizeCounters
+
+ @Description   get MAC statistics counters for different frame size
+
+ @Param[out]    ioc_fm_port_mac_frame_size_counters_t    A structure holding the counters
+
+ @Return        E_OK on success; Error code otherwise.
+
+ @Cautions      Allowed only following FM_Init().
+*//***************************************************************************/
+#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)
+
 
 /** @} */ /* end of lnx_ioctl_FM_PORT_pcd_runtime_control_grp group */
 /** @} */ /* end of lnx_ioctl_FM_PORT_runtime_control_grp group */