xref: /titanic_52/usr/src/uts/common/io/softmac/softmac_stat.c (revision ccdeb6b6d71f3c9aa7e78b688f7b34fff109a817)
1d62bc4baSyz147064 /*
2d62bc4baSyz147064  * CDDL HEADER START
3d62bc4baSyz147064  *
4d62bc4baSyz147064  * The contents of this file are subject to the terms of the
5d62bc4baSyz147064  * Common Development and Distribution License (the "License").
6d62bc4baSyz147064  * You may not use this file except in compliance with the License.
7d62bc4baSyz147064  *
8d62bc4baSyz147064  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9d62bc4baSyz147064  * or http://www.opensolaris.org/os/licensing.
10d62bc4baSyz147064  * See the License for the specific language governing permissions
11d62bc4baSyz147064  * and limitations under the License.
12d62bc4baSyz147064  *
13d62bc4baSyz147064  * When distributing Covered Code, include this CDDL HEADER in each
14d62bc4baSyz147064  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15d62bc4baSyz147064  * If applicable, add the following below this CDDL HEADER, with the
16d62bc4baSyz147064  * fields enclosed by brackets "[]" replaced with your own identifying
17d62bc4baSyz147064  * information: Portions Copyright [yyyy] [name of copyright owner]
18d62bc4baSyz147064  *
19d62bc4baSyz147064  * CDDL HEADER END
20d62bc4baSyz147064  */
21d62bc4baSyz147064 /*
22aca118b7Slucy wang - Sun Microsystems - Beijing China  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23d62bc4baSyz147064  * Use is subject to license terms.
243bc4925dSGarrett D'Amore  *
253bc4925dSGarrett D'Amore  * Copyright 2015 Garrett D'Amore <garret@damore.org>
26422542c1SRobert Mustacchi  * Copyright 2016 Joyent, Inc.
27d62bc4baSyz147064  */
28d62bc4baSyz147064 
29d62bc4baSyz147064 #include <sys/types.h>
30d62bc4baSyz147064 #include <sys/kstat.h>
31d62bc4baSyz147064 #include <sys/mac.h>
32d62bc4baSyz147064 #include <sys/dls.h>
33d62bc4baSyz147064 #include <sys/softmac_impl.h>
34d62bc4baSyz147064 
35d62bc4baSyz147064 typedef struct i_softmac_stat_info_s {
36d62bc4baSyz147064 	uint_t		ssi_stat;
37d62bc4baSyz147064 	char		*ssi_name;
38d62bc4baSyz147064 	char		*ssi_alias;
39d62bc4baSyz147064 } i_softmac_stat_info_t;
40d62bc4baSyz147064 
41d62bc4baSyz147064 /*
42d62bc4baSyz147064  * Must be the same order as mac_driver_stat.
43d62bc4baSyz147064  */
44d62bc4baSyz147064 static i_softmac_stat_info_t	i_softmac_driver_si[] = {
45d62bc4baSyz147064 	{ MAC_STAT_IFSPEED,	"ifspeed",	"link_speed"	},
46d62bc4baSyz147064 	{ MAC_STAT_MULTIRCV,	"multircv",	NULL		},
47d62bc4baSyz147064 	{ MAC_STAT_BRDCSTRCV,	"brdcstrcv",	NULL		},
48d62bc4baSyz147064 	{ MAC_STAT_MULTIXMT,	"multixmt",	NULL		},
49d62bc4baSyz147064 	{ MAC_STAT_BRDCSTXMT,	"brdcstxmt",	NULL		},
50d62bc4baSyz147064 	{ MAC_STAT_NORCVBUF,	"norcvbuf",	"rx_no_buf"	},
51d62bc4baSyz147064 	{ MAC_STAT_IERRORS,	"ierrors",	NULL		},
52d62bc4baSyz147064 	{ MAC_STAT_UNKNOWNS,	"unknowns",	NULL		},
53d62bc4baSyz147064 	{ MAC_STAT_NOXMTBUF,	"noxmtbuf",	"No Txpkt "	},
54d62bc4baSyz147064 	{ MAC_STAT_OERRORS,	"oerrors",	NULL		},
55d62bc4baSyz147064 	{ MAC_STAT_COLLISIONS,	"collisions",	NULL		},
56d62bc4baSyz147064 	{ MAC_STAT_RBYTES,	"rbytes64",	"rbytes"	},
57d62bc4baSyz147064 	{ MAC_STAT_IPACKETS,	"ipackets64",	"ipackets"	},
58d62bc4baSyz147064 	{ MAC_STAT_OBYTES,	"obytes64",	"obytes"	},
59d62bc4baSyz147064 	{ MAC_STAT_OPACKETS,	"opackets64",	"opackets"	},
60d62bc4baSyz147064 	{ MAC_STAT_UNDERFLOWS,	"uflo",		NULL		},
61d62bc4baSyz147064 	{ MAC_STAT_OVERFLOWS,	"oflo",		NULL		}
62d62bc4baSyz147064 };
63d62bc4baSyz147064 
64aca118b7Slucy wang - Sun Microsystems - Beijing China #define	SOFTMAC_DRIVER_SI_SZ						\
65aca118b7Slucy wang - Sun Microsystems - Beijing China 	(sizeof (i_softmac_driver_si) / sizeof (i_softmac_driver_si[0]))
66aca118b7Slucy wang - Sun Microsystems - Beijing China 
67d62bc4baSyz147064 /*
68d62bc4baSyz147064  * Must be the same order as ether_stat.
69d62bc4baSyz147064  */
70d62bc4baSyz147064 static i_softmac_stat_info_t	i_softmac_ether_si[] = {
71d62bc4baSyz147064 	{ ETHER_STAT_ALIGN_ERRORS,	"align_errors",
72d62bc4baSyz147064 	    "alignment_err" },
73d62bc4baSyz147064 	{ ETHER_STAT_FCS_ERRORS,	"fcs_errors",		"crc_err" },
74d62bc4baSyz147064 	{ ETHER_STAT_FIRST_COLLISIONS,	"first_collisions",	NULL },
75d62bc4baSyz147064 	{ ETHER_STAT_MULTI_COLLISIONS,	"multi_collisions",	NULL },
76d62bc4baSyz147064 	{ ETHER_STAT_SQE_ERRORS,	"sqe_errors",		NULL },
77d62bc4baSyz147064 	{ ETHER_STAT_DEFER_XMTS,	"defer_xmts",		NULL },
78d62bc4baSyz147064 	{ ETHER_STAT_TX_LATE_COLLISIONS, "tx_late_collisions",
79d62bc4baSyz147064 	    "late_collisions" },
80d62bc4baSyz147064 	{ ETHER_STAT_EX_COLLISIONS,	"ex_collisions",
81d62bc4baSyz147064 	    "excessive_collisions" },
82d62bc4baSyz147064 	{ ETHER_STAT_MACXMT_ERRORS,	"macxmt_errors",	NULL },
83d62bc4baSyz147064 	{ ETHER_STAT_CARRIER_ERRORS,	"carrier_errors",	NULL },
84d62bc4baSyz147064 	{ ETHER_STAT_TOOLONG_ERRORS,	"toolong_errors",	"length_err" },
85d62bc4baSyz147064 	{ ETHER_STAT_MACRCV_ERRORS,	"macrcv_errors",
86d62bc4baSyz147064 	    "Rx Error Count" },
87d62bc4baSyz147064 
88d62bc4baSyz147064 	{ ETHER_STAT_XCVR_ADDR,		"xcvr_addr",		NULL },
89d62bc4baSyz147064 	{ ETHER_STAT_XCVR_ID,		"xcvr_id",		NULL },
90d62bc4baSyz147064 	{ ETHER_STAT_XCVR_INUSE,	"xcvr_inuse",		NULL },
91d62bc4baSyz147064 
92d62bc4baSyz147064 	{ ETHER_STAT_CAP_1000FDX,	"cap_1000fdx",		NULL },
93d62bc4baSyz147064 	{ ETHER_STAT_CAP_1000HDX,	"cap_1000hdx",		NULL },
94d62bc4baSyz147064 	{ ETHER_STAT_CAP_100FDX,	"cap_100fdx",		NULL },
95d62bc4baSyz147064 	{ ETHER_STAT_CAP_100HDX,	"cap_100hdx",		NULL },
96d62bc4baSyz147064 	{ ETHER_STAT_CAP_10FDX,		"cap_10fdx",		NULL },
97d62bc4baSyz147064 	{ ETHER_STAT_CAP_10HDX,		"cap_10hdx",		NULL },
98d62bc4baSyz147064 	{ ETHER_STAT_CAP_ASMPAUSE,	"cap_asmpause",		NULL },
99d62bc4baSyz147064 	{ ETHER_STAT_CAP_PAUSE,		"cap_pause",		NULL },
100d62bc4baSyz147064 	{ ETHER_STAT_CAP_AUTONEG,	"cap_autoneg",		NULL },
101d62bc4baSyz147064 
102d62bc4baSyz147064 	{ ETHER_STAT_ADV_CAP_1000FDX,	"adv_cap_1000fdx",	NULL },
103d62bc4baSyz147064 	{ ETHER_STAT_ADV_CAP_1000HDX,	"adv_cap_1000hdx",	NULL },
104d62bc4baSyz147064 	{ ETHER_STAT_ADV_CAP_100FDX,	"adv_cap_100fdx",	NULL },
105d62bc4baSyz147064 	{ ETHER_STAT_ADV_CAP_100HDX,	"adv_cap_100hdx",	NULL },
106d62bc4baSyz147064 	{ ETHER_STAT_ADV_CAP_10FDX,	"adv_cap_10fdx",	NULL },
107d62bc4baSyz147064 	{ ETHER_STAT_ADV_CAP_10HDX,	"adv_cap_10hdx",	NULL },
108d62bc4baSyz147064 	{ ETHER_STAT_ADV_CAP_ASMPAUSE,	"adv_cap_asmpause",	NULL },
109d62bc4baSyz147064 	{ ETHER_STAT_ADV_CAP_PAUSE,	"adv_cap_pause",	NULL },
110d62bc4baSyz147064 	{ ETHER_STAT_ADV_CAP_AUTONEG,	"adv_cap_autoneg",	NULL },
111d62bc4baSyz147064 
112d62bc4baSyz147064 	{ ETHER_STAT_LP_CAP_1000FDX,	"lp_cap_1000fdx",	NULL },
113d62bc4baSyz147064 	{ ETHER_STAT_LP_CAP_1000HDX,	"lp_cap_1000hdx",	NULL },
114d62bc4baSyz147064 	{ ETHER_STAT_LP_CAP_100FDX,	"lp_cap_100fdx",	NULL },
115d62bc4baSyz147064 	{ ETHER_STAT_LP_CAP_100HDX,	"lp_cap_100hdx",	NULL },
116d62bc4baSyz147064 	{ ETHER_STAT_LP_CAP_10FDX,	"lp_cap_10fdx",		NULL },
117d62bc4baSyz147064 	{ ETHER_STAT_LP_CAP_10HDX,	"lp_cap_10hdx",		NULL },
118d62bc4baSyz147064 	{ ETHER_STAT_LP_CAP_ASMPAUSE,	"lp_cap_asmpause",	NULL },
119d62bc4baSyz147064 	{ ETHER_STAT_LP_CAP_PAUSE,	"lp_cap_pause",		NULL },
120d62bc4baSyz147064 	{ ETHER_STAT_LP_CAP_AUTONEG,	"lp_cap_autoneg",	NULL },
121d62bc4baSyz147064 
122d62bc4baSyz147064 	{ ETHER_STAT_LINK_ASMPAUSE,	"link_asmpause",	NULL },
123d62bc4baSyz147064 	{ ETHER_STAT_LINK_PAUSE,	"link_pause",		NULL },
124d62bc4baSyz147064 	{ ETHER_STAT_LINK_AUTONEG,	"link_autoneg",		NULL },
125d62bc4baSyz147064 	{ ETHER_STAT_LINK_DUPLEX,	"link_duplex",		"duplex" },
126d62bc4baSyz147064 
127d62bc4baSyz147064 	{ ETHER_STAT_TOOSHORT_ERRORS,	"runt_errors",		NULL },
128d62bc4baSyz147064 	{ ETHER_STAT_CAP_REMFAULT,	"cap_rem_fault",	NULL },
129d62bc4baSyz147064 	{ ETHER_STAT_ADV_REMFAULT,	"adv_rem_fault",	NULL },
130d62bc4baSyz147064 	{ ETHER_STAT_LP_REMFAULT,	"lp_rem_fault",		NULL },
131d62bc4baSyz147064 
132d62bc4baSyz147064 	{ ETHER_STAT_JABBER_ERRORS,	"jabber_errors",	NULL },
133d62bc4baSyz147064 	{ ETHER_STAT_CAP_100T4,		"cap_100T4",		NULL },
134d62bc4baSyz147064 	{ ETHER_STAT_ADV_CAP_100T4,	"adv_cap_100T4",	NULL },
135aca118b7Slucy wang - Sun Microsystems - Beijing China 	{ ETHER_STAT_LP_CAP_100T4,	"lp_cap_100T4",		NULL },
136aca118b7Slucy wang - Sun Microsystems - Beijing China 
137aca118b7Slucy wang - Sun Microsystems - Beijing China 	{ ETHER_STAT_CAP_10GFDX,	"cap_10gfdx",		NULL },
138aca118b7Slucy wang - Sun Microsystems - Beijing China 	{ ETHER_STAT_ADV_CAP_10GFDX,	"adv_cap_10gfdx",	NULL },
1393bc4925dSGarrett D'Amore 	{ ETHER_STAT_LP_CAP_1000FDX,	"lp_cap_10gfdx",	NULL },
1403bc4925dSGarrett D'Amore 
1413bc4925dSGarrett D'Amore 	{ ETHER_STAT_CAP_40GFDX,	"cap_40gfdx",		NULL },
1423bc4925dSGarrett D'Amore 	{ ETHER_STAT_ADV_CAP_40GFDX,	"adv_cap_40gfdx",	NULL },
1433bc4925dSGarrett D'Amore 	{ ETHER_STAT_LP_CAP_40GFDX,	"lp_cap_40gfdx",	NULL },
1443bc4925dSGarrett D'Amore 
1453bc4925dSGarrett D'Amore 	{ ETHER_STAT_CAP_100GFDX,	"cap_100gfdx",		NULL },
1463bc4925dSGarrett D'Amore 	{ ETHER_STAT_ADV_CAP_100GFDX,	"adv_cap_100gfdx",	NULL },
1473bc4925dSGarrett D'Amore 	{ ETHER_STAT_LP_CAP_100GFDX,	"lp_cap_100gfdx",	NULL },
1483bc4925dSGarrett D'Amore 
1493bc4925dSGarrett D'Amore 	{ ETHER_STAT_CAP_2500FDX,	"cap_2500fdx",		NULL },
1503bc4925dSGarrett D'Amore 	{ ETHER_STAT_ADV_CAP_2500FDX,	"adv_cap_2500fdx",	NULL },
1513bc4925dSGarrett D'Amore 	{ ETHER_STAT_LP_CAP_2500FDX,	"lp_cap_2500fdx",	NULL },
1523bc4925dSGarrett D'Amore 
1533bc4925dSGarrett D'Amore 	{ ETHER_STAT_CAP_5000FDX,	"cap_5000fdx",		NULL },
1543bc4925dSGarrett D'Amore 	{ ETHER_STAT_ADV_CAP_5000FDX,	"adv_cap_5000fdx",	NULL },
1553bc4925dSGarrett D'Amore 	{ ETHER_STAT_LP_CAP_5000FDX,	"lp_cap_5000fdx",	NULL },
156422542c1SRobert Mustacchi 
157422542c1SRobert Mustacchi 	{ ETHER_STAT_CAP_25GFDX,	"cap_25gfdx",		NULL },
158422542c1SRobert Mustacchi 	{ ETHER_STAT_ADV_CAP_25GFDX,	"adv_cap_25gfdx",	NULL },
159422542c1SRobert Mustacchi 	{ ETHER_STAT_LP_CAP_25GFDX,	"lp_cap_25gfdx",	NULL },
160422542c1SRobert Mustacchi 
161422542c1SRobert Mustacchi 	{ ETHER_STAT_CAP_50GFDX,	"cap_50gfdx",		NULL },
162422542c1SRobert Mustacchi 	{ ETHER_STAT_ADV_CAP_50GFDX,	"adv_cap_50gfdx",	NULL },
163422542c1SRobert Mustacchi 	{ ETHER_STAT_LP_CAP_50GFDX,	"lp_cap_50gfdx",	NULL },
164d62bc4baSyz147064 };
165d62bc4baSyz147064 
166aca118b7Slucy wang - Sun Microsystems - Beijing China #define	SOFTMAC_ETHER_SI_SZ						\
167aca118b7Slucy wang - Sun Microsystems - Beijing China 	(sizeof (i_softmac_ether_si) / sizeof (i_softmac_ether_si[0]))
168aca118b7Slucy wang - Sun Microsystems - Beijing China 
169d62bc4baSyz147064 static kstat_t	*softmac_hold_dev_kstat(softmac_t *);
170d62bc4baSyz147064 static void	softmac_rele_dev_kstat(kstat_t *);
171d62bc4baSyz147064 static int	softmac_get_kstat(kstat_t *, char *, uint64_t *);
172d62bc4baSyz147064 
173d62bc4baSyz147064 static kstat_t *
174d62bc4baSyz147064 softmac_hold_dev_kstat(softmac_t *softmac)
175d62bc4baSyz147064 {
176d62bc4baSyz147064 	char		drv[MAXLINKNAMELEN];
177d62bc4baSyz147064 	uint_t		ppa;
178d62bc4baSyz147064 	kstat_t		*ksp;
179d62bc4baSyz147064 
180*ccdeb6b6SDan McDonald 	if (ddi_parse_dlen(softmac->smac_devname, drv, MAXLINKNAMELEN, &ppa) !=
181*ccdeb6b6SDan McDonald 	    DDI_SUCCESS) {
182d62bc4baSyz147064 		return (NULL);
183*ccdeb6b6SDan McDonald 	}
184d62bc4baSyz147064 
185d62bc4baSyz147064 	/*
186d62bc4baSyz147064 	 * Find the kstat by the module name and the instance number.
187d62bc4baSyz147064 	 */
188d62bc4baSyz147064 	ksp = kstat_hold_byname(drv, ppa, softmac->smac_devname, ALL_ZONES);
189d62bc4baSyz147064 	if (ksp != NULL) {
190d62bc4baSyz147064 		KSTAT_ENTER(ksp);
191d62bc4baSyz147064 
192d62bc4baSyz147064 		if ((ksp->ks_data != NULL) &&
193d62bc4baSyz147064 		    (ksp->ks_type == KSTAT_TYPE_NAMED)) {
194d62bc4baSyz147064 			/*
195d62bc4baSyz147064 			 * Update the kstat to get the latest statistics.
196d62bc4baSyz147064 			 */
197d62bc4baSyz147064 			if (KSTAT_UPDATE(ksp, KSTAT_READ) == 0)
198d62bc4baSyz147064 				return (ksp);
199d62bc4baSyz147064 		}
200d62bc4baSyz147064 
201d62bc4baSyz147064 		KSTAT_EXIT(ksp);
202d62bc4baSyz147064 		kstat_rele(ksp);
203d62bc4baSyz147064 	}
204d62bc4baSyz147064 	return (NULL);
205d62bc4baSyz147064 }
206d62bc4baSyz147064 
207d62bc4baSyz147064 static void
208d62bc4baSyz147064 softmac_rele_dev_kstat(kstat_t *ksp)
209d62bc4baSyz147064 {
210d62bc4baSyz147064 	KSTAT_EXIT(ksp);
211d62bc4baSyz147064 	kstat_rele(ksp);
212d62bc4baSyz147064 }
213d62bc4baSyz147064 
214d62bc4baSyz147064 /*
215d62bc4baSyz147064  * The kstat needs to be held when calling this function.
216d62bc4baSyz147064  */
217d62bc4baSyz147064 static int
218d62bc4baSyz147064 softmac_get_kstat(kstat_t *ksp, char *name, uint64_t *valp)
219d62bc4baSyz147064 {
220d62bc4baSyz147064 	kstat_named_t	*knp;
221d62bc4baSyz147064 	int		i;
222d62bc4baSyz147064 	int		ret = ENOTSUP;
223d62bc4baSyz147064 
224d62bc4baSyz147064 	if (name == NULL)
225d62bc4baSyz147064 		return (ret);
226d62bc4baSyz147064 
227d62bc4baSyz147064 	/*
228d62bc4baSyz147064 	 * Search the kstat with the given name.
229d62bc4baSyz147064 	 */
230d62bc4baSyz147064 	for (i = 0, knp = KSTAT_NAMED_PTR(ksp); i < ksp->ks_ndata; i++, knp++) {
231d62bc4baSyz147064 		if (strcmp(knp->name, name) == 0) {
232d62bc4baSyz147064 			switch (knp->data_type) {
233d62bc4baSyz147064 			case KSTAT_DATA_INT32:
234d62bc4baSyz147064 			case KSTAT_DATA_UINT32:
235d62bc4baSyz147064 				*valp = (uint64_t)(knp->value.ui32);
236d62bc4baSyz147064 				ret = 0;
237d62bc4baSyz147064 				break;
238d62bc4baSyz147064 			case KSTAT_DATA_INT64:
239d62bc4baSyz147064 			case KSTAT_DATA_UINT64:
240d62bc4baSyz147064 				*valp = knp->value.ui64;
241d62bc4baSyz147064 				ret = 0;
242d62bc4baSyz147064 				break;
243d62bc4baSyz147064 #ifdef _LP64
244d62bc4baSyz147064 			case KSTAT_DATA_LONG:
245d62bc4baSyz147064 			case KSTAT_DATA_ULONG:
246d62bc4baSyz147064 				*valp = (uint64_t)knp->value.ul;
247d62bc4baSyz147064 				ret = 0;
248d62bc4baSyz147064 				break;
249d62bc4baSyz147064 #endif
250d62bc4baSyz147064 			case KSTAT_DATA_CHAR:
251d62bc4baSyz147064 				if (strcmp(name, "duplex") != 0)
252d62bc4baSyz147064 					break;
253d62bc4baSyz147064 				if (strncmp(knp->value.c, "full", 4) == 0)
254d62bc4baSyz147064 					*valp = LINK_DUPLEX_FULL;
255d62bc4baSyz147064 				else if (strncmp(knp->value.c, "half", 4) == 0)
256d62bc4baSyz147064 					*valp = LINK_DUPLEX_HALF;
257d62bc4baSyz147064 				else
258d62bc4baSyz147064 					*valp = LINK_DUPLEX_UNKNOWN;
259d62bc4baSyz147064 				ret = 0;
260d62bc4baSyz147064 				break;
261d62bc4baSyz147064 			}
262d62bc4baSyz147064 			break;
263d62bc4baSyz147064 		}
264d62bc4baSyz147064 	}
265d62bc4baSyz147064 
266d62bc4baSyz147064 	return (ret);
267d62bc4baSyz147064 }
268d62bc4baSyz147064 
269d62bc4baSyz147064 int
270d62bc4baSyz147064 softmac_m_stat(void *arg, uint_t stat, uint64_t *val)
271d62bc4baSyz147064 {
272d62bc4baSyz147064 	softmac_t	*softmac = arg;
273d62bc4baSyz147064 	kstat_t		*ksp;
274d62bc4baSyz147064 	uint_t		index;
275d62bc4baSyz147064 	int		ret;
276d62bc4baSyz147064 
277d62bc4baSyz147064 	if ((ksp = softmac_hold_dev_kstat(softmac)) == NULL)
278d62bc4baSyz147064 		return (ENOTSUP);
279d62bc4baSyz147064 
280d62bc4baSyz147064 	if (IS_MAC_STAT(stat)) {
281aca118b7Slucy wang - Sun Microsystems - Beijing China 		i_softmac_stat_info_t *ssip = NULL;
282aca118b7Slucy wang - Sun Microsystems - Beijing China 
283aca118b7Slucy wang - Sun Microsystems - Beijing China 		for (index = 0; index < SOFTMAC_DRIVER_SI_SZ; index++) {
284aca118b7Slucy wang - Sun Microsystems - Beijing China 			if (stat == i_softmac_driver_si[index].ssi_stat) {
285aca118b7Slucy wang - Sun Microsystems - Beijing China 				ssip = &i_softmac_driver_si[index];
286aca118b7Slucy wang - Sun Microsystems - Beijing China 				break;
287aca118b7Slucy wang - Sun Microsystems - Beijing China 			}
288aca118b7Slucy wang - Sun Microsystems - Beijing China 		}
289aca118b7Slucy wang - Sun Microsystems - Beijing China 
290aca118b7Slucy wang - Sun Microsystems - Beijing China 		if (ssip == NULL) {
291aca118b7Slucy wang - Sun Microsystems - Beijing China 			ret = ENOTSUP;
292aca118b7Slucy wang - Sun Microsystems - Beijing China 		} else {
293aca118b7Slucy wang - Sun Microsystems - Beijing China 			if ((ret = softmac_get_kstat(ksp, ssip->ssi_name,
294aca118b7Slucy wang - Sun Microsystems - Beijing China 			    val)) != 0)
295aca118b7Slucy wang - Sun Microsystems - Beijing China 				ret = softmac_get_kstat(ksp, ssip->ssi_alias,
296aca118b7Slucy wang - Sun Microsystems - Beijing China 				    val);
297d62bc4baSyz147064 		}
298d62bc4baSyz147064 	} else {
299d62bc4baSyz147064 		ASSERT(IS_MACTYPE_STAT(stat));
300d62bc4baSyz147064 
301d62bc4baSyz147064 		switch (softmac->smac_media) {
302aca118b7Slucy wang - Sun Microsystems - Beijing China 		case DL_ETHER: {
303aca118b7Slucy wang - Sun Microsystems - Beijing China 			i_softmac_stat_info_t *ssip = NULL;
304aca118b7Slucy wang - Sun Microsystems - Beijing China 
305aca118b7Slucy wang - Sun Microsystems - Beijing China 			for (index = 0; index < SOFTMAC_ETHER_SI_SZ; index++) {
306aca118b7Slucy wang - Sun Microsystems - Beijing China 				if (stat ==
307aca118b7Slucy wang - Sun Microsystems - Beijing China 				    i_softmac_ether_si[index].ssi_stat) {
308aca118b7Slucy wang - Sun Microsystems - Beijing China 					ssip = &i_softmac_ether_si[index];
309d62bc4baSyz147064 					break;
310aca118b7Slucy wang - Sun Microsystems - Beijing China 				}
311aca118b7Slucy wang - Sun Microsystems - Beijing China 			}
312aca118b7Slucy wang - Sun Microsystems - Beijing China 
313aca118b7Slucy wang - Sun Microsystems - Beijing China 			if (ssip == NULL) {
314aca118b7Slucy wang - Sun Microsystems - Beijing China 				ret = ENOTSUP;
315aca118b7Slucy wang - Sun Microsystems - Beijing China 			} else {
316aca118b7Slucy wang - Sun Microsystems - Beijing China 				if ((ret = softmac_get_kstat(ksp,
317aca118b7Slucy wang - Sun Microsystems - Beijing China 				    ssip->ssi_name, val)) != 0)
318aca118b7Slucy wang - Sun Microsystems - Beijing China 					ret = softmac_get_kstat(ksp,
319aca118b7Slucy wang - Sun Microsystems - Beijing China 					    ssip->ssi_alias, val);
320aca118b7Slucy wang - Sun Microsystems - Beijing China 			}
321aca118b7Slucy wang - Sun Microsystems - Beijing China 
322aca118b7Slucy wang - Sun Microsystems - Beijing China 			break;
323aca118b7Slucy wang - Sun Microsystems - Beijing China 		}
324d62bc4baSyz147064 		default:
325d62bc4baSyz147064 			ret = ENOTSUP;
326d62bc4baSyz147064 			break;
327d62bc4baSyz147064 		}
328d62bc4baSyz147064 	}
329d62bc4baSyz147064 
330d62bc4baSyz147064 	softmac_rele_dev_kstat(ksp);
331d62bc4baSyz147064 	return (ret);
332d62bc4baSyz147064 }
333