Print this page
11493 aggr needs support for multiple pseudo rx groups
Portions contributed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/mac/mac_stat.c
+++ new/usr/src/uts/common/io/mac/mac_stat.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 + * Copyright 2018 Joyent, Inc.
24 25 */
25 26
26 27 /*
27 28 * MAC Services Module
28 29 */
29 30
30 31 #include <sys/types.h>
31 32 #include <sys/sysmacros.h>
32 33 #include <sys/stream.h>
33 34 #include <sys/kstat.h>
34 35 #include <sys/mac.h>
35 36 #include <sys/mac_impl.h>
36 37 #include <sys/mac_client_impl.h>
37 38 #include <sys/mac_stat.h>
38 39 #include <sys/mac_soft_ring.h>
39 40 #include <sys/vlan.h>
40 41
41 42 #define MAC_KSTAT_NAME "mac"
42 43 #define MAC_KSTAT_CLASS "net"
43 44
44 45 enum mac_stat {
45 46 MAC_STAT_LCL,
46 47 MAC_STAT_LCLBYTES,
47 48 MAC_STAT_INTRS,
48 49 MAC_STAT_INTRBYTES,
49 50 MAC_STAT_POLLS,
50 51 MAC_STAT_POLLBYTES,
51 52 MAC_STAT_RXSDROPS,
52 53 MAC_STAT_CHU10,
53 54 MAC_STAT_CH10T50,
54 55 MAC_STAT_CHO50,
55 56 MAC_STAT_BLOCK,
56 57 MAC_STAT_UNBLOCK,
57 58 MAC_STAT_TXSDROPS,
58 59 MAC_STAT_TX_ERRORS,
59 60 MAC_STAT_MACSPOOFED,
60 61 MAC_STAT_IPSPOOFED,
61 62 MAC_STAT_DHCPSPOOFED,
62 63 MAC_STAT_RESTRICTED,
63 64 MAC_STAT_DHCPDROPPED,
64 65 MAC_STAT_MULTIRCVBYTES,
65 66 MAC_STAT_BRDCSTRCVBYTES,
66 67 MAC_STAT_MULTIXMTBYTES,
67 68 MAC_STAT_BRDCSTXMTBYTES
68 69 };
69 70
70 71 static mac_stat_info_t i_mac_si[] = {
71 72 { MAC_STAT_IFSPEED, "ifspeed", KSTAT_DATA_UINT64, 0 },
72 73 { MAC_STAT_MULTIRCV, "multircv", KSTAT_DATA_UINT32, 0 },
73 74 { MAC_STAT_BRDCSTRCV, "brdcstrcv", KSTAT_DATA_UINT32, 0 },
74 75 { MAC_STAT_MULTIXMT, "multixmt", KSTAT_DATA_UINT32, 0 },
75 76 { MAC_STAT_BRDCSTXMT, "brdcstxmt", KSTAT_DATA_UINT32, 0 },
76 77 { MAC_STAT_NORCVBUF, "norcvbuf", KSTAT_DATA_UINT32, 0 },
77 78 { MAC_STAT_IERRORS, "ierrors", KSTAT_DATA_UINT32, 0 },
78 79 { MAC_STAT_UNKNOWNS, "unknowns", KSTAT_DATA_UINT32, 0 },
79 80 { MAC_STAT_NOXMTBUF, "noxmtbuf", KSTAT_DATA_UINT32, 0 },
80 81 { MAC_STAT_OERRORS, "oerrors", KSTAT_DATA_UINT32, 0 },
81 82 { MAC_STAT_COLLISIONS, "collisions", KSTAT_DATA_UINT32, 0 },
82 83 { MAC_STAT_UNDERFLOWS, "uflo", KSTAT_DATA_UINT32, 0 },
83 84 { MAC_STAT_OVERFLOWS, "oflo", KSTAT_DATA_UINT32, 0 },
84 85 { MAC_STAT_RBYTES, "rbytes", KSTAT_DATA_UINT32, 0 },
85 86 { MAC_STAT_IPACKETS, "ipackets", KSTAT_DATA_UINT32, 0 },
86 87 { MAC_STAT_OBYTES, "obytes", KSTAT_DATA_UINT32, 0 },
87 88 { MAC_STAT_OPACKETS, "opackets", KSTAT_DATA_UINT32, 0 },
88 89 { MAC_STAT_RBYTES, "rbytes64", KSTAT_DATA_UINT64, 0 },
89 90 { MAC_STAT_IPACKETS, "ipackets64", KSTAT_DATA_UINT64, 0 },
90 91 { MAC_STAT_OBYTES, "obytes64", KSTAT_DATA_UINT64, 0 },
91 92 { MAC_STAT_OPACKETS, "opackets64", KSTAT_DATA_UINT64, 0 }
92 93 };
93 94 #define MAC_NKSTAT \
94 95 (sizeof (i_mac_si) / sizeof (mac_stat_info_t))
95 96
96 97 static mac_stat_info_t i_mac_mod_si[] = {
97 98 { MAC_STAT_LINK_STATE, "link_state", KSTAT_DATA_UINT32,
98 99 (uint64_t)LINK_STATE_UNKNOWN },
99 100 { MAC_STAT_LINK_UP, "link_up", KSTAT_DATA_UINT32, 0 },
100 101 { MAC_STAT_PROMISC, "promisc", KSTAT_DATA_UINT32, 0 }
101 102 };
102 103 #define MAC_MOD_NKSTAT \
103 104 (sizeof (i_mac_mod_si) / sizeof (mac_stat_info_t))
104 105
105 106 #define MAC_MOD_KSTAT_OFFSET 0
106 107 #define MAC_KSTAT_OFFSET MAC_MOD_KSTAT_OFFSET + MAC_MOD_NKSTAT
107 108 #define MAC_TYPE_KSTAT_OFFSET MAC_KSTAT_OFFSET + MAC_NKSTAT
108 109
109 110 /*
110 111 * Definitions for per rx ring statistics
111 112 */
112 113 static mac_stat_info_t i_mac_rx_ring_si[] = {
113 114 { MAC_STAT_RBYTES, "rbytes", KSTAT_DATA_UINT64, 0},
114 115 { MAC_STAT_IPACKETS, "ipackets", KSTAT_DATA_UINT64, 0},
115 116 { MAC_STAT_HDROPS, "hdrops", KSTAT_DATA_UINT64, 0}
116 117 };
117 118 #define MAC_RX_RING_NKSTAT \
118 119 (sizeof (i_mac_rx_ring_si) / sizeof (mac_stat_info_t))
119 120
120 121 /*
121 122 * Definitions for per tx ring statistics
122 123 */
123 124 static mac_stat_info_t i_mac_tx_ring_si[] = {
124 125 { MAC_STAT_OBYTES, "obytes", KSTAT_DATA_UINT64, 0},
125 126 { MAC_STAT_OPACKETS, "opackets", KSTAT_DATA_UINT64, 0}
126 127 };
127 128 #define MAC_TX_RING_NKSTAT \
128 129 (sizeof (i_mac_tx_ring_si) / sizeof (mac_stat_info_t))
129 130
130 131
131 132 /*
132 133 * Definitions for per software lane tx statistics
133 134 */
134 135 static mac_stat_info_t i_mac_tx_swlane_si[] = {
135 136 { MAC_STAT_OBYTES, "obytes", KSTAT_DATA_UINT64, 0},
136 137 { MAC_STAT_OPACKETS, "opackets", KSTAT_DATA_UINT64, 0},
137 138 { MAC_STAT_OERRORS, "oerrors", KSTAT_DATA_UINT64, 0},
138 139 { MAC_STAT_BLOCK, "blockcnt", KSTAT_DATA_UINT64, 0},
139 140 { MAC_STAT_UNBLOCK, "unblockcnt", KSTAT_DATA_UINT64, 0},
140 141 { MAC_STAT_TXSDROPS, "txsdrops", KSTAT_DATA_UINT64, 0}
141 142 };
142 143 #define MAC_TX_SWLANE_NKSTAT \
143 144 (sizeof (i_mac_tx_swlane_si) / sizeof (mac_stat_info_t))
144 145
145 146 /*
146 147 * Definitions for per software lane rx statistics
147 148 */
148 149 static mac_stat_info_t i_mac_rx_swlane_si[] = {
149 150 { MAC_STAT_IPACKETS, "ipackets", KSTAT_DATA_UINT64, 0},
150 151 { MAC_STAT_RBYTES, "rbytes", KSTAT_DATA_UINT64, 0},
151 152 { MAC_STAT_LCL, "local", KSTAT_DATA_UINT64, 0},
152 153 { MAC_STAT_LCLBYTES, "localbytes", KSTAT_DATA_UINT64, 0},
153 154 { MAC_STAT_INTRS, "intrs", KSTAT_DATA_UINT64, 0},
154 155 { MAC_STAT_INTRBYTES, "intrbytes", KSTAT_DATA_UINT64, 0},
155 156 { MAC_STAT_RXSDROPS, "rxsdrops", KSTAT_DATA_UINT64, 0}
156 157 };
157 158 #define MAC_RX_SWLANE_NKSTAT \
158 159 (sizeof (i_mac_rx_swlane_si) / sizeof (mac_stat_info_t))
159 160
160 161 /*
161 162 * Definitions for per hardware lane rx statistics
162 163 */
163 164 static mac_stat_info_t i_mac_rx_hwlane_si[] = {
164 165 { MAC_STAT_IPACKETS, "ipackets", KSTAT_DATA_UINT64, 0},
165 166 { MAC_STAT_RBYTES, "rbytes", KSTAT_DATA_UINT64, 0},
166 167 { MAC_STAT_INTRS, "intrs", KSTAT_DATA_UINT64, 0},
167 168 { MAC_STAT_INTRBYTES, "intrbytes", KSTAT_DATA_UINT64, 0},
168 169 { MAC_STAT_POLLS, "polls", KSTAT_DATA_UINT64, 0},
169 170 { MAC_STAT_POLLBYTES, "pollbytes", KSTAT_DATA_UINT64, 0},
170 171 { MAC_STAT_RXSDROPS, "rxsdrops", KSTAT_DATA_UINT64, 0},
171 172 { MAC_STAT_CHU10, "chainunder10", KSTAT_DATA_UINT64, 0},
172 173 { MAC_STAT_CH10T50, "chain10to50", KSTAT_DATA_UINT64, 0},
173 174 { MAC_STAT_CHO50, "chainover50", KSTAT_DATA_UINT64, 0}
174 175 };
175 176 #define MAC_RX_HWLANE_NKSTAT \
176 177 (sizeof (i_mac_rx_hwlane_si) / sizeof (mac_stat_info_t))
177 178
178 179 /*
179 180 * Definitions for misc statistics
180 181 */
181 182 static mac_stat_info_t i_mac_misc_si[] = {
182 183 { MAC_STAT_MULTIRCV, "multircv", KSTAT_DATA_UINT64, 0},
183 184 { MAC_STAT_BRDCSTRCV, "brdcstrcv", KSTAT_DATA_UINT64, 0},
184 185 { MAC_STAT_MULTIXMT, "multixmt", KSTAT_DATA_UINT64, 0},
185 186 { MAC_STAT_BRDCSTXMT, "brdcstxmt", KSTAT_DATA_UINT64, 0},
186 187 { MAC_STAT_MULTIRCVBYTES, "multircvbytes", KSTAT_DATA_UINT64, 0},
187 188 { MAC_STAT_BRDCSTRCVBYTES, "brdcstrcvbytes", KSTAT_DATA_UINT64, 0},
188 189 { MAC_STAT_MULTIXMTBYTES, "multixmtbytes", KSTAT_DATA_UINT64, 0},
189 190 { MAC_STAT_BRDCSTXMTBYTES, "brdcstxmtbytes", KSTAT_DATA_UINT64, 0},
190 191 { MAC_STAT_TX_ERRORS, "txerrors", KSTAT_DATA_UINT64, 0},
191 192 { MAC_STAT_MACSPOOFED, "macspoofed", KSTAT_DATA_UINT64, 0},
192 193 { MAC_STAT_IPSPOOFED, "ipspoofed", KSTAT_DATA_UINT64, 0},
193 194 { MAC_STAT_DHCPSPOOFED, "dhcpspoofed", KSTAT_DATA_UINT64, 0},
194 195 { MAC_STAT_RESTRICTED, "restricted", KSTAT_DATA_UINT64, 0},
195 196 { MAC_STAT_DHCPDROPPED, "dhcpdropped", KSTAT_DATA_UINT64, 0},
196 197 { MAC_STAT_IPACKETS, "ipackets", KSTAT_DATA_UINT64, 0},
197 198 { MAC_STAT_RBYTES, "rbytes", KSTAT_DATA_UINT64, 0},
198 199 { MAC_STAT_LCL, "local", KSTAT_DATA_UINT64, 0},
199 200 { MAC_STAT_LCLBYTES, "localbytes", KSTAT_DATA_UINT64, 0},
200 201 { MAC_STAT_INTRS, "intrs", KSTAT_DATA_UINT64, 0},
201 202 { MAC_STAT_INTRBYTES, "intrbytes", KSTAT_DATA_UINT64, 0},
202 203 { MAC_STAT_POLLS, "polls", KSTAT_DATA_UINT64, 0},
203 204 { MAC_STAT_POLLBYTES, "pollbytes", KSTAT_DATA_UINT64, 0},
204 205 { MAC_STAT_RXSDROPS, "rxsdrops", KSTAT_DATA_UINT64, 0},
205 206 { MAC_STAT_CHU10, "chainunder10", KSTAT_DATA_UINT64, 0},
206 207 { MAC_STAT_CH10T50, "chain10to50", KSTAT_DATA_UINT64, 0},
207 208 { MAC_STAT_CHO50, "chainover50", KSTAT_DATA_UINT64, 0},
208 209 { MAC_STAT_OBYTES, "obytes", KSTAT_DATA_UINT64, 0},
209 210 { MAC_STAT_OPACKETS, "opackets", KSTAT_DATA_UINT64, 0},
210 211 { MAC_STAT_OERRORS, "oerrors", KSTAT_DATA_UINT64, 0},
211 212 { MAC_STAT_BLOCK, "blockcnt", KSTAT_DATA_UINT64, 0},
212 213 { MAC_STAT_UNBLOCK, "unblockcnt", KSTAT_DATA_UINT64, 0},
213 214 { MAC_STAT_TXSDROPS, "txsdrops", KSTAT_DATA_UINT64, 0}
214 215 };
215 216 #define MAC_SUMMARY_NKSTAT \
216 217 (sizeof (i_mac_misc_si) / sizeof (mac_stat_info_t))
217 218
218 219 /*
219 220 * Definitions for per hardware lane tx statistics
220 221 */
221 222 static mac_stat_info_t i_mac_tx_hwlane_si[] = {
222 223 { MAC_STAT_OBYTES, "obytes", KSTAT_DATA_UINT64, 0},
223 224 { MAC_STAT_OPACKETS, "opackets", KSTAT_DATA_UINT64, 0},
224 225 { MAC_STAT_OERRORS, "oerrors", KSTAT_DATA_UINT64, 0},
225 226 { MAC_STAT_BLOCK, "blockcnt", KSTAT_DATA_UINT64, 0},
226 227 { MAC_STAT_UNBLOCK, "unblockcnt", KSTAT_DATA_UINT64, 0},
227 228 { MAC_STAT_TXSDROPS, "txsdrops", KSTAT_DATA_UINT64, 0}
228 229 };
229 230 #define MAC_TX_HWLANE_NKSTAT \
230 231 (sizeof (i_mac_tx_hwlane_si) / sizeof (mac_stat_info_t))
231 232
232 233 /*
233 234 * Definitions for per fanout rx statistics
234 235 */
235 236 static mac_stat_info_t i_mac_rx_fanout_si[] = {
236 237 { MAC_STAT_RBYTES, "rbytes", KSTAT_DATA_UINT64, 0},
237 238 { MAC_STAT_IPACKETS, "ipackets", KSTAT_DATA_UINT64, 0},
238 239 };
239 240 #define MAC_RX_FANOUT_NKSTAT \
240 241 (sizeof (i_mac_rx_fanout_si) / sizeof (mac_stat_info_t))
241 242
242 243 /*
243 244 * Private functions.
244 245 */
245 246
246 247 typedef struct {
247 248 uint_t si_offset;
248 249 } stat_info_t;
249 250
250 251 #define RX_SRS_STAT_OFF(f) (offsetof(mac_rx_stats_t, f))
251 252 static stat_info_t rx_srs_stats_list[] = {
252 253 {RX_SRS_STAT_OFF(mrs_lclbytes)},
253 254 {RX_SRS_STAT_OFF(mrs_lclcnt)},
↓ open down ↓ |
220 lines elided |
↑ open up ↑ |
254 255 {RX_SRS_STAT_OFF(mrs_pollcnt)},
255 256 {RX_SRS_STAT_OFF(mrs_pollbytes)},
256 257 {RX_SRS_STAT_OFF(mrs_intrcnt)},
257 258 {RX_SRS_STAT_OFF(mrs_intrbytes)},
258 259 {RX_SRS_STAT_OFF(mrs_sdrops)},
259 260 {RX_SRS_STAT_OFF(mrs_chaincntundr10)},
260 261 {RX_SRS_STAT_OFF(mrs_chaincnt10to50)},
261 262 {RX_SRS_STAT_OFF(mrs_chaincntover50)},
262 263 {RX_SRS_STAT_OFF(mrs_ierrors)}
263 264 };
264 -#define RX_SRS_STAT_SIZE \
265 +#define RX_SRS_STAT_SIZE \
265 266 (sizeof (rx_srs_stats_list) / sizeof (stat_info_t))
266 267
267 268 #define TX_SOFTRING_STAT_OFF(f) (offsetof(mac_tx_stats_t, f))
268 269 static stat_info_t tx_softring_stats_list[] = {
269 270 {TX_SOFTRING_STAT_OFF(mts_obytes)},
270 271 {TX_SOFTRING_STAT_OFF(mts_opackets)},
271 272 {TX_SOFTRING_STAT_OFF(mts_oerrors)},
272 273 {TX_SOFTRING_STAT_OFF(mts_blockcnt)},
273 274 {TX_SOFTRING_STAT_OFF(mts_unblockcnt)},
274 275 {TX_SOFTRING_STAT_OFF(mts_sdrops)},
275 276 };
276 -#define TX_SOFTRING_STAT_SIZE \
277 +#define TX_SOFTRING_STAT_SIZE \
277 278 (sizeof (tx_softring_stats_list) / sizeof (stat_info_t))
278 279
279 280 static void
280 281 i_mac_add_stats(void *sum, void *op1, void *op2,
281 282 stat_info_t stats_list[], uint_t size)
282 283 {
283 - int i;
284 + int i;
284 285
285 286 for (i = 0; i < size; i++) {
286 287 uint64_t *op1_val = (uint64_t *)
287 288 ((uchar_t *)op1 + stats_list[i].si_offset);
288 289 uint64_t *op2_val = (uint64_t *)
289 290 ((uchar_t *)op2 + stats_list[i].si_offset);
290 291 uint64_t *sum_val = (uint64_t *)
291 292 ((uchar_t *)sum + stats_list[i].si_offset);
292 293
293 294 *sum_val = *op1_val + *op2_val;
294 295 }
295 296 }
296 297
297 298 static int
298 299 i_mac_driver_stat_update(kstat_t *ksp, int rw)
299 300 {
300 301 mac_impl_t *mip = ksp->ks_private;
301 302 kstat_named_t *knp = ksp->ks_data;
302 303 uint_t i;
303 304 uint64_t val;
304 305 mac_stat_info_t *msi;
305 306 uint_t msi_index;
306 307
307 308 if (rw != KSTAT_READ)
308 309 return (EACCES);
309 310
310 311 for (i = 0; i < mip->mi_kstat_count; i++, msi_index++) {
311 312 if (i == MAC_MOD_KSTAT_OFFSET) {
312 313 msi_index = 0;
313 314 msi = i_mac_mod_si;
314 315 } else if (i == MAC_KSTAT_OFFSET) {
315 316 msi_index = 0;
316 317 msi = i_mac_si;
317 318 } else if (i == MAC_TYPE_KSTAT_OFFSET) {
318 319 msi_index = 0;
319 320 msi = mip->mi_type->mt_stats;
320 321 }
321 322
322 323 val = mac_stat_get((mac_handle_t)mip, msi[msi_index].msi_stat);
323 324 switch (msi[msi_index].msi_type) {
324 325 case KSTAT_DATA_UINT64:
325 326 knp->value.ui64 = val;
326 327 break;
327 328 case KSTAT_DATA_UINT32:
328 329 knp->value.ui32 = (uint32_t)val;
329 330 break;
330 331 default:
331 332 ASSERT(B_FALSE);
332 333 break;
333 334 }
334 335
335 336 knp++;
336 337 }
337 338
338 339 return (0);
339 340 }
340 341
341 342 static void
342 343 i_mac_kstat_init(kstat_named_t *knp, mac_stat_info_t *si, uint_t count)
343 344 {
344 345 int i;
345 346 for (i = 0; i < count; i++) {
346 347 kstat_named_init(knp, si[i].msi_name, si[i].msi_type);
347 348 knp++;
348 349 }
349 350 }
350 351
351 352 static int
352 353 i_mac_stat_update(kstat_t *ksp, int rw, uint64_t (*fn)(void *, uint_t),
353 354 mac_stat_info_t *msi, uint_t count)
354 355 {
355 356 kstat_named_t *knp = ksp->ks_data;
356 357 uint_t i;
357 358 uint64_t val;
358 359
359 360 if (rw != KSTAT_READ)
360 361 return (EACCES);
361 362
362 363 for (i = 0; i < count; i++) {
363 364 val = fn(ksp->ks_private, msi[i].msi_stat);
364 365
365 366 switch (msi[i].msi_type) {
366 367 case KSTAT_DATA_UINT64:
367 368 knp->value.ui64 = val;
368 369 break;
369 370 case KSTAT_DATA_UINT32:
370 371 knp->value.ui32 = (uint32_t)val;
371 372 break;
372 373 default:
373 374 ASSERT(B_FALSE);
374 375 break;
375 376 }
376 377 knp++;
377 378 }
378 379 return (0);
379 380 }
380 381
381 382 /*
382 383 * Create kstat with given name - statname, update function - fn
383 384 * and initialize it with given names - init_stat_info
384 385 */
385 386 static kstat_t *
386 387 i_mac_stat_create(void *handle, const char *modname, const char *statname,
387 388 int (*fn) (kstat_t *, int),
388 389 mac_stat_info_t *init_stat_info, uint_t count)
389 390 {
390 391 kstat_t *ksp;
391 392 kstat_named_t *knp;
392 393
393 394 ksp = kstat_create(modname, 0, statname, "net",
394 395 KSTAT_TYPE_NAMED, count, 0);
395 396
396 397 if (ksp == NULL)
397 398 return (NULL);
398 399
399 400 ksp->ks_update = fn;
400 401 ksp->ks_private = handle;
401 402
402 403 knp = (kstat_named_t *)ksp->ks_data;
403 404 i_mac_kstat_init(knp, init_stat_info, count);
404 405 kstat_install(ksp);
405 406
406 407 return (ksp);
407 408 }
408 409
409 410 /*
410 411 * Per rx ring statistics
411 412 */
412 413 uint64_t
413 414 mac_rx_ring_stat_get(void *handle, uint_t stat)
414 415 {
415 416 mac_ring_t *ring = (mac_ring_t *)handle;
416 417 uint64_t val = 0;
417 418
418 419 /*
419 420 * XXX Every ring-capable driver must implement an entry point to
420 421 * query per ring statistics. CR 6893122 tracks this work item.
421 422 * Once this bug is fixed, the framework should fail registration
422 423 * for a driver that does not implement this entry point and
423 424 * assert ring->mr_stat != NULL here.
424 425 */
425 426 if (ring->mr_stat != NULL)
426 427 ring->mr_stat(ring->mr_driver, stat, &val);
427 428
428 429 return (val);
429 430 }
430 431
431 432 static int
432 433 i_mac_rx_ring_stat_update(kstat_t *ksp, int rw)
433 434 {
434 435 return (i_mac_stat_update(ksp, rw, mac_rx_ring_stat_get,
435 436 i_mac_rx_ring_si, MAC_RX_RING_NKSTAT));
436 437 }
437 438
438 439 static void
439 440 i_mac_rx_ring_stat_create(mac_ring_t *ring, const char *modname,
440 441 const char *statname)
441 442 {
442 443 kstat_t *ksp;
443 444
444 445 ksp = i_mac_stat_create(ring, modname, statname,
445 446 i_mac_rx_ring_stat_update, i_mac_rx_ring_si, MAC_RX_RING_NKSTAT);
446 447
447 448 ring->mr_ksp = ksp;
448 449 }
449 450
450 451 /*
451 452 * Per tx ring statistics
452 453 */
453 454 uint64_t
454 455 mac_tx_ring_stat_get(void *handle, uint_t stat)
455 456 {
456 457 mac_ring_t *ring = (mac_ring_t *)handle;
457 458 uint64_t val = 0;
458 459
459 460 /*
460 461 * XXX Every ring-capable driver must implement an entry point to
461 462 * query per ring statistics. CR 6893122 tracks this work item.
462 463 * Once this bug is fixed, the framework should fail registration
463 464 * for a driver that does not implement this entry point and
464 465 * assert ring->mr_stat != NULL here.
465 466 */
466 467 if (ring->mr_stat != NULL)
467 468 ring->mr_stat(ring->mr_driver, stat, &val);
468 469
469 470 return (val);
470 471 }
471 472
472 473 static int
473 474 i_mac_tx_ring_stat_update(kstat_t *ksp, int rw)
474 475 {
475 476 return (i_mac_stat_update(ksp, rw, mac_tx_ring_stat_get,
476 477 i_mac_tx_ring_si, MAC_TX_RING_NKSTAT));
477 478 }
478 479
479 480 static void
480 481 i_mac_tx_ring_stat_create(mac_ring_t *ring, const char *modname,
481 482 const char *statname)
482 483 {
483 484 kstat_t *ksp;
484 485
485 486 ksp = i_mac_stat_create(ring, modname, statname,
486 487 i_mac_tx_ring_stat_update, i_mac_tx_ring_si, MAC_TX_RING_NKSTAT);
487 488
488 489 ring->mr_ksp = ksp;
489 490 }
490 491
491 492 /*
492 493 * Per software lane tx statistics
493 494 */
494 495 static uint64_t
495 496 i_mac_tx_swlane_stat_get(void *handle, uint_t stat)
496 497 {
497 498 mac_soft_ring_set_t *mac_srs = (mac_soft_ring_set_t *)handle;
498 499 mac_tx_stats_t *mac_tx_stat = &mac_srs->srs_tx.st_stat;
499 500
500 501 switch (stat) {
501 502 case MAC_STAT_OBYTES:
502 503 return (mac_tx_stat->mts_obytes);
503 504
504 505 case MAC_STAT_OPACKETS:
505 506 return (mac_tx_stat->mts_opackets);
506 507
507 508 case MAC_STAT_OERRORS:
508 509 return (mac_tx_stat->mts_oerrors);
509 510
510 511 case MAC_STAT_BLOCK:
511 512 return (mac_tx_stat->mts_blockcnt);
512 513
513 514 case MAC_STAT_UNBLOCK:
514 515 return (mac_tx_stat->mts_unblockcnt);
515 516
516 517 case MAC_STAT_TXSDROPS:
517 518 return (mac_tx_stat->mts_sdrops);
518 519
519 520 default:
520 521 return (0);
521 522 }
522 523 }
523 524
524 525 static int
525 526 i_mac_tx_swlane_stat_update(kstat_t *ksp, int rw)
526 527 {
527 528 return (i_mac_stat_update(ksp, rw, i_mac_tx_swlane_stat_get,
528 529 i_mac_tx_swlane_si, MAC_TX_SWLANE_NKSTAT));
529 530 }
530 531
531 532 static void
532 533 i_mac_tx_swlane_stat_create(mac_soft_ring_set_t *mac_srs, const char *modname,
533 534 const char *statname)
534 535 {
535 536 kstat_t *ksp;
536 537
537 538 ksp = i_mac_stat_create(mac_srs, modname, statname,
538 539 i_mac_tx_swlane_stat_update, i_mac_tx_swlane_si,
539 540 MAC_TX_SWLANE_NKSTAT);
540 541
541 542 mac_srs->srs_ksp = ksp;
542 543 }
543 544
544 545 /*
545 546 * Per software lane rx statistics
546 547 */
547 548 static uint64_t
548 549 i_mac_rx_swlane_stat_get(void *handle, uint_t stat)
549 550 {
550 551 mac_soft_ring_set_t *mac_srs = (mac_soft_ring_set_t *)handle;
551 552 mac_rx_stats_t *mac_rx_stat = &mac_srs->srs_rx.sr_stat;
552 553
553 554 switch (stat) {
554 555 case MAC_STAT_IPACKETS:
555 556 return (mac_rx_stat->mrs_intrcnt +
556 557 mac_rx_stat->mrs_lclcnt);
557 558
558 559 case MAC_STAT_RBYTES:
559 560 return (mac_rx_stat->mrs_intrbytes +
560 561 mac_rx_stat->mrs_lclbytes);
561 562
562 563 case MAC_STAT_LCL:
563 564 return (mac_rx_stat->mrs_lclcnt);
564 565
565 566 case MAC_STAT_LCLBYTES:
566 567 return (mac_rx_stat->mrs_lclbytes);
567 568
568 569 case MAC_STAT_INTRS:
569 570 return (mac_rx_stat->mrs_intrcnt);
570 571
571 572 case MAC_STAT_INTRBYTES:
572 573 return (mac_rx_stat->mrs_intrbytes);
573 574
574 575 case MAC_STAT_RXSDROPS:
575 576 return (mac_rx_stat->mrs_sdrops);
576 577
577 578 default:
578 579 return (0);
579 580 }
580 581 }
581 582
582 583 static int
583 584 i_mac_rx_swlane_stat_update(kstat_t *ksp, int rw)
584 585 {
585 586 return (i_mac_stat_update(ksp, rw, i_mac_rx_swlane_stat_get,
586 587 i_mac_rx_swlane_si, MAC_RX_SWLANE_NKSTAT));
587 588 }
588 589
589 590 static void
590 591 i_mac_rx_swlane_stat_create(mac_soft_ring_set_t *mac_srs, const char *modname,
591 592 const char *statname)
592 593 {
593 594 kstat_t *ksp;
594 595
595 596 ksp = i_mac_stat_create(mac_srs, modname, statname,
596 597 i_mac_rx_swlane_stat_update, i_mac_rx_swlane_si,
597 598 MAC_RX_SWLANE_NKSTAT);
598 599
599 600 mac_srs->srs_ksp = ksp;
600 601 }
601 602
602 603
603 604 /*
604 605 * Per hardware lane rx statistics
605 606 */
606 607 static uint64_t
607 608 i_mac_rx_hwlane_stat_get(void *handle, uint_t stat)
608 609 {
609 610 mac_soft_ring_set_t *mac_srs = (mac_soft_ring_set_t *)handle;
610 611 mac_rx_stats_t *mac_rx_stat = &mac_srs->srs_rx.sr_stat;
611 612
612 613 switch (stat) {
613 614 case MAC_STAT_IPACKETS:
614 615 return (mac_rx_stat->mrs_intrcnt +
615 616 mac_rx_stat->mrs_pollcnt);
616 617
617 618 case MAC_STAT_RBYTES:
618 619 return (mac_rx_stat->mrs_intrbytes +
619 620 mac_rx_stat->mrs_pollbytes);
620 621
621 622 case MAC_STAT_INTRS:
622 623 return (mac_rx_stat->mrs_intrcnt);
623 624
624 625 case MAC_STAT_INTRBYTES:
625 626 return (mac_rx_stat->mrs_intrbytes);
626 627
627 628 case MAC_STAT_POLLS:
628 629 return (mac_rx_stat->mrs_pollcnt);
629 630
630 631 case MAC_STAT_POLLBYTES:
631 632 return (mac_rx_stat->mrs_pollbytes);
632 633
633 634 case MAC_STAT_RXSDROPS:
634 635 return (mac_rx_stat->mrs_sdrops);
635 636
636 637 case MAC_STAT_CHU10:
637 638 return (mac_rx_stat->mrs_chaincntundr10);
638 639
639 640 case MAC_STAT_CH10T50:
640 641 return (mac_rx_stat->mrs_chaincnt10to50);
641 642
642 643 case MAC_STAT_CHO50:
643 644 return (mac_rx_stat->mrs_chaincntover50);
644 645
645 646 default:
646 647 return (0);
647 648 }
648 649 }
649 650
650 651 static int
651 652 i_mac_rx_hwlane_stat_update(kstat_t *ksp, int rw)
652 653 {
653 654 return (i_mac_stat_update(ksp, rw, i_mac_rx_hwlane_stat_get,
654 655 i_mac_rx_hwlane_si, MAC_RX_HWLANE_NKSTAT));
655 656 }
656 657
657 658 static void
658 659 i_mac_rx_hwlane_stat_create(mac_soft_ring_set_t *mac_srs, const char *modname,
659 660 const char *statname)
660 661 {
661 662 kstat_t *ksp;
662 663
663 664 ksp = i_mac_stat_create(mac_srs, modname, statname,
664 665 i_mac_rx_hwlane_stat_update, i_mac_rx_hwlane_si,
665 666 MAC_RX_HWLANE_NKSTAT);
666 667
667 668 mac_srs->srs_ksp = ksp;
668 669 }
669 670
670 671
↓ open down ↓ |
377 lines elided |
↑ open up ↑ |
671 672 /*
672 673 * Misc statistics
673 674 *
674 675 * Counts for
675 676 * - Multicast/broadcast Rx/Tx counts
676 677 * - Tx errors
677 678 */
678 679 static uint64_t
679 680 i_mac_misc_stat_get(void *handle, uint_t stat)
680 681 {
681 - flow_entry_t *flent = handle;
682 - mac_client_impl_t *mcip = flent->fe_mcip;
682 + flow_entry_t *flent = handle;
683 + mac_client_impl_t *mcip = flent->fe_mcip;
683 684 mac_misc_stats_t *mac_misc_stat = &mcip->mci_misc_stat;
684 685 mac_rx_stats_t *mac_rx_stat;
685 686 mac_tx_stats_t *mac_tx_stat;
686 687
687 688 mac_rx_stat = &mac_misc_stat->mms_defunctrxlanestats;
688 689 mac_tx_stat = &mac_misc_stat->mms_defuncttxlanestats;
689 690
690 691 switch (stat) {
691 692 case MAC_STAT_MULTIRCV:
692 693 return (mac_misc_stat->mms_multircv);
693 694
694 695 case MAC_STAT_BRDCSTRCV:
695 696 return (mac_misc_stat->mms_brdcstrcv);
696 697
697 698 case MAC_STAT_MULTIXMT:
698 699 return (mac_misc_stat->mms_multixmt);
699 700
700 701 case MAC_STAT_BRDCSTXMT:
701 702 return (mac_misc_stat->mms_brdcstxmt);
702 703
703 704 case MAC_STAT_MULTIRCVBYTES:
704 705 return (mac_misc_stat->mms_multircvbytes);
705 706
706 707 case MAC_STAT_BRDCSTRCVBYTES:
707 708 return (mac_misc_stat->mms_brdcstrcvbytes);
708 709
709 710 case MAC_STAT_MULTIXMTBYTES:
710 711 return (mac_misc_stat->mms_multixmtbytes);
711 712
712 713 case MAC_STAT_BRDCSTXMTBYTES:
713 714 return (mac_misc_stat->mms_brdcstxmtbytes);
714 715
715 716 case MAC_STAT_TX_ERRORS:
716 717 return (mac_misc_stat->mms_txerrors);
717 718
718 719 case MAC_STAT_MACSPOOFED:
719 720 return (mac_misc_stat->mms_macspoofed);
720 721
721 722 case MAC_STAT_IPSPOOFED:
722 723 return (mac_misc_stat->mms_ipspoofed);
723 724
724 725 case MAC_STAT_DHCPSPOOFED:
725 726 return (mac_misc_stat->mms_dhcpspoofed);
726 727
727 728 case MAC_STAT_RESTRICTED:
728 729 return (mac_misc_stat->mms_restricted);
729 730
730 731 case MAC_STAT_DHCPDROPPED:
731 732 return (mac_misc_stat->mms_dhcpdropped);
732 733
733 734 case MAC_STAT_IPACKETS:
734 735 return (mac_rx_stat->mrs_intrcnt +
735 736 mac_rx_stat->mrs_pollcnt);
736 737
737 738 case MAC_STAT_RBYTES:
738 739 return (mac_rx_stat->mrs_intrbytes +
739 740 mac_rx_stat->mrs_pollbytes);
740 741
741 742 case MAC_STAT_LCL:
742 743 return (mac_rx_stat->mrs_lclcnt);
743 744
744 745 case MAC_STAT_LCLBYTES:
745 746 return (mac_rx_stat->mrs_lclbytes);
746 747
747 748 case MAC_STAT_INTRS:
748 749 return (mac_rx_stat->mrs_intrcnt);
749 750
750 751 case MAC_STAT_INTRBYTES:
751 752 return (mac_rx_stat->mrs_intrbytes);
752 753
753 754 case MAC_STAT_POLLS:
754 755 return (mac_rx_stat->mrs_pollcnt);
755 756
756 757 case MAC_STAT_POLLBYTES:
757 758 return (mac_rx_stat->mrs_pollbytes);
758 759
759 760 case MAC_STAT_RXSDROPS:
760 761 return (mac_rx_stat->mrs_sdrops);
761 762
762 763 case MAC_STAT_CHU10:
763 764 return (mac_rx_stat->mrs_chaincntundr10);
764 765
765 766 case MAC_STAT_CH10T50:
766 767 return (mac_rx_stat->mrs_chaincnt10to50);
767 768
768 769 case MAC_STAT_CHO50:
769 770 return (mac_rx_stat->mrs_chaincntover50);
770 771
771 772 case MAC_STAT_OBYTES:
772 773 return (mac_tx_stat->mts_obytes);
773 774
774 775 case MAC_STAT_OPACKETS:
775 776 return (mac_tx_stat->mts_opackets);
776 777
777 778 case MAC_STAT_OERRORS:
778 779 return (mac_tx_stat->mts_oerrors);
779 780
780 781 case MAC_STAT_BLOCK:
781 782 return (mac_tx_stat->mts_blockcnt);
782 783
783 784 case MAC_STAT_UNBLOCK:
784 785 return (mac_tx_stat->mts_unblockcnt);
785 786
786 787 case MAC_STAT_TXSDROPS:
787 788 return (mac_tx_stat->mts_sdrops);
788 789
789 790 default:
790 791 return (0);
791 792 }
792 793 }
793 794
794 795 static int
795 796 i_mac_misc_stat_update(kstat_t *ksp, int rw)
796 797 {
797 798 return (i_mac_stat_update(ksp, rw, i_mac_misc_stat_get,
798 799 i_mac_misc_si, MAC_SUMMARY_NKSTAT));
799 800 }
800 801
801 802 static void
802 803 i_mac_misc_stat_create(flow_entry_t *flent, const char *modname,
803 804 const char *statname)
804 805 {
805 806 kstat_t *ksp;
806 807
807 808 ksp = i_mac_stat_create(flent, modname, statname,
808 809 i_mac_misc_stat_update, i_mac_misc_si,
809 810 MAC_SUMMARY_NKSTAT);
810 811
811 812 flent->fe_misc_stat_ksp = ksp;
812 813 }
813 814
814 815 /*
815 816 * Per hardware lane tx statistics
816 817 */
817 818 static uint64_t
818 819 i_mac_tx_hwlane_stat_get(void *handle, uint_t stat)
819 820 {
820 821 mac_soft_ring_t *ringp = (mac_soft_ring_t *)handle;
821 822 mac_tx_stats_t *mac_tx_stat = &ringp->s_st_stat;
822 823
823 824 switch (stat) {
824 825 case MAC_STAT_OBYTES:
825 826 return (mac_tx_stat->mts_obytes);
826 827
827 828 case MAC_STAT_OPACKETS:
828 829 return (mac_tx_stat->mts_opackets);
829 830
830 831 case MAC_STAT_OERRORS:
831 832 return (mac_tx_stat->mts_oerrors);
832 833
833 834 case MAC_STAT_BLOCK:
834 835 return (mac_tx_stat->mts_blockcnt);
835 836
836 837 case MAC_STAT_UNBLOCK:
837 838 return (mac_tx_stat->mts_unblockcnt);
838 839
839 840 case MAC_STAT_TXSDROPS:
840 841 return (mac_tx_stat->mts_sdrops);
841 842
842 843 default:
843 844 return (0);
844 845 }
845 846 }
846 847
847 848 static int
848 849 i_mac_tx_hwlane_stat_update(kstat_t *ksp, int rw)
849 850 {
850 851 return (i_mac_stat_update(ksp, rw, i_mac_tx_hwlane_stat_get,
851 852 i_mac_tx_hwlane_si, MAC_TX_HWLANE_NKSTAT));
852 853 }
853 854
854 855 static void
855 856 i_mac_tx_hwlane_stat_create(mac_soft_ring_t *ringp, const char *modname,
856 857 const char *statname)
857 858 {
858 859 kstat_t *ksp;
859 860
860 861 ksp = i_mac_stat_create(ringp, modname, statname,
861 862 i_mac_tx_hwlane_stat_update, i_mac_tx_hwlane_si,
862 863 MAC_TX_HWLANE_NKSTAT);
↓ open down ↓ |
170 lines elided |
↑ open up ↑ |
863 864
864 865 ringp->s_ring_ksp = ksp;
865 866 }
866 867
867 868 /*
868 869 * Per fanout rx statistics
869 870 */
870 871 static uint64_t
871 872 i_mac_rx_fanout_stat_get(void *handle, uint_t stat)
872 873 {
873 - mac_soft_ring_t *tcp_ringp = (mac_soft_ring_t *)handle;
874 + mac_soft_ring_t *tcp_ringp = (mac_soft_ring_t *)handle;
874 875 mac_soft_ring_t *udp_ringp = NULL, *oth_ringp = NULL;
875 - mac_soft_ring_set_t *mac_srs = tcp_ringp->s_ring_set;
876 + mac_soft_ring_set_t *mac_srs = tcp_ringp->s_ring_set;
876 877 int index;
877 878 uint64_t val;
878 879
879 880 mutex_enter(&mac_srs->srs_lock);
880 881 /* Extract corresponding udp and oth ring pointers */
881 882 for (index = 0; mac_srs->srs_tcp_soft_rings[index] != NULL; index++) {
882 883 if (mac_srs->srs_tcp_soft_rings[index] == tcp_ringp) {
883 884 udp_ringp = mac_srs->srs_udp_soft_rings[index];
884 885 oth_ringp = mac_srs->srs_oth_soft_rings[index];
885 886 break;
886 887 }
887 888 }
888 889
889 890 ASSERT((udp_ringp != NULL) && (oth_ringp != NULL));
890 891
891 892 switch (stat) {
892 893 case MAC_STAT_RBYTES:
893 894 val = (tcp_ringp->s_ring_total_rbytes) +
894 895 (udp_ringp->s_ring_total_rbytes) +
895 896 (oth_ringp->s_ring_total_rbytes);
896 897 break;
897 898
898 899 case MAC_STAT_IPACKETS:
899 900 val = (tcp_ringp->s_ring_total_inpkt) +
900 901 (udp_ringp->s_ring_total_inpkt) +
901 902 (oth_ringp->s_ring_total_inpkt);
902 903 break;
903 904
904 905 default:
905 906 val = 0;
906 907 break;
907 908 }
908 909 mutex_exit(&mac_srs->srs_lock);
909 910 return (val);
910 911 }
911 912
912 913 static int
913 914 i_mac_rx_fanout_stat_update(kstat_t *ksp, int rw)
914 915 {
915 916 return (i_mac_stat_update(ksp, rw, i_mac_rx_fanout_stat_get,
916 917 i_mac_rx_fanout_si, MAC_RX_FANOUT_NKSTAT));
917 918 }
918 919
919 920 static void
920 921 i_mac_rx_fanout_stat_create(mac_soft_ring_t *ringp, const char *modname,
921 922 const char *statname)
922 923 {
923 924 kstat_t *ksp;
924 925
925 926 ksp = i_mac_stat_create(ringp, modname, statname,
926 927 i_mac_rx_fanout_stat_update, i_mac_rx_fanout_si,
927 928 MAC_RX_FANOUT_NKSTAT);
928 929
929 930 ringp->s_ring_ksp = ksp;
930 931 }
931 932
932 933 /*
933 934 * Exported functions.
934 935 */
935 936
936 937 /*
937 938 * Create the "mac" kstat. The "mac" kstat is comprised of three kinds of
938 939 * statistics: statistics maintained by the mac module itself, generic mac
939 940 * statistics maintained by the driver, and MAC-type specific statistics
940 941 * also maintained by the driver.
941 942 */
942 943 void
943 944 mac_driver_stat_create(mac_impl_t *mip)
944 945 {
945 946 kstat_t *ksp;
946 947 kstat_named_t *knp;
947 948 uint_t count;
948 949 major_t major = getmajor(mip->mi_phy_dev);
949 950
950 951 count = MAC_MOD_NKSTAT + MAC_NKSTAT + mip->mi_type->mt_statcount;
951 952 ksp = kstat_create((const char *)ddi_major_to_name(major),
952 953 getminor(mip->mi_phy_dev) - 1, MAC_KSTAT_NAME,
953 954 MAC_KSTAT_CLASS, KSTAT_TYPE_NAMED, count, 0);
954 955 if (ksp == NULL)
955 956 return;
956 957
957 958 ksp->ks_update = i_mac_driver_stat_update;
958 959 ksp->ks_private = mip;
959 960 mip->mi_ksp = ksp;
960 961 mip->mi_kstat_count = count;
961 962
962 963 knp = (kstat_named_t *)ksp->ks_data;
963 964 i_mac_kstat_init(knp, i_mac_mod_si, MAC_MOD_NKSTAT);
964 965 knp += MAC_MOD_NKSTAT;
965 966 i_mac_kstat_init(knp, i_mac_si, MAC_NKSTAT);
966 967 if (mip->mi_type->mt_statcount > 0) {
967 968 knp += MAC_NKSTAT;
968 969 i_mac_kstat_init(knp, mip->mi_type->mt_stats,
969 970 mip->mi_type->mt_statcount);
970 971 }
971 972
972 973 kstat_install(ksp);
973 974 }
974 975
975 976 /*ARGSUSED*/
976 977 void
977 978 mac_driver_stat_delete(mac_impl_t *mip)
978 979 {
979 980 if (mip->mi_ksp != NULL) {
980 981 kstat_delete(mip->mi_ksp);
981 982 mip->mi_ksp = NULL;
982 983 mip->mi_kstat_count = 0;
983 984 }
984 985 }
985 986
986 987 uint64_t
987 988 mac_driver_stat_default(mac_impl_t *mip, uint_t stat)
988 989 {
989 990 uint_t stat_index;
990 991
991 992 if (IS_MAC_STAT(stat)) {
992 993 stat_index = stat - MAC_STAT_MIN;
993 994 ASSERT(stat_index < MAC_NKSTAT);
994 995 return (i_mac_si[stat_index].msi_default);
995 996 }
↓ open down ↓ |
110 lines elided |
↑ open up ↑ |
996 997 ASSERT(IS_MACTYPE_STAT(stat));
997 998 stat_index = stat - MACTYPE_STAT_MIN;
998 999 ASSERT(stat_index < mip->mi_type->mt_statcount);
999 1000 return (mip->mi_type->mt_stats[stat_index].msi_default);
1000 1001 }
1001 1002
1002 1003 void
1003 1004 mac_ring_stat_create(mac_ring_t *ring)
1004 1005 {
1005 1006 mac_impl_t *mip = ring->mr_mip;
1007 + mac_group_t *grp = (mac_group_t *)ring->mr_gh;
1006 1008 char statname[MAXNAMELEN];
1007 1009 char modname[MAXNAMELEN];
1008 1010
1009 1011 if (mip->mi_state_flags & MIS_IS_AGGR) {
1010 1012 (void) strlcpy(modname, mip->mi_clients_list->mci_name,
1011 1013 MAXNAMELEN);
1012 1014 } else
1013 1015 (void) strlcpy(modname, mip->mi_name, MAXNAMELEN);
1014 1016
1015 1017 switch (ring->mr_type) {
1016 1018 case MAC_RING_TYPE_RX:
1017 - (void) snprintf(statname, sizeof (statname), "mac_rx_ring%d",
1018 - ring->mr_index);
1019 + (void) snprintf(statname, sizeof (statname),
1020 + "mac_rx_ring_%d_%d", grp->mrg_index, ring->mr_index);
1019 1021 i_mac_rx_ring_stat_create(ring, modname, statname);
1020 1022 break;
1021 1023
1022 1024 case MAC_RING_TYPE_TX:
1023 1025 (void) snprintf(statname, sizeof (statname), "mac_tx_ring%d",
1024 1026 ring->mr_index);
1025 1027 i_mac_tx_ring_stat_create(ring, modname, statname);
1026 1028 break;
1027 1029
1028 1030 default:
1029 1031 ASSERT(B_FALSE);
1030 1032 break;
1031 1033 }
1032 1034 }
1033 1035
1034 1036 void
1035 1037 mac_srs_stat_create(mac_soft_ring_set_t *mac_srs)
1036 1038 {
1037 1039 flow_entry_t *flent = mac_srs->srs_flent;
1038 - char statname[MAXNAMELEN];
1040 + char statname[MAXNAMELEN];
1039 1041 boolean_t is_tx_srs;
1040 1042
1041 1043 /* No hardware/software lanes for user defined flows */
1042 1044 if ((flent->fe_type & FLOW_USER) != 0)
1043 1045 return;
1044 1046
1045 1047 is_tx_srs = ((mac_srs->srs_type & SRST_TX) != 0);
1046 1048
1047 1049 if (is_tx_srs) {
1048 1050 mac_srs_tx_t *srs_tx = &mac_srs->srs_tx;
1049 1051 mac_ring_t *ring = srs_tx->st_arg2;
1050 1052
1051 1053 if (ring != NULL) {
1052 1054 (void) snprintf(statname, sizeof (statname),
1053 1055 "mac_tx_hwlane%d", ring->mr_index);
1054 1056 } else {
1055 1057 (void) snprintf(statname, sizeof (statname),
1056 1058 "mac_tx_swlane0");
1057 1059 }
1058 1060 i_mac_tx_swlane_stat_create(mac_srs, flent->fe_flow_name,
1059 1061 statname);
1060 1062 } else {
1061 1063 mac_ring_t *ring = mac_srs->srs_ring;
1062 1064
1063 1065 if (ring == NULL) {
1064 1066 (void) snprintf(statname, sizeof (statname),
1065 1067 "mac_rx_swlane0");
1066 1068 i_mac_rx_swlane_stat_create(mac_srs,
1067 1069 flent->fe_flow_name, statname);
1068 1070 } else {
1069 1071 (void) snprintf(statname, sizeof (statname),
1070 1072 "mac_rx_hwlane%d", ring->mr_index);
1071 1073 i_mac_rx_hwlane_stat_create(mac_srs,
1072 1074 flent->fe_flow_name, statname);
1073 1075 }
1074 1076 }
1075 1077 }
1076 1078
1077 1079 void
1078 1080 mac_misc_stat_create(flow_entry_t *flent)
1079 1081 {
1080 1082 char statname[MAXNAMELEN];
1081 1083
1082 1084 /* No misc stats for user defined or mcast/bcast flows */
1083 1085 if (((flent->fe_type & FLOW_USER) != 0) ||
1084 1086 ((flent->fe_type & FLOW_MCAST) != 0))
1085 1087 return;
1086 1088
1087 1089 (void) snprintf(statname, sizeof (statname), "mac_misc_stat");
1088 1090 i_mac_misc_stat_create(flent, flent->fe_flow_name, statname);
1089 1091 }
1090 1092
1091 1093 void
1092 1094 mac_soft_ring_stat_create(mac_soft_ring_t *ringp)
1093 1095 {
1094 1096 mac_soft_ring_set_t *mac_srs = ringp->s_ring_set;
1095 1097 flow_entry_t *flent = ringp->s_ring_mcip->mci_flent;
1096 1098 mac_ring_t *ring = (mac_ring_t *)ringp->s_ring_tx_arg2;
1097 1099 boolean_t is_tx_srs;
1098 1100 char statname[MAXNAMELEN];
1099 1101
1100 1102 /* No hardware/software lanes for user defined flows */
1101 1103 if ((flent->fe_type & FLOW_USER) != 0)
1102 1104 return;
1103 1105
1104 1106 is_tx_srs = ((mac_srs->srs_type & SRST_TX) != 0);
1105 1107 if (is_tx_srs) { /* tx side hardware lane */
1106 1108 ASSERT(ring != NULL);
1107 1109 (void) snprintf(statname, sizeof (statname), "mac_tx_hwlane%d",
1108 1110 ring->mr_index);
1109 1111 i_mac_tx_hwlane_stat_create(ringp, flent->fe_flow_name,
1110 1112 statname);
1111 1113 } else { /* rx side fanout */
1112 1114 /* Maintain single stat for (tcp, udp, oth) */
1113 1115 if (ringp->s_ring_type & ST_RING_TCP) {
1114 1116 int index;
1115 1117 mac_soft_ring_t *softring;
1116 1118
1117 1119 for (index = 0, softring = mac_srs->srs_soft_ring_head;
1118 1120 softring != NULL;
1119 1121 index++, softring = softring->s_ring_next) {
1120 1122 if (softring == ringp)
1121 1123 break;
1122 1124 }
1123 1125
1124 1126 if (mac_srs->srs_ring == NULL) {
1125 1127 (void) snprintf(statname, sizeof (statname),
1126 1128 "mac_rx_swlane0_fanout%d", index/3);
1127 1129 } else {
1128 1130 (void) snprintf(statname, sizeof (statname),
1129 1131 "mac_rx_hwlane%d_fanout%d",
1130 1132 mac_srs->srs_ring->mr_index, index/3);
1131 1133 }
1132 1134 i_mac_rx_fanout_stat_create(ringp, flent->fe_flow_name,
1133 1135 statname);
1134 1136 }
1135 1137 }
1136 1138 }
1137 1139
1138 1140 void
1139 1141 mac_ring_stat_delete(mac_ring_t *ring)
1140 1142 {
1141 1143 if (ring->mr_ksp != NULL) {
1142 1144 kstat_delete(ring->mr_ksp);
1143 1145 ring->mr_ksp = NULL;
1144 1146 }
1145 1147 }
1146 1148
1147 1149 void
1148 1150 mac_srs_stat_delete(mac_soft_ring_set_t *mac_srs)
1149 1151 {
1150 1152 boolean_t is_tx_srs;
1151 1153
1152 1154 is_tx_srs = ((mac_srs->srs_type & SRST_TX) != 0);
1153 1155 if (!is_tx_srs) {
1154 1156 /*
1155 1157 * Rx ring has been taken away. Before destroying corresponding
1156 1158 * SRS, save the stats recorded by that SRS.
1157 1159 */
1158 1160 mac_client_impl_t *mcip = mac_srs->srs_mcip;
1159 1161 mac_misc_stats_t *mac_misc_stat = &mcip->mci_misc_stat;
1160 1162 mac_rx_stats_t *mac_rx_stat = &mac_srs->srs_rx.sr_stat;
1161 1163
1162 1164 i_mac_add_stats(&mac_misc_stat->mms_defunctrxlanestats,
1163 1165 mac_rx_stat, &mac_misc_stat->mms_defunctrxlanestats,
1164 1166 rx_srs_stats_list, RX_SRS_STAT_SIZE);
1165 1167 }
1166 1168
1167 1169 if (mac_srs->srs_ksp != NULL) {
1168 1170 kstat_delete(mac_srs->srs_ksp);
1169 1171 mac_srs->srs_ksp = NULL;
1170 1172 }
1171 1173 }
1172 1174
1173 1175 void
1174 1176 mac_misc_stat_delete(flow_entry_t *flent)
1175 1177 {
1176 1178 if (flent->fe_misc_stat_ksp != NULL) {
1177 1179 kstat_delete(flent->fe_misc_stat_ksp);
1178 1180 flent->fe_misc_stat_ksp = NULL;
1179 1181 }
1180 1182 }
1181 1183
1182 1184 void
1183 1185 mac_soft_ring_stat_delete(mac_soft_ring_t *ringp)
1184 1186 {
1185 1187 mac_soft_ring_set_t *mac_srs = ringp->s_ring_set;
1186 1188 boolean_t is_tx_srs;
1187 1189
1188 1190 is_tx_srs = ((mac_srs->srs_type & SRST_TX) != 0);
1189 1191 if (is_tx_srs) {
1190 1192 /*
1191 1193 * Tx ring has been taken away. Before destroying corresponding
1192 1194 * soft ring, save the stats recorded by that soft ring.
1193 1195 */
1194 1196 mac_client_impl_t *mcip = mac_srs->srs_mcip;
1195 1197 mac_misc_stats_t *mac_misc_stat = &mcip->mci_misc_stat;
1196 1198 mac_tx_stats_t *mac_tx_stat = &ringp->s_st_stat;
1197 1199
1198 1200 i_mac_add_stats(&mac_misc_stat->mms_defuncttxlanestats,
1199 1201 mac_tx_stat, &mac_misc_stat->mms_defuncttxlanestats,
1200 1202 tx_softring_stats_list, TX_SOFTRING_STAT_SIZE);
1201 1203 }
1202 1204
1203 1205 if (ringp->s_ring_ksp) {
1204 1206 kstat_delete(ringp->s_ring_ksp);
1205 1207 ringp->s_ring_ksp = NULL;
1206 1208 }
1207 1209 }
1208 1210
1209 1211 void
1210 1212 mac_pseudo_ring_stat_rename(mac_impl_t *mip)
1211 1213 {
1212 1214 mac_group_t *group;
1213 1215 mac_ring_t *ring;
1214 1216
1215 1217 /* Recreate pseudo rx ring kstats */
1216 1218 for (group = mip->mi_rx_groups; group != NULL;
1217 1219 group = group->mrg_next) {
1218 1220 for (ring = group->mrg_rings; ring != NULL;
1219 1221 ring = ring->mr_next) {
1220 1222 mac_ring_stat_delete(ring);
1221 1223 mac_ring_stat_create(ring);
1222 1224 }
1223 1225 }
1224 1226
1225 1227 /* Recreate pseudo tx ring kstats */
1226 1228 for (group = mip->mi_tx_groups; group != NULL;
1227 1229 group = group->mrg_next) {
1228 1230 for (ring = group->mrg_rings; ring != NULL;
1229 1231 ring = ring->mr_next) {
1230 1232 mac_ring_stat_delete(ring);
1231 1233 mac_ring_stat_create(ring);
1232 1234 }
1233 1235 }
1234 1236 }
1235 1237
1236 1238 void
1237 1239 mac_stat_rename(mac_client_impl_t *mcip)
1238 1240 {
1239 1241 flow_entry_t *flent = mcip->mci_flent;
1240 1242 mac_soft_ring_set_t *mac_srs;
1241 1243 mac_soft_ring_t *ringp;
1242 1244 int i, j;
1243 1245
1244 1246 ASSERT(flent != NULL);
1245 1247
1246 1248 /* Recreate rx SRSes kstats */
1247 1249 for (i = 0; i < flent->fe_rx_srs_cnt; i++) {
1248 1250 mac_srs = (mac_soft_ring_set_t *)flent->fe_rx_srs[i];
1249 1251 mac_srs_stat_delete(mac_srs);
1250 1252 mac_srs_stat_create(mac_srs);
1251 1253
1252 1254 /* Recreate rx fanout kstats */
1253 1255 for (j = 0; j < mac_srs->srs_tcp_ring_count; j++) {
1254 1256 ringp = mac_srs->srs_tcp_soft_rings[j];
1255 1257 mac_soft_ring_stat_delete(ringp);
1256 1258 mac_soft_ring_stat_create(ringp);
1257 1259 }
1258 1260 }
1259 1261
1260 1262 /* Recreate tx SRS kstats */
1261 1263 mac_srs = (mac_soft_ring_set_t *)flent->fe_tx_srs;
1262 1264 mac_srs_stat_delete(mac_srs);
1263 1265 mac_srs_stat_create(mac_srs);
1264 1266
1265 1267 /* Recreate tx sofring kstats */
1266 1268 for (ringp = mac_srs->srs_soft_ring_head; ringp;
1267 1269 ringp = ringp->s_ring_next) {
1268 1270 mac_soft_ring_stat_delete(ringp);
1269 1271 mac_soft_ring_stat_create(ringp);
1270 1272 }
1271 1273
1272 1274 /* Recreate misc kstats */
1273 1275 mac_misc_stat_delete(flent);
1274 1276 mac_misc_stat_create(flent);
1275 1277 }
1276 1278
1277 1279 void
1278 1280 mac_tx_srs_stat_recreate(mac_soft_ring_set_t *tx_srs, boolean_t add_stats)
1279 1281 {
1280 1282 mac_client_impl_t *mcip = tx_srs->srs_mcip;
1281 1283 mac_misc_stats_t *mac_misc_stat = &mcip->mci_misc_stat;
1282 1284 mac_tx_stats_t *mac_tx_stat = &tx_srs->srs_tx.st_stat;
1283 1285
1284 1286 if (add_stats) {
1285 1287 /* Add the stats to cumulative stats */
1286 1288 i_mac_add_stats(&mac_misc_stat->mms_defuncttxlanestats,
1287 1289 mac_tx_stat, &mac_misc_stat->mms_defuncttxlanestats,
1288 1290 tx_softring_stats_list, TX_SOFTRING_STAT_SIZE);
1289 1291 }
1290 1292
1291 1293 bzero(mac_tx_stat, sizeof (mac_tx_stats_t));
1292 1294 mac_srs_stat_delete(tx_srs);
1293 1295 mac_srs_stat_create(tx_srs);
1294 1296 }
↓ open down ↓ |
246 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX