aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/lantiq/vrx518_tc/patches/205-dcdp-ptm_tc-dynamically-alloc-mib.patch
blob: ca4c041b210bbf1300ca888492a86f2e08234a3f (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
--- a/dcdp/ptm_tc.c
+++ b/dcdp/ptm_tc.c
@@ -298,15 +298,19 @@ static int ptm_tc_get_stats(struct ptm_e
 )
 {
 	struct rtnl_link_stats64 *stat;
-	struct wan_rx_mib_table rx_mib;
+	struct wan_rx_mib_table *rx_mib;
 	unsigned int cur_cnt, last_cnt;
 	struct intel_tc_ptm_sl_stats *ptm_sl_stats;
 	struct ptm_priv *ptm_tc;
+	int ret = 0;
 	if (!priv || !stats)
 		return -EFAULT;
 	ptm_tc = priv->ptm_tc;
 	if (!ptm_tc)
 		return -EFAULT;
+	rx_mib = kzalloc(sizeof(*rx_mib), GFP_KERNEL);
+	if (!rx_mib)
+		return -ENOMEM;
 	if (bonding)
 		stats->tc_info = TC_PTM_BND_MODE;
 	else
@@ -340,11 +344,11 @@ static int ptm_tc_get_stats(struct ptm_e
 		? cur_cnt - last_cnt
 		: cur_cnt + ((unsigned int)(-1) - last_cnt);
 
-	tc_mem_read(priv, &rx_mib,
+	tc_mem_read(priv, rx_mib,
 		fpi_addr(__RX_GIF_MIB_BASE),
-		sizeof(rx_mib)
+		sizeof(*rx_mib)
 	);
-	ptm_sl_stats->wrx_gif_drop_pdu = rx_mib.wrx_dropdes_pdu;
+	ptm_sl_stats->wrx_gif_drop_pdu = rx_mib->wrx_dropdes_pdu;
 
 	cur_cnt = tc_r32(GIF0_RX_CRC_ERR_CNT);
 	last_cnt = priv->ptm_mib.rx_crc_err_pdu[0];
@@ -358,7 +362,7 @@ static int ptm_tc_get_stats(struct ptm_e
 		? cur_cnt - last_cnt
 		: cur_cnt + ((unsigned int)(-1) - last_cnt);
 
-	ptm_sl_stats->wrx_gif_total_bytes = rx_mib.wrx_total_bytes;
+	ptm_sl_stats->wrx_gif_total_bytes = rx_mib->wrx_total_bytes;
 	cur_cnt = sb_r32(__US_TC_LOCAL_Q_CFG_CTXT_BASE +
 		offsetof(desq_cfg_ctxt_t, deq_pkt_cnt) / 4);
 	last_cnt = priv->ptm_mib.tx_total_pdu[0];
@@ -376,90 +380,108 @@ static int ptm_tc_get_stats(struct ptm_e
 	/* For bonding information */
 	if (bonding) {
 		int i;
-		struct intel_tc_ptm_bonding_stats ptm_ds;
-		struct intel_tc_ptm_bonding_stats ptm_us;
+		struct intel_tc_ptm_bonding_stats *ptm_ds;
+		struct intel_tc_ptm_bonding_stats *ptm_us;
 		struct intel_tc_ptm_bonding_stats *ptm_bonding_stats;
+
+		ptm_ds = kzalloc(sizeof(*ptm_ds), GFP_KERNEL);
+		if (!ptm_ds) {
+			ret = -ENOMEM;
+			goto free_rx_mib;
+		}
+		
+		ptm_us = kzalloc(sizeof(*ptm_us), GFP_KERNEL);
+		if (!ptm_us) {
+			ret = -ENOMEM;
+			goto free_ptm_ds;
+		}
+
 		priv = tc_ep_priv(0);
-		ptm_tc_bond_get_stats(priv, &ptm_ds);
+		ptm_tc_bond_get_stats(priv, ptm_ds);
 		priv = tc_ep_priv(1);
-		ptm_tc_bond_get_stats(priv, &ptm_us);
+		ptm_tc_bond_get_stats(priv, ptm_us);
 		ptm_bonding_stats =
 			&(stats->stats.ptm_tc_stats.pmt_bonding_stats);
 		for (i = 0; i < 8; i++)
 			ptm_bonding_stats->us_gif_mib[i] =
-				ptm_ds.us_gif_mib[i] + ptm_us.us_gif_mib[i];
+				ptm_ds->us_gif_mib[i] + ptm_us->us_gif_mib[i];
 		for (i = 0; i < 8; i++) {
 			ptm_bonding_stats->ds_gif_mib[i].rx_frag_byte_cnt =
-				ptm_ds.ds_gif_mib[i].rx_frag_byte_cnt
-				+ ptm_us.ds_gif_mib[i].rx_frag_byte_cnt;
+				ptm_ds->ds_gif_mib[i].rx_frag_byte_cnt
+				+ ptm_us->ds_gif_mib[i].rx_frag_byte_cnt;
 			ptm_bonding_stats->ds_gif_mib[i].rx_byte_cnt =
-				ptm_ds.ds_gif_mib[i].rx_byte_cnt
-				+ ptm_us.ds_gif_mib[i].rx_byte_cnt;
+				ptm_ds->ds_gif_mib[i].rx_byte_cnt
+				+ ptm_us->ds_gif_mib[i].rx_byte_cnt;
 			ptm_bonding_stats->ds_gif_mib[i].rx_of_frag_byte_cnt =
-				ptm_ds.ds_gif_mib[i].rx_of_frag_byte_cnt
-				+ ptm_us.ds_gif_mib[i].rx_of_frag_byte_cnt;
+				ptm_ds->ds_gif_mib[i].rx_of_frag_byte_cnt
+				+ ptm_us->ds_gif_mib[i].rx_of_frag_byte_cnt;
 			ptm_bonding_stats->ds_gif_mib[i].rx_of_byte_cnt =
-				ptm_ds.ds_gif_mib[i].rx_of_byte_cnt
-				+ ptm_us.ds_gif_mib[i].rx_of_byte_cnt;
+				ptm_ds->ds_gif_mib[i].rx_of_byte_cnt
+				+ ptm_us->ds_gif_mib[i].rx_of_byte_cnt;
 			ptm_bonding_stats->ds_gif_mib[i].rx_oor_frag_byte_cnt =
-				ptm_ds.ds_gif_mib[i].rx_oor_frag_byte_cnt
-				+ ptm_us.ds_gif_mib[i].rx_oor_frag_byte_cnt;
+				ptm_ds->ds_gif_mib[i].rx_oor_frag_byte_cnt
+				+ ptm_us->ds_gif_mib[i].rx_oor_frag_byte_cnt;
 			ptm_bonding_stats->ds_gif_mib[i].rx_miss_frag_byte_cnt =
-				ptm_ds.ds_gif_mib[i].rx_miss_frag_byte_cnt
-				+ ptm_us.ds_gif_mib[i].rx_miss_frag_byte_cnt;
+				ptm_ds->ds_gif_mib[i].rx_miss_frag_byte_cnt
+				+ ptm_us->ds_gif_mib[i].rx_miss_frag_byte_cnt;
 			ptm_bonding_stats->ds_gif_mib[i].rx_to_frag_byte_cnt =
-				ptm_ds.ds_gif_mib[i].rx_to_frag_byte_cnt
-				+ ptm_us.ds_gif_mib[i].rx_to_frag_byte_cnt;
+				ptm_ds->ds_gif_mib[i].rx_to_frag_byte_cnt
+				+ ptm_us->ds_gif_mib[i].rx_to_frag_byte_cnt;
 		}
 		for (i = 0; i < 4; i++) {
 			ptm_bonding_stats->ds_bg_mib[i].conform_pkt_cnt =
-				ptm_ds.ds_bg_mib[i].conform_pkt_cnt
-				+ ptm_us.ds_bg_mib[i].conform_pkt_cnt;
+				ptm_ds->ds_bg_mib[i].conform_pkt_cnt
+				+ ptm_us->ds_bg_mib[i].conform_pkt_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].conform_frag_cnt =
-				ptm_ds.ds_bg_mib[i].conform_frag_cnt
-				+ ptm_us.ds_bg_mib[i].conform_frag_cnt;
+				ptm_ds->ds_bg_mib[i].conform_frag_cnt
+				+ ptm_us->ds_bg_mib[i].conform_frag_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].conform_byte_cnt =
-				ptm_ds.ds_bg_mib[i].conform_byte_cnt
-				+ ptm_us.ds_bg_mib[i].conform_byte_cnt;
+				ptm_ds->ds_bg_mib[i].conform_byte_cnt
+				+ ptm_us->ds_bg_mib[i].conform_byte_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].no_sop_pkt_cnt =
-				ptm_ds.ds_bg_mib[i].no_sop_pkt_cnt
-				+ ptm_us.ds_bg_mib[i].no_sop_pkt_cnt;
+				ptm_ds->ds_bg_mib[i].no_sop_pkt_cnt
+				+ ptm_us->ds_bg_mib[i].no_sop_pkt_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].no_sop_frag_cnt =
-				ptm_ds.ds_bg_mib[i].no_sop_frag_cnt
-				+ ptm_us.ds_bg_mib[i].no_sop_frag_cnt;
+				ptm_ds->ds_bg_mib[i].no_sop_frag_cnt
+				+ ptm_us->ds_bg_mib[i].no_sop_frag_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].no_sop_byte_cnt =
-				ptm_ds.ds_bg_mib[i].no_sop_byte_cnt
-				+ ptm_us.ds_bg_mib[i].no_sop_byte_cnt;
+				ptm_ds->ds_bg_mib[i].no_sop_byte_cnt
+				+ ptm_us->ds_bg_mib[i].no_sop_byte_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].no_eop_pkt_cnt =
-				ptm_ds.ds_bg_mib[i].no_eop_pkt_cnt
-				+ ptm_us.ds_bg_mib[i].no_eop_pkt_cnt;
+				ptm_ds->ds_bg_mib[i].no_eop_pkt_cnt
+				+ ptm_us->ds_bg_mib[i].no_eop_pkt_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].no_eop_frag_cnt =
-				ptm_ds.ds_bg_mib[i].no_eop_frag_cnt
-				+ ptm_us.ds_bg_mib[i].no_eop_frag_cnt;
+				ptm_ds->ds_bg_mib[i].no_eop_frag_cnt
+				+ ptm_us->ds_bg_mib[i].no_eop_frag_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].no_eop_byte_cnt =
-				ptm_ds.ds_bg_mib[i].no_eop_byte_cnt
-				+ ptm_us.ds_bg_mib[i].no_eop_byte_cnt;
+				ptm_ds->ds_bg_mib[i].no_eop_byte_cnt
+				+ ptm_us->ds_bg_mib[i].no_eop_byte_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].oversize_pkt_cnt =
-				ptm_ds.ds_bg_mib[i].oversize_pkt_cnt
-				+ ptm_us.ds_bg_mib[i].oversize_pkt_cnt;
+				ptm_ds->ds_bg_mib[i].oversize_pkt_cnt
+				+ ptm_us->ds_bg_mib[i].oversize_pkt_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].oversize_frag_cnt =
-				ptm_ds.ds_bg_mib[i].oversize_frag_cnt
-				+ ptm_us.ds_bg_mib[i].oversize_frag_cnt;
+				ptm_ds->ds_bg_mib[i].oversize_frag_cnt
+				+ ptm_us->ds_bg_mib[i].oversize_frag_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].oversize_byte_cnt =
-				ptm_ds.ds_bg_mib[i].oversize_byte_cnt
-				+ ptm_us.ds_bg_mib[i].oversize_byte_cnt;
+				ptm_ds->ds_bg_mib[i].oversize_byte_cnt
+				+ ptm_us->ds_bg_mib[i].oversize_byte_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].noncosec_pkt_cnt =
-				ptm_ds.ds_bg_mib[i].noncosec_pkt_cnt
-				+ ptm_us.ds_bg_mib[i].noncosec_pkt_cnt;
+				ptm_ds->ds_bg_mib[i].noncosec_pkt_cnt
+				+ ptm_us->ds_bg_mib[i].noncosec_pkt_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].noncosec_frag_cnt =
-				ptm_ds.ds_bg_mib[i].noncosec_frag_cnt
-				+ ptm_us.ds_bg_mib[i].noncosec_frag_cnt;
+				ptm_ds->ds_bg_mib[i].noncosec_frag_cnt
+				+ ptm_us->ds_bg_mib[i].noncosec_frag_cnt;
 			ptm_bonding_stats->ds_bg_mib[i].noncosec_byte_cnt =
-				ptm_ds.ds_bg_mib[i].noncosec_byte_cnt
-				+ ptm_us.ds_bg_mib[i].noncosec_byte_cnt;
+				ptm_ds->ds_bg_mib[i].noncosec_byte_cnt
+				+ ptm_us->ds_bg_mib[i].noncosec_byte_cnt;
 		}
+		kfree(ptm_us);
+free_ptm_ds:
+		kfree(ptm_ds);
 	}
-	return 0;
+free_rx_mib:
+	kfree(rx_mib);
+	return ret;
 }
 static int ptm_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {