xref: /illumos-gate/usr/src/uts/common/io/igb/igb_gld.c (revision 42b53e0f)
1c869993eSxy /*
2c869993eSxy  * CDDL HEADER START
3c869993eSxy  *
4c869993eSxy  * The contents of this file are subject to the terms of the
5c869993eSxy  * Common Development and Distribution License (the "License").
6c869993eSxy  * You may not use this file except in compliance with the License.
7c869993eSxy  *
8da14cebeSEric Cheng  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da14cebeSEric Cheng  * or http://www.opensolaris.org/os/licensing.
10c869993eSxy  * See the License for the specific language governing permissions
11c869993eSxy  * and limitations under the License.
12c869993eSxy  *
13da14cebeSEric Cheng  * When distributing Covered Code, include this CDDL HEADER in each
14da14cebeSEric Cheng  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15c869993eSxy  * If applicable, add the following below this CDDL HEADER, with the
16c869993eSxy  * fields enclosed by brackets "[]" replaced with your own identifying
17c869993eSxy  * information: Portions Copyright [yyyy] [name of copyright owner]
18c869993eSxy  *
19c869993eSxy  * CDDL HEADER END
20c869993eSxy  */
21c869993eSxy 
22c869993eSxy /*
2369b2d733SGuoqing Zhu  * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
24c869993eSxy  */
25c869993eSxy 
26da14cebeSEric Cheng /*
2769b2d733SGuoqing Zhu  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2843ae5505SDan McDonald  * Copyright 2013, Nexenta Systems, Inc. All rights reserved.
2913485e69SGarrett D'Amore  * Copyright 2014 Pluribus Networks Inc.
30238d8f47SDale Ghent  * Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
31c1e9c696SRobert Mustacchi  * Copyright (c) 2017, Joyent, Inc.
32*42b53e0fSRobert Mustacchi  * Copyright 2023 Oxide Computer Company
33da14cebeSEric Cheng  */
34c869993eSxy 
35c869993eSxy #include "igb_sw.h"
36c869993eSxy 
37c869993eSxy int
igb_m_stat(void * arg,uint_t stat,uint64_t * val)38c869993eSxy igb_m_stat(void *arg, uint_t stat, uint64_t *val)
39c869993eSxy {
40c869993eSxy 	igb_t *igb = (igb_t *)arg;
41c869993eSxy 	struct e1000_hw *hw = &igb->hw;
42c869993eSxy 	igb_stat_t *igb_ks;
43c869993eSxy 	uint32_t low_val, high_val;
44c869993eSxy 
45c869993eSxy 	igb_ks = (igb_stat_t *)igb->igb_ks->ks_data;
46c869993eSxy 
47c869993eSxy 	mutex_enter(&igb->gen_lock);
48c869993eSxy 
49c869993eSxy 	if (igb->igb_state & IGB_SUSPENDED) {
50c869993eSxy 		mutex_exit(&igb->gen_lock);
51c869993eSxy 		return (ECANCELED);
52c869993eSxy 	}
53c869993eSxy 
54c869993eSxy 	switch (stat) {
55c869993eSxy 	case MAC_STAT_IFSPEED:
56c869993eSxy 		*val = igb->link_speed * 1000000ull;
57c869993eSxy 		break;
58c869993eSxy 
59c869993eSxy 	case MAC_STAT_MULTIRCV:
6013485e69SGarrett D'Amore 		igb->stat_mprc += E1000_READ_REG(hw, E1000_MPRC);
6113485e69SGarrett D'Amore 		*val = igb->stat_mprc;
62c869993eSxy 		break;
63c869993eSxy 
64c869993eSxy 	case MAC_STAT_BRDCSTRCV:
6513485e69SGarrett D'Amore 		igb->stat_bprc += E1000_READ_REG(hw, E1000_BPRC);
6613485e69SGarrett D'Amore 		*val = igb->stat_bprc;
67c869993eSxy 		break;
68c869993eSxy 
69c869993eSxy 	case MAC_STAT_MULTIXMT:
7013485e69SGarrett D'Amore 		igb->stat_mptc += E1000_READ_REG(hw, E1000_MPTC);
7113485e69SGarrett D'Amore 		*val = igb->stat_mptc;
72c869993eSxy 		break;
73c869993eSxy 
74c869993eSxy 	case MAC_STAT_BRDCSTXMT:
7513485e69SGarrett D'Amore 		igb->stat_bptc += E1000_READ_REG(hw, E1000_BPTC);
7613485e69SGarrett D'Amore 		*val = igb->stat_bptc;
77c869993eSxy 		break;
78c869993eSxy 
79c869993eSxy 	case MAC_STAT_NORCVBUF:
8013485e69SGarrett D'Amore 		igb->stat_rnbc += E1000_READ_REG(hw, E1000_RNBC);
8113485e69SGarrett D'Amore 		*val = igb->stat_rnbc;
82c869993eSxy 		break;
83c869993eSxy 
84c869993eSxy 	case MAC_STAT_IERRORS:
8513485e69SGarrett D'Amore 		igb->stat_rxerrc += E1000_READ_REG(hw, E1000_RXERRC);
8613485e69SGarrett D'Amore 		igb->stat_algnerrc += E1000_READ_REG(hw, E1000_ALGNERRC);
87c869993eSxy 		igb_ks->rlec.value.ui64 +=
88c869993eSxy 		    E1000_READ_REG(hw, E1000_RLEC);
8913485e69SGarrett D'Amore 		igb->stat_crcerrs += E1000_READ_REG(hw, E1000_CRCERRS);
9013485e69SGarrett D'Amore 		igb->stat_cexterr += E1000_READ_REG(hw, E1000_CEXTERR);
9113485e69SGarrett D'Amore 		*val = igb->stat_rxerrc +
9213485e69SGarrett D'Amore 		    igb->stat_algnerrc +
93c869993eSxy 		    igb_ks->rlec.value.ui64 +
9413485e69SGarrett D'Amore 		    igb->stat_crcerrs +
9513485e69SGarrett D'Amore 		    igb->stat_cexterr;
96c869993eSxy 		break;
97c869993eSxy 
98c869993eSxy 	case MAC_STAT_NOXMTBUF:
99c869993eSxy 		*val = 0;
100c869993eSxy 		break;
101c869993eSxy 
102c869993eSxy 	case MAC_STAT_OERRORS:
10313485e69SGarrett D'Amore 		igb->stat_ecol += E1000_READ_REG(hw, E1000_ECOL);
10413485e69SGarrett D'Amore 		*val = igb->stat_ecol;
105c869993eSxy 		break;
106c869993eSxy 
107c869993eSxy 	case MAC_STAT_COLLISIONS:
10813485e69SGarrett D'Amore 		igb->stat_colc += E1000_READ_REG(hw, E1000_COLC);
10913485e69SGarrett D'Amore 		*val = igb->stat_colc;
110c869993eSxy 		break;
111c869993eSxy 
112c869993eSxy 	case MAC_STAT_RBYTES:
113c869993eSxy 		/*
114c869993eSxy 		 * The 64-bit register will reset whenever the upper
115c869993eSxy 		 * 32 bits are read. So we need to read the lower
116c869993eSxy 		 * 32 bits first, then read the upper 32 bits.
117c869993eSxy 		 */
118c869993eSxy 		low_val = E1000_READ_REG(hw, E1000_TORL);
119c869993eSxy 		high_val = E1000_READ_REG(hw, E1000_TORH);
12013485e69SGarrett D'Amore 		igb->stat_tor += (uint64_t)high_val << 32 | (uint64_t)low_val;
12113485e69SGarrett D'Amore 		*val = igb->stat_tor;
122c869993eSxy 		break;
123c869993eSxy 
124c869993eSxy 	case MAC_STAT_IPACKETS:
12513485e69SGarrett D'Amore 		igb->stat_tpr += E1000_READ_REG(hw, E1000_TPR);
12613485e69SGarrett D'Amore 		*val = igb->stat_tpr;
127c869993eSxy 		break;
128c869993eSxy 
129c869993eSxy 	case MAC_STAT_OBYTES:
130c869993eSxy 		/*
131c869993eSxy 		 * The 64-bit register will reset whenever the upper
132c869993eSxy 		 * 32 bits are read. So we need to read the lower
133c869993eSxy 		 * 32 bits first, then read the upper 32 bits.
134c869993eSxy 		 */
135c869993eSxy 		low_val = E1000_READ_REG(hw, E1000_TOTL);
136c869993eSxy 		high_val = E1000_READ_REG(hw, E1000_TOTH);
13713485e69SGarrett D'Amore 		igb->stat_tot += (uint64_t)high_val << 32 | (uint64_t)low_val;
13813485e69SGarrett D'Amore 		*val = igb->stat_tot;
139c869993eSxy 		break;
140c869993eSxy 
141c869993eSxy 	case MAC_STAT_OPACKETS:
14213485e69SGarrett D'Amore 		igb->stat_tpt += E1000_READ_REG(hw, E1000_TPT);
14313485e69SGarrett D'Amore 		*val = igb->stat_tpt;
144c869993eSxy 		break;
145c869993eSxy 
146c869993eSxy 	/* RFC 1643 stats */
147c869993eSxy 	case ETHER_STAT_ALIGN_ERRORS:
14813485e69SGarrett D'Amore 		igb->stat_algnerrc += E1000_READ_REG(hw, E1000_ALGNERRC);
14913485e69SGarrett D'Amore 		*val = igb->stat_algnerrc;
150c869993eSxy 		break;
151c869993eSxy 
152c869993eSxy 	case ETHER_STAT_FCS_ERRORS:
15313485e69SGarrett D'Amore 		igb->stat_crcerrs += E1000_READ_REG(hw, E1000_CRCERRS);
15413485e69SGarrett D'Amore 		*val = igb->stat_crcerrs;
155c869993eSxy 		break;
156c869993eSxy 
157c869993eSxy 	case ETHER_STAT_FIRST_COLLISIONS:
15813485e69SGarrett D'Amore 		igb->stat_scc += E1000_READ_REG(hw, E1000_SCC);
15913485e69SGarrett D'Amore 		*val = igb->stat_scc;
160c869993eSxy 		break;
161c869993eSxy 
162c869993eSxy 	case ETHER_STAT_MULTI_COLLISIONS:
16313485e69SGarrett D'Amore 		igb->stat_mcc += E1000_READ_REG(hw, E1000_MCC);
16413485e69SGarrett D'Amore 		*val = igb->stat_mcc;
165c869993eSxy 		break;
166c869993eSxy 
167c869993eSxy 	case ETHER_STAT_SQE_ERRORS:
16813485e69SGarrett D'Amore 		igb->stat_sec += E1000_READ_REG(hw, E1000_SEC);
16913485e69SGarrett D'Amore 		*val = igb->stat_sec;
170c869993eSxy 		break;
171c869993eSxy 
172c869993eSxy 	case ETHER_STAT_DEFER_XMTS:
17313485e69SGarrett D'Amore 		igb->stat_dc += E1000_READ_REG(hw, E1000_DC);
17413485e69SGarrett D'Amore 		*val = igb->stat_dc;
175c869993eSxy 		break;
176c869993eSxy 
177c869993eSxy 	case ETHER_STAT_TX_LATE_COLLISIONS:
17813485e69SGarrett D'Amore 		igb->stat_latecol += E1000_READ_REG(hw, E1000_LATECOL);
17913485e69SGarrett D'Amore 		*val = igb->stat_latecol;
180c869993eSxy 		break;
181c869993eSxy 
182c869993eSxy 	case ETHER_STAT_EX_COLLISIONS:
18313485e69SGarrett D'Amore 		igb->stat_ecol += E1000_READ_REG(hw, E1000_ECOL);
18413485e69SGarrett D'Amore 		*val = igb->stat_ecol;
185c869993eSxy 		break;
186c869993eSxy 
187c869993eSxy 	case ETHER_STAT_MACXMT_ERRORS:
18813485e69SGarrett D'Amore 		igb->stat_ecol += E1000_READ_REG(hw, E1000_ECOL);
18913485e69SGarrett D'Amore 		*val = igb->stat_ecol;
190c869993eSxy 		break;
191c869993eSxy 
192c869993eSxy 	case ETHER_STAT_CARRIER_ERRORS:
19313485e69SGarrett D'Amore 		igb->stat_cexterr += E1000_READ_REG(hw, E1000_CEXTERR);
19413485e69SGarrett D'Amore 		*val = igb->stat_cexterr;
195c869993eSxy 		break;
196c869993eSxy 
197c869993eSxy 	case ETHER_STAT_TOOLONG_ERRORS:
19813485e69SGarrett D'Amore 		igb->stat_roc += E1000_READ_REG(hw, E1000_ROC);
19913485e69SGarrett D'Amore 		*val = igb->stat_roc;
200c869993eSxy 		break;
201c869993eSxy 
202c869993eSxy 	case ETHER_STAT_MACRCV_ERRORS:
20313485e69SGarrett D'Amore 		igb->stat_rxerrc += E1000_READ_REG(hw, E1000_RXERRC);
20413485e69SGarrett D'Amore 		*val = igb->stat_rxerrc;
205c869993eSxy 		break;
206c869993eSxy 
207c869993eSxy 	/* MII/GMII stats */
208c869993eSxy 	case ETHER_STAT_XCVR_ADDR:
209*42b53e0fSRobert Mustacchi 		*val = hw->phy.addr;
210c869993eSxy 		break;
211c869993eSxy 
212c869993eSxy 	case ETHER_STAT_XCVR_ID:
213c869993eSxy 		*val = hw->phy.id | hw->phy.revision;
214c869993eSxy 		break;
215c869993eSxy 
216c869993eSxy 	case ETHER_STAT_XCVR_INUSE:
217*42b53e0fSRobert Mustacchi 		*val = (uint64_t)e1000_link_to_media(hw, igb->link_speed);
218c869993eSxy 		break;
219c869993eSxy 
220c869993eSxy 	case ETHER_STAT_CAP_1000FDX:
221c869993eSxy 		*val = igb->param_1000fdx_cap;
222c869993eSxy 		break;
223c869993eSxy 
224c869993eSxy 	case ETHER_STAT_CAP_1000HDX:
225c869993eSxy 		*val = igb->param_1000hdx_cap;
226c869993eSxy 		break;
227c869993eSxy 
228c869993eSxy 	case ETHER_STAT_CAP_100FDX:
229c869993eSxy 		*val = igb->param_100fdx_cap;
230c869993eSxy 		break;
231c869993eSxy 
232c869993eSxy 	case ETHER_STAT_CAP_100HDX:
233c869993eSxy 		*val = igb->param_100hdx_cap;
234c869993eSxy 		break;
235c869993eSxy 
236c869993eSxy 	case ETHER_STAT_CAP_10FDX:
237c869993eSxy 		*val = igb->param_10fdx_cap;
238c869993eSxy 		break;
239c869993eSxy 
240c869993eSxy 	case ETHER_STAT_CAP_10HDX:
241c869993eSxy 		*val = igb->param_10hdx_cap;
242c869993eSxy 		break;
243c869993eSxy 
244c869993eSxy 	case ETHER_STAT_CAP_ASMPAUSE:
245c869993eSxy 		*val = igb->param_asym_pause_cap;
246c869993eSxy 		break;
247c869993eSxy 
248c869993eSxy 	case ETHER_STAT_CAP_PAUSE:
249c869993eSxy 		*val = igb->param_pause_cap;
250c869993eSxy 		break;
251c869993eSxy 
252c869993eSxy 	case ETHER_STAT_CAP_AUTONEG:
253c869993eSxy 		*val = igb->param_autoneg_cap;
254c869993eSxy 		break;
255c869993eSxy 
256c869993eSxy 	case ETHER_STAT_ADV_CAP_1000FDX:
257c869993eSxy 		*val = igb->param_adv_1000fdx_cap;
258c869993eSxy 		break;
259c869993eSxy 
260c869993eSxy 	case ETHER_STAT_ADV_CAP_1000HDX:
261c869993eSxy 		*val = igb->param_adv_1000hdx_cap;
262c869993eSxy 		break;
263c869993eSxy 
264c869993eSxy 	case ETHER_STAT_ADV_CAP_100FDX:
265c869993eSxy 		*val = igb->param_adv_100fdx_cap;
266c869993eSxy 		break;
267c869993eSxy 
268c869993eSxy 	case ETHER_STAT_ADV_CAP_100HDX:
269c869993eSxy 		*val = igb->param_adv_100hdx_cap;
270c869993eSxy 		break;
271c869993eSxy 
272c869993eSxy 	case ETHER_STAT_ADV_CAP_10FDX:
273c869993eSxy 		*val = igb->param_adv_10fdx_cap;
274c869993eSxy 		break;
275c869993eSxy 
276c869993eSxy 	case ETHER_STAT_ADV_CAP_10HDX:
277c869993eSxy 		*val = igb->param_adv_10hdx_cap;
278c869993eSxy 		break;
279c869993eSxy 
280c869993eSxy 	case ETHER_STAT_ADV_CAP_ASMPAUSE:
281c869993eSxy 		*val = igb->param_adv_asym_pause_cap;
282c869993eSxy 		break;
283c869993eSxy 
284c869993eSxy 	case ETHER_STAT_ADV_CAP_PAUSE:
285c869993eSxy 		*val = igb->param_adv_pause_cap;
286c869993eSxy 		break;
287c869993eSxy 
288c869993eSxy 	case ETHER_STAT_ADV_CAP_AUTONEG:
289c869993eSxy 		*val = hw->mac.autoneg;
290c869993eSxy 		break;
291c869993eSxy 
292c869993eSxy 	case ETHER_STAT_LP_CAP_1000FDX:
293c869993eSxy 		*val = igb->param_lp_1000fdx_cap;
294c869993eSxy 		break;
295c869993eSxy 
296c869993eSxy 	case ETHER_STAT_LP_CAP_1000HDX:
297c869993eSxy 		*val = igb->param_lp_1000hdx_cap;
298c869993eSxy 		break;
299c869993eSxy 
300c869993eSxy 	case ETHER_STAT_LP_CAP_100FDX:
301c869993eSxy 		*val = igb->param_lp_100fdx_cap;
302c869993eSxy 		break;
303c869993eSxy 
304c869993eSxy 	case ETHER_STAT_LP_CAP_100HDX:
305c869993eSxy 		*val = igb->param_lp_100hdx_cap;
306c869993eSxy 		break;
307c869993eSxy 
308c869993eSxy 	case ETHER_STAT_LP_CAP_10FDX:
309c869993eSxy 		*val = igb->param_lp_10fdx_cap;
310c869993eSxy 		break;
311c869993eSxy 
312c869993eSxy 	case ETHER_STAT_LP_CAP_10HDX:
313c869993eSxy 		*val = igb->param_lp_10hdx_cap;
314c869993eSxy 		break;
315c869993eSxy 
316c869993eSxy 	case ETHER_STAT_LP_CAP_ASMPAUSE:
317c869993eSxy 		*val = igb->param_lp_asym_pause_cap;
318c869993eSxy 		break;
319c869993eSxy 
320c869993eSxy 	case ETHER_STAT_LP_CAP_PAUSE:
321c869993eSxy 		*val = igb->param_lp_pause_cap;
322c869993eSxy 		break;
323c869993eSxy 
324c869993eSxy 	case ETHER_STAT_LP_CAP_AUTONEG:
325c869993eSxy 		*val = igb->param_lp_autoneg_cap;
326c869993eSxy 		break;
327c869993eSxy 
328c869993eSxy 	case ETHER_STAT_LINK_ASMPAUSE:
329c869993eSxy 		*val = igb->param_asym_pause_cap;
330c869993eSxy 		break;
331c869993eSxy 
332c869993eSxy 	case ETHER_STAT_LINK_PAUSE:
333c869993eSxy 		*val = igb->param_pause_cap;
334c869993eSxy 		break;
335c869993eSxy 
336c869993eSxy 	case ETHER_STAT_LINK_AUTONEG:
337c869993eSxy 		*val = hw->mac.autoneg;
338c869993eSxy 		break;
339c869993eSxy 
340c869993eSxy 	case ETHER_STAT_LINK_DUPLEX:
341c869993eSxy 		*val = (igb->link_duplex == FULL_DUPLEX) ?
342c869993eSxy 		    LINK_DUPLEX_FULL : LINK_DUPLEX_HALF;
343c869993eSxy 		break;
344c869993eSxy 
345c869993eSxy 	case ETHER_STAT_TOOSHORT_ERRORS:
34613485e69SGarrett D'Amore 		igb->stat_ruc += E1000_READ_REG(hw, E1000_RUC);
34713485e69SGarrett D'Amore 		*val = igb->stat_ruc;
348c869993eSxy 		break;
349c869993eSxy 
350c869993eSxy 	case ETHER_STAT_CAP_REMFAULT:
351c869993eSxy 		*val = igb->param_rem_fault;
352c869993eSxy 		break;
353c869993eSxy 
354c869993eSxy 	case ETHER_STAT_ADV_REMFAULT:
355c869993eSxy 		*val = igb->param_adv_rem_fault;
356c869993eSxy 		break;
357c869993eSxy 
358c869993eSxy 	case ETHER_STAT_LP_REMFAULT:
359c869993eSxy 		*val = igb->param_lp_rem_fault;
360c869993eSxy 		break;
361c869993eSxy 
362c869993eSxy 	case ETHER_STAT_JABBER_ERRORS:
36313485e69SGarrett D'Amore 		igb->stat_rjc += E1000_READ_REG(hw, E1000_RJC);
36413485e69SGarrett D'Amore 		*val = igb->stat_rjc;
365c869993eSxy 		break;
366c869993eSxy 
367c869993eSxy 	case ETHER_STAT_CAP_100T4:
368c869993eSxy 		*val = igb->param_100t4_cap;
369c869993eSxy 		break;
370c869993eSxy 
371c869993eSxy 	case ETHER_STAT_ADV_CAP_100T4:
372c869993eSxy 		*val = igb->param_adv_100t4_cap;
373c869993eSxy 		break;
374c869993eSxy 
375c869993eSxy 	case ETHER_STAT_LP_CAP_100T4:
376c869993eSxy 		*val = igb->param_lp_100t4_cap;
377c869993eSxy 		break;
378c869993eSxy 
379c869993eSxy 	default:
380c869993eSxy 		mutex_exit(&igb->gen_lock);
381c869993eSxy 		return (ENOTSUP);
382c869993eSxy 	}
383c869993eSxy 
384c869993eSxy 	mutex_exit(&igb->gen_lock);
385c869993eSxy 
386cf8dcc9bSzhefeng xu - Sun Microsystems - Beijing China 	if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
387cf8dcc9bSzhefeng xu - Sun Microsystems - Beijing China 		ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
388cf8dcc9bSzhefeng xu - Sun Microsystems - Beijing China 		return (EIO);
389cf8dcc9bSzhefeng xu - Sun Microsystems - Beijing China 	}
3908bb4b220Sgl 
391c869993eSxy 	return (0);
392c869993eSxy }
393c869993eSxy 
394c869993eSxy /*
395c869993eSxy  * Bring the device out of the reset/quiesced state that it
396c869993eSxy  * was in when the interface was registered.
397c869993eSxy  */
398c869993eSxy int
igb_m_start(void * arg)399c869993eSxy igb_m_start(void *arg)
400c869993eSxy {
401c869993eSxy 	igb_t *igb = (igb_t *)arg;
402c869993eSxy 
403c869993eSxy 	mutex_enter(&igb->gen_lock);
404c869993eSxy 
405c869993eSxy 	if (igb->igb_state & IGB_SUSPENDED) {
406c869993eSxy 		mutex_exit(&igb->gen_lock);
407c869993eSxy 		return (ECANCELED);
408c869993eSxy 	}
409c869993eSxy 
410ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (igb_start(igb, B_TRUE) != IGB_SUCCESS) {
411c869993eSxy 		mutex_exit(&igb->gen_lock);
412c869993eSxy 		return (EIO);
413c869993eSxy 	}
414c869993eSxy 
415cf8dcc9bSzhefeng xu - Sun Microsystems - Beijing China 	atomic_or_32(&igb->igb_state, IGB_STARTED);
416c869993eSxy 
417c869993eSxy 	mutex_exit(&igb->gen_lock);
418c869993eSxy 
419c869993eSxy 	/*
420c869993eSxy 	 * Enable and start the watchdog timer
421c869993eSxy 	 */
422c869993eSxy 	igb_enable_watchdog_timer(igb);
423c869993eSxy 
424c869993eSxy 	return (0);
425c869993eSxy }
426c869993eSxy 
427c869993eSxy /*
428c869993eSxy  * Stop the device and put it in a reset/quiesced state such
429c869993eSxy  * that the interface can be unregistered.
430c869993eSxy  */
431c869993eSxy void
igb_m_stop(void * arg)432c869993eSxy igb_m_stop(void *arg)
433c869993eSxy {
434c869993eSxy 	igb_t *igb = (igb_t *)arg;
435c869993eSxy 
436c869993eSxy 	mutex_enter(&igb->gen_lock);
437c869993eSxy 
438c869993eSxy 	if (igb->igb_state & IGB_SUSPENDED) {
439c869993eSxy 		mutex_exit(&igb->gen_lock);
440c869993eSxy 		return;
441c869993eSxy 	}
442c869993eSxy 
443cf8dcc9bSzhefeng xu - Sun Microsystems - Beijing China 	atomic_and_32(&igb->igb_state, ~IGB_STARTED);
444c869993eSxy 
445ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	igb_stop(igb, B_TRUE);
446c869993eSxy 
447c869993eSxy 	mutex_exit(&igb->gen_lock);
448c869993eSxy 
449c869993eSxy 	/*
450c869993eSxy 	 * Disable and stop the watchdog timer
451c869993eSxy 	 */
452c869993eSxy 	igb_disable_watchdog_timer(igb);
453c869993eSxy }
454c869993eSxy 
455c869993eSxy /*
456c869993eSxy  * Set the promiscuity of the device.
457c869993eSxy  */
458c869993eSxy int
igb_m_promisc(void * arg,boolean_t on)459c869993eSxy igb_m_promisc(void *arg, boolean_t on)
460c869993eSxy {
461c869993eSxy 	igb_t *igb = (igb_t *)arg;
462c869993eSxy 	uint32_t reg_val;
463c869993eSxy 
464c869993eSxy 	mutex_enter(&igb->gen_lock);
465c869993eSxy 
466c869993eSxy 	if (igb->igb_state & IGB_SUSPENDED) {
467c869993eSxy 		mutex_exit(&igb->gen_lock);
468c869993eSxy 		return (ECANCELED);
469c869993eSxy 	}
470c869993eSxy 
471c869993eSxy 	reg_val = E1000_READ_REG(&igb->hw, E1000_RCTL);
472c869993eSxy 
473c869993eSxy 	if (on)
474c869993eSxy 		reg_val |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
475c869993eSxy 	else
476c869993eSxy 		reg_val &= (~(E1000_RCTL_UPE | E1000_RCTL_MPE));
477c869993eSxy 
478c869993eSxy 	E1000_WRITE_REG(&igb->hw, E1000_RCTL, reg_val);
479c869993eSxy 
480c869993eSxy 	mutex_exit(&igb->gen_lock);
481c869993eSxy 
4828bb4b220Sgl 	if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
4838bb4b220Sgl 		ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
4848bb4b220Sgl 		return (EIO);
4858bb4b220Sgl 	}
4868bb4b220Sgl 
487c869993eSxy 	return (0);
488c869993eSxy }
489c869993eSxy 
490c869993eSxy /*
491c869993eSxy  * Add/remove the addresses to/from the set of multicast
492c869993eSxy  * addresses for which the device will receive packets.
493c869993eSxy  */
494c869993eSxy int
igb_m_multicst(void * arg,boolean_t add,const uint8_t * mcst_addr)495c869993eSxy igb_m_multicst(void *arg, boolean_t add, const uint8_t *mcst_addr)
496c869993eSxy {
497c869993eSxy 	igb_t *igb = (igb_t *)arg;
498c869993eSxy 	int result;
499c869993eSxy 
500c869993eSxy 	mutex_enter(&igb->gen_lock);
501c869993eSxy 
502c869993eSxy 	if (igb->igb_state & IGB_SUSPENDED) {
503c869993eSxy 		mutex_exit(&igb->gen_lock);
504c869993eSxy 		return (ECANCELED);
505c869993eSxy 	}
506c869993eSxy 
507c869993eSxy 	result = (add) ? igb_multicst_add(igb, mcst_addr)
508c869993eSxy 	    : igb_multicst_remove(igb, mcst_addr);
509c869993eSxy 
510c869993eSxy 	mutex_exit(&igb->gen_lock);
511c869993eSxy 
512c869993eSxy 	return (result);
513c869993eSxy }
514c869993eSxy 
515c869993eSxy /*
516c869993eSxy  * Pass on M_IOCTL messages passed to the DLD, and support
517c869993eSxy  * private IOCTLs for debugging and ndd.
518c869993eSxy  */
519c869993eSxy void
igb_m_ioctl(void * arg,queue_t * q,mblk_t * mp)520c869993eSxy igb_m_ioctl(void *arg, queue_t *q, mblk_t *mp)
521c869993eSxy {
522c869993eSxy 	igb_t *igb = (igb_t *)arg;
523c869993eSxy 	struct iocblk *iocp;
524c869993eSxy 	enum ioc_reply status;
525c869993eSxy 
526c869993eSxy 	iocp = (struct iocblk *)(uintptr_t)mp->b_rptr;
527c869993eSxy 	iocp->ioc_error = 0;
528c869993eSxy 
529ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	mutex_enter(&igb->gen_lock);
530ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (igb->igb_state & IGB_SUSPENDED) {
531ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		mutex_exit(&igb->gen_lock);
532ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		miocnak(q, mp, 0, EINVAL);
533ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return;
534ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
535ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	mutex_exit(&igb->gen_lock);
536ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
537c869993eSxy 	switch (iocp->ioc_cmd) {
538c869993eSxy 	case LB_GET_INFO_SIZE:
539c869993eSxy 	case LB_GET_INFO:
540c869993eSxy 	case LB_GET_MODE:
541c869993eSxy 	case LB_SET_MODE:
542c869993eSxy 		status = igb_loopback_ioctl(igb, iocp, mp);
543c869993eSxy 		break;
544c869993eSxy 
545c869993eSxy 	default:
546c869993eSxy 		status = IOC_INVAL;
547c869993eSxy 		break;
548c869993eSxy 	}
549c869993eSxy 
550c869993eSxy 	/*
551c869993eSxy 	 * Decide how to reply
552c869993eSxy 	 */
553c869993eSxy 	switch (status) {
554c869993eSxy 	default:
555c869993eSxy 	case IOC_INVAL:
556c869993eSxy 		/*
557c869993eSxy 		 * Error, reply with a NAK and EINVAL or the specified error
558c869993eSxy 		 */
559c869993eSxy 		miocnak(q, mp, 0, iocp->ioc_error == 0 ?
560c869993eSxy 		    EINVAL : iocp->ioc_error);
561c869993eSxy 		break;
562c869993eSxy 
563c869993eSxy 	case IOC_DONE:
564c869993eSxy 		/*
565c869993eSxy 		 * OK, reply already sent
566c869993eSxy 		 */
567c869993eSxy 		break;
568c869993eSxy 
569c869993eSxy 	case IOC_ACK:
570c869993eSxy 		/*
571c869993eSxy 		 * OK, reply with an ACK
572c869993eSxy 		 */
573c869993eSxy 		miocack(q, mp, 0, 0);
574c869993eSxy 		break;
575c869993eSxy 
576c869993eSxy 	case IOC_REPLY:
577c869993eSxy 		/*
578c869993eSxy 		 * OK, send prepared reply as ACK or NAK
579c869993eSxy 		 */
580c869993eSxy 		mp->b_datap->db_type = iocp->ioc_error == 0 ?
581c869993eSxy 		    M_IOCACK : M_IOCNAK;
582c869993eSxy 		qreply(q, mp);
583c869993eSxy 		break;
584c869993eSxy 	}
585c869993eSxy }
586c869993eSxy 
587c869993eSxy /*
588da14cebeSEric Cheng  * Add a MAC address to the target RX group.
589c869993eSxy  */
590da14cebeSEric Cheng static int
igb_addmac(void * arg,const uint8_t * mac_addr)591da14cebeSEric Cheng igb_addmac(void *arg, const uint8_t *mac_addr)
592c869993eSxy {
593da14cebeSEric Cheng 	igb_rx_group_t *rx_group = (igb_rx_group_t *)arg;
594da14cebeSEric Cheng 	igb_t *igb = rx_group->igb;
595da14cebeSEric Cheng 	struct e1000_hw *hw = &igb->hw;
596da14cebeSEric Cheng 	int i, slot;
597c869993eSxy 
598c869993eSxy 	mutex_enter(&igb->gen_lock);
599c869993eSxy 
600c869993eSxy 	if (igb->igb_state & IGB_SUSPENDED) {
601c869993eSxy 		mutex_exit(&igb->gen_lock);
602c869993eSxy 		return (ECANCELED);
603c869993eSxy 	}
604c869993eSxy 
605c869993eSxy 	if (igb->unicst_avail == 0) {
606c869993eSxy 		/* no slots available */
607c869993eSxy 		mutex_exit(&igb->gen_lock);
608c869993eSxy 		return (ENOSPC);
609c869993eSxy 	}
610c869993eSxy 
611c869993eSxy 	/*
612da14cebeSEric Cheng 	 * The slots from 0 to igb->num_rx_groups are reserved slots which
613da14cebeSEric Cheng 	 * are 1 to 1 mapped with group index directly. The other slots are
614da14cebeSEric Cheng 	 * shared between the all of groups. While adding a MAC address,
615da14cebeSEric Cheng 	 * it will try to set the reserved slots first, then the shared slots.
616c869993eSxy 	 */
617da14cebeSEric Cheng 	slot = -1;
618da14cebeSEric Cheng 	if (igb->unicst_addr[rx_group->index].mac.set == 1) {
619da14cebeSEric Cheng 		/*
620da14cebeSEric Cheng 		 * The reserved slot for current group is used, find the free
621da14cebeSEric Cheng 		 * slots in the shared slots.
622da14cebeSEric Cheng 		 */
623da14cebeSEric Cheng 		for (i = igb->num_rx_groups; i < igb->unicst_total; i++) {
624da14cebeSEric Cheng 			if (igb->unicst_addr[i].mac.set == 0) {
625da14cebeSEric Cheng 				slot = i;
626da14cebeSEric Cheng 				break;
627da14cebeSEric Cheng 			}
628da14cebeSEric Cheng 		}
629da14cebeSEric Cheng 	} else
630da14cebeSEric Cheng 		slot = rx_group->index;
631c869993eSxy 
632da14cebeSEric Cheng 	if (slot == -1) {
633da14cebeSEric Cheng 		/* no slots available in the shared slots */
634da14cebeSEric Cheng 		mutex_exit(&igb->gen_lock);
635da14cebeSEric Cheng 		return (ENOSPC);
636da14cebeSEric Cheng 	}
637c869993eSxy 
638da14cebeSEric Cheng 	/* Set VMDq according to the mode supported by hardware. */
639da14cebeSEric Cheng 	e1000_rar_set_vmdq(hw, mac_addr, slot, igb->vmdq_mode, rx_group->index);
640c869993eSxy 
641da14cebeSEric Cheng 	bcopy(mac_addr, igb->unicst_addr[slot].mac.addr, ETHERADDRL);
642da14cebeSEric Cheng 	igb->unicst_addr[slot].mac.group_index = rx_group->index;
643da14cebeSEric Cheng 	igb->unicst_addr[slot].mac.set = 1;
644da14cebeSEric Cheng 	igb->unicst_avail--;
645c869993eSxy 
646fa25784cSxy 	mutex_exit(&igb->gen_lock);
647fa25784cSxy 
648da14cebeSEric Cheng 	return (0);
649c869993eSxy }
650c869993eSxy 
651c869993eSxy /*
652da14cebeSEric Cheng  * Remove a MAC address from the specified RX group.
653c869993eSxy  */
654da14cebeSEric Cheng static int
igb_remmac(void * arg,const uint8_t * mac_addr)655da14cebeSEric Cheng igb_remmac(void *arg, const uint8_t *mac_addr)
656c869993eSxy {
657da14cebeSEric Cheng 	igb_rx_group_t *rx_group = (igb_rx_group_t *)arg;
658da14cebeSEric Cheng 	igb_t *igb = rx_group->igb;
659da14cebeSEric Cheng 	struct e1000_hw *hw = &igb->hw;
660da14cebeSEric Cheng 	int slot;
661c869993eSxy 
662c869993eSxy 	mutex_enter(&igb->gen_lock);
663c869993eSxy 
664c869993eSxy 	if (igb->igb_state & IGB_SUSPENDED) {
665c869993eSxy 		mutex_exit(&igb->gen_lock);
666c869993eSxy 		return (ECANCELED);
667c869993eSxy 	}
668c869993eSxy 
669da14cebeSEric Cheng 	slot = igb_unicst_find(igb, mac_addr);
670da14cebeSEric Cheng 	if (slot == -1) {
671c869993eSxy 		mutex_exit(&igb->gen_lock);
672c869993eSxy 		return (EINVAL);
673c869993eSxy 	}
674c869993eSxy 
675fa25784cSxy 	if (igb->unicst_addr[slot].mac.set == 0) {
676c869993eSxy 		mutex_exit(&igb->gen_lock);
677fa25784cSxy 		return (EINVAL);
678fa25784cSxy 	}
679c869993eSxy 
680da14cebeSEric Cheng 	/* Clear the MAC ddress in the slot */
681da14cebeSEric Cheng 	e1000_rar_clear(hw, slot);
682da14cebeSEric Cheng 	igb->unicst_addr[slot].mac.set = 0;
683da14cebeSEric Cheng 	igb->unicst_avail++;
684fa25784cSxy 
685c869993eSxy 	mutex_exit(&igb->gen_lock);
686c869993eSxy 
687da14cebeSEric Cheng 	return (0);
688c869993eSxy }
689c869993eSxy 
690c869993eSxy /*
691da14cebeSEric Cheng  * Enable interrupt on the specificed rx ring.
692c869993eSxy  */
693c869993eSxy int
igb_rx_ring_intr_enable(mac_intr_handle_t intrh)694da14cebeSEric Cheng igb_rx_ring_intr_enable(mac_intr_handle_t intrh)
695c869993eSxy {
696da14cebeSEric Cheng 	igb_rx_ring_t *rx_ring = (igb_rx_ring_t *)intrh;
697da14cebeSEric Cheng 	igb_t *igb = rx_ring->igb;
698da14cebeSEric Cheng 	struct e1000_hw *hw = &igb->hw;
699da14cebeSEric Cheng 	uint32_t index = rx_ring->index;
700c869993eSxy 
701da14cebeSEric Cheng 	if (igb->intr_type == DDI_INTR_TYPE_MSIX) {
702da14cebeSEric Cheng 		/* Interrupt enabling for MSI-X */
703da14cebeSEric Cheng 		igb->eims_mask |= (E1000_EICR_RX_QUEUE0 << index);
704da14cebeSEric Cheng 		E1000_WRITE_REG(hw, E1000_EIMS, igb->eims_mask);
705da14cebeSEric Cheng 		E1000_WRITE_REG(hw, E1000_EIAC, igb->eims_mask);
706da14cebeSEric Cheng 	} else {
707da14cebeSEric Cheng 		ASSERT(index == 0);
708da14cebeSEric Cheng 		/* Interrupt enabling for MSI and legacy */
709da14cebeSEric Cheng 		igb->ims_mask |= E1000_IMS_RXT0;
710da14cebeSEric Cheng 		E1000_WRITE_REG(hw, E1000_IMS, igb->ims_mask);
711c869993eSxy 	}
712c869993eSxy 
713da14cebeSEric Cheng 	E1000_WRITE_FLUSH(hw);
714c869993eSxy 
715da14cebeSEric Cheng 	return (0);
716da14cebeSEric Cheng }
717c869993eSxy 
718da14cebeSEric Cheng /*
719da14cebeSEric Cheng  * Disable interrupt on the specificed rx ring.
720da14cebeSEric Cheng  */
721da14cebeSEric Cheng int
igb_rx_ring_intr_disable(mac_intr_handle_t intrh)722da14cebeSEric Cheng igb_rx_ring_intr_disable(mac_intr_handle_t intrh)
723da14cebeSEric Cheng {
724da14cebeSEric Cheng 	igb_rx_ring_t *rx_ring = (igb_rx_ring_t *)intrh;
725da14cebeSEric Cheng 	igb_t *igb = rx_ring->igb;
726da14cebeSEric Cheng 	struct e1000_hw *hw = &igb->hw;
727da14cebeSEric Cheng 	uint32_t index = rx_ring->index;
728da14cebeSEric Cheng 
729da14cebeSEric Cheng 	if (igb->intr_type == DDI_INTR_TYPE_MSIX) {
730da14cebeSEric Cheng 		/* Interrupt disabling for MSI-X */
731da14cebeSEric Cheng 		igb->eims_mask &= ~(E1000_EICR_RX_QUEUE0 << index);
732da14cebeSEric Cheng 		E1000_WRITE_REG(hw, E1000_EIMC,
733da14cebeSEric Cheng 		    (E1000_EICR_RX_QUEUE0 << index));
734da14cebeSEric Cheng 		E1000_WRITE_REG(hw, E1000_EIAC, igb->eims_mask);
735da14cebeSEric Cheng 	} else {
736da14cebeSEric Cheng 		ASSERT(index == 0);
737da14cebeSEric Cheng 		/* Interrupt disabling for MSI and legacy */
738da14cebeSEric Cheng 		igb->ims_mask &= ~E1000_IMS_RXT0;
739da14cebeSEric Cheng 		E1000_WRITE_REG(hw, E1000_IMC, E1000_IMS_RXT0);
740c869993eSxy 	}
741c869993eSxy 
742da14cebeSEric Cheng 	E1000_WRITE_FLUSH(hw);
743da14cebeSEric Cheng 
744da14cebeSEric Cheng 	return (0);
745da14cebeSEric Cheng }
746da14cebeSEric Cheng 
747da14cebeSEric Cheng /*
748da14cebeSEric Cheng  * Get the global ring index by a ring index within a group.
749da14cebeSEric Cheng  */
750da14cebeSEric Cheng int
igb_get_rx_ring_index(igb_t * igb,int gindex,int rindex)751da14cebeSEric Cheng igb_get_rx_ring_index(igb_t *igb, int gindex, int rindex)
752da14cebeSEric Cheng {
753da14cebeSEric Cheng 	igb_rx_ring_t *rx_ring;
754da14cebeSEric Cheng 	int i;
755da14cebeSEric Cheng 
756da14cebeSEric Cheng 	for (i = 0; i < igb->num_rx_rings; i++) {
757da14cebeSEric Cheng 		rx_ring = &igb->rx_rings[i];
758da14cebeSEric Cheng 		if (rx_ring->group_index == gindex)
759da14cebeSEric Cheng 			rindex--;
760da14cebeSEric Cheng 		if (rindex < 0)
761da14cebeSEric Cheng 			return (i);
762c869993eSxy 	}
763fa25784cSxy 
764da14cebeSEric Cheng 	return (-1);
765da14cebeSEric Cheng }
766fa25784cSxy 
767da14cebeSEric Cheng static int
igb_ring_start(mac_ring_driver_t rh,uint64_t mr_gen_num)768da14cebeSEric Cheng igb_ring_start(mac_ring_driver_t rh, uint64_t mr_gen_num)
769da14cebeSEric Cheng {
770da14cebeSEric Cheng 	igb_rx_ring_t *rx_ring = (igb_rx_ring_t *)rh;
771c869993eSxy 
772da14cebeSEric Cheng 	mutex_enter(&rx_ring->rx_lock);
773da14cebeSEric Cheng 	rx_ring->ring_gen_num = mr_gen_num;
774da14cebeSEric Cheng 	mutex_exit(&rx_ring->rx_lock);
775da14cebeSEric Cheng 	return (0);
776c869993eSxy }
777c869993eSxy 
778c869993eSxy /*
779da14cebeSEric Cheng  * Callback funtion for MAC layer to register all rings.
780c869993eSxy  */
781da14cebeSEric Cheng /* ARGSUSED */
782da14cebeSEric Cheng void
igb_fill_ring(void * arg,mac_ring_type_t rtype,const int rg_index,const int index,mac_ring_info_t * infop,mac_ring_handle_t rh)783da14cebeSEric Cheng igb_fill_ring(void *arg, mac_ring_type_t rtype, const int rg_index,
784da14cebeSEric Cheng     const int index, mac_ring_info_t *infop, mac_ring_handle_t rh)
785c869993eSxy {
786c869993eSxy 	igb_t *igb = (igb_t *)arg;
787da14cebeSEric Cheng 	mac_intr_t *mintr = &infop->mri_intr;
788c869993eSxy 
789da14cebeSEric Cheng 	switch (rtype) {
790da14cebeSEric Cheng 	case MAC_RING_TYPE_RX: {
791da14cebeSEric Cheng 		igb_rx_ring_t *rx_ring;
792da14cebeSEric Cheng 		int global_index;
793c869993eSxy 
794da14cebeSEric Cheng 		/*
795da14cebeSEric Cheng 		 * 'index' is the ring index within the group.
796da14cebeSEric Cheng 		 * We need the global ring index by searching in group.
797da14cebeSEric Cheng 		 */
798da14cebeSEric Cheng 		global_index = igb_get_rx_ring_index(igb, rg_index, index);
799c869993eSxy 
800da14cebeSEric Cheng 		ASSERT(global_index >= 0);
801c869993eSxy 
802da14cebeSEric Cheng 		rx_ring = &igb->rx_rings[global_index];
803da14cebeSEric Cheng 		rx_ring->ring_handle = rh;
804da14cebeSEric Cheng 
805da14cebeSEric Cheng 		infop->mri_driver = (mac_ring_driver_t)rx_ring;
806da14cebeSEric Cheng 		infop->mri_start = igb_ring_start;
807da14cebeSEric Cheng 		infop->mri_stop = NULL;
808da14cebeSEric Cheng 		infop->mri_poll = (mac_ring_poll_t)igb_rx_ring_poll;
8090dc2366fSVenugopal Iyer 		infop->mri_stat = igb_rx_ring_stat;
810da14cebeSEric Cheng 
811da14cebeSEric Cheng 		mintr->mi_handle = (mac_intr_handle_t)rx_ring;
812da14cebeSEric Cheng 		mintr->mi_enable = igb_rx_ring_intr_enable;
813da14cebeSEric Cheng 		mintr->mi_disable = igb_rx_ring_intr_disable;
8140dc2366fSVenugopal Iyer 		if (igb->intr_type & (DDI_INTR_TYPE_MSIX | DDI_INTR_TYPE_MSI)) {
8150dc2366fSVenugopal Iyer 			mintr->mi_ddi_handle =
8160dc2366fSVenugopal Iyer 			    igb->htable[rx_ring->intr_vector];
8170dc2366fSVenugopal Iyer 		}
818da14cebeSEric Cheng 		break;
819c869993eSxy 	}
820da14cebeSEric Cheng 	case MAC_RING_TYPE_TX: {
821da14cebeSEric Cheng 		ASSERT(index < igb->num_tx_rings);
822c869993eSxy 
823da14cebeSEric Cheng 		igb_tx_ring_t *tx_ring = &igb->tx_rings[index];
824da14cebeSEric Cheng 		tx_ring->ring_handle = rh;
825da14cebeSEric Cheng 
826da14cebeSEric Cheng 		infop->mri_driver = (mac_ring_driver_t)tx_ring;
827da14cebeSEric Cheng 		infop->mri_start = NULL;
828da14cebeSEric Cheng 		infop->mri_stop = NULL;
829da14cebeSEric Cheng 		infop->mri_tx = igb_tx_ring_send;
8300dc2366fSVenugopal Iyer 		infop->mri_stat = igb_tx_ring_stat;
8310dc2366fSVenugopal Iyer 		if (igb->intr_type & (DDI_INTR_TYPE_MSIX | DDI_INTR_TYPE_MSI)) {
8320dc2366fSVenugopal Iyer 			mintr->mi_ddi_handle =
8330dc2366fSVenugopal Iyer 			    igb->htable[tx_ring->intr_vector];
8340dc2366fSVenugopal Iyer 		}
835da14cebeSEric Cheng 		break;
836c869993eSxy 	}
837da14cebeSEric Cheng 	default:
838da14cebeSEric Cheng 		break;
839da14cebeSEric Cheng 	}
840da14cebeSEric Cheng }
841c869993eSxy 
842da14cebeSEric Cheng void
igb_fill_group(void * arg,mac_ring_type_t rtype,const int index,mac_group_info_t * infop,mac_group_handle_t gh)843da14cebeSEric Cheng igb_fill_group(void *arg, mac_ring_type_t rtype, const int index,
844da14cebeSEric Cheng     mac_group_info_t *infop, mac_group_handle_t gh)
845da14cebeSEric Cheng {
846da14cebeSEric Cheng 	igb_t *igb = (igb_t *)arg;
847da14cebeSEric Cheng 
848da14cebeSEric Cheng 	switch (rtype) {
849da14cebeSEric Cheng 	case MAC_RING_TYPE_RX: {
850da14cebeSEric Cheng 		igb_rx_group_t *rx_group;
851da14cebeSEric Cheng 
852da14cebeSEric Cheng 		ASSERT((index >= 0) && (index < igb->num_rx_groups));
853da14cebeSEric Cheng 
854da14cebeSEric Cheng 		rx_group = &igb->rx_groups[index];
855da14cebeSEric Cheng 		rx_group->group_handle = gh;
856da14cebeSEric Cheng 
857da14cebeSEric Cheng 		infop->mgi_driver = (mac_group_driver_t)rx_group;
858da14cebeSEric Cheng 		infop->mgi_start = NULL;
859da14cebeSEric Cheng 		infop->mgi_stop = NULL;
860da14cebeSEric Cheng 		infop->mgi_addmac = igb_addmac;
861da14cebeSEric Cheng 		infop->mgi_remmac = igb_remmac;
862da14cebeSEric Cheng 		infop->mgi_count = (igb->num_rx_rings / igb->num_rx_groups);
863da14cebeSEric Cheng 
864da14cebeSEric Cheng 		break;
865da14cebeSEric Cheng 	}
866da14cebeSEric Cheng 	case MAC_RING_TYPE_TX:
867da14cebeSEric Cheng 		break;
868da14cebeSEric Cheng 	default:
869da14cebeSEric Cheng 		break;
870da14cebeSEric Cheng 	}
871c869993eSxy }
872c869993eSxy 
873c1e9c696SRobert Mustacchi static int
igb_led_set(void * arg,mac_led_mode_t mode,uint_t flags)874c1e9c696SRobert Mustacchi igb_led_set(void *arg, mac_led_mode_t mode, uint_t flags)
875c1e9c696SRobert Mustacchi {
876c1e9c696SRobert Mustacchi 	igb_t *igb = arg;
877c1e9c696SRobert Mustacchi 
878c1e9c696SRobert Mustacchi 	if (flags != 0)
879c1e9c696SRobert Mustacchi 		return (EINVAL);
880c1e9c696SRobert Mustacchi 
881c1e9c696SRobert Mustacchi 	if (mode != MAC_LED_DEFAULT &&
882c1e9c696SRobert Mustacchi 	    mode != MAC_LED_IDENT &&
883c1e9c696SRobert Mustacchi 	    mode != MAC_LED_OFF &&
884c1e9c696SRobert Mustacchi 	    mode != MAC_LED_ON)
885c1e9c696SRobert Mustacchi 		return (ENOTSUP);
886c1e9c696SRobert Mustacchi 
887c1e9c696SRobert Mustacchi 	if (mode != MAC_LED_DEFAULT && !igb->igb_led_setup) {
888c1e9c696SRobert Mustacchi 		if (e1000_setup_led(&igb->hw) != E1000_SUCCESS)
889c1e9c696SRobert Mustacchi 			return (EIO);
890c1e9c696SRobert Mustacchi 
891c1e9c696SRobert Mustacchi 		igb->igb_led_setup = B_TRUE;
892c1e9c696SRobert Mustacchi 	}
893c1e9c696SRobert Mustacchi 
894c1e9c696SRobert Mustacchi 	switch (mode) {
895c1e9c696SRobert Mustacchi 	case MAC_LED_DEFAULT:
896c1e9c696SRobert Mustacchi 		if (igb->igb_led_setup) {
897c1e9c696SRobert Mustacchi 			if (e1000_cleanup_led(&igb->hw) != E1000_SUCCESS)
898c1e9c696SRobert Mustacchi 				return (EIO);
899c1e9c696SRobert Mustacchi 			igb->igb_led_setup = B_FALSE;
900c1e9c696SRobert Mustacchi 		}
901c1e9c696SRobert Mustacchi 		break;
902c1e9c696SRobert Mustacchi 	case MAC_LED_IDENT:
903c1e9c696SRobert Mustacchi 		if (e1000_blink_led(&igb->hw) != E1000_SUCCESS)
904c1e9c696SRobert Mustacchi 			return (EIO);
905c1e9c696SRobert Mustacchi 		break;
906c1e9c696SRobert Mustacchi 	case MAC_LED_OFF:
907c1e9c696SRobert Mustacchi 		if (e1000_led_off(&igb->hw) != E1000_SUCCESS)
908c1e9c696SRobert Mustacchi 			return (EIO);
909c1e9c696SRobert Mustacchi 		break;
910c1e9c696SRobert Mustacchi 	case MAC_LED_ON:
911c1e9c696SRobert Mustacchi 		if (e1000_led_on(&igb->hw) != E1000_SUCCESS)
912c1e9c696SRobert Mustacchi 			return (EIO);
913c1e9c696SRobert Mustacchi 		break;
914c1e9c696SRobert Mustacchi 	default:
915c1e9c696SRobert Mustacchi 		return (ENOTSUP);
916c1e9c696SRobert Mustacchi 	}
917c1e9c696SRobert Mustacchi 
918c1e9c696SRobert Mustacchi 	return (0);
919c1e9c696SRobert Mustacchi }
920c1e9c696SRobert Mustacchi 
921c869993eSxy /*
922c869993eSxy  * Obtain the MAC's capabilities and associated data from
923c869993eSxy  * the driver.
924c869993eSxy  */
925c869993eSxy boolean_t
igb_m_getcapab(void * arg,mac_capab_t cap,void * cap_data)926c869993eSxy igb_m_getcapab(void *arg, mac_capab_t cap, void *cap_data)
927c869993eSxy {
928c869993eSxy 	igb_t *igb = (igb_t *)arg;
929c869993eSxy 
930c869993eSxy 	switch (cap) {
931c869993eSxy 	case MAC_CAPAB_HCKSUM: {
932c869993eSxy 		uint32_t *tx_hcksum_flags = cap_data;
933c869993eSxy 
934c869993eSxy 		/*
935c869993eSxy 		 * We advertise our capabilities only if tx hcksum offload is
936c869993eSxy 		 * enabled.  On receive, the stack will accept checksummed
937c869993eSxy 		 * packets anyway, even if we haven't said we can deliver
938c869993eSxy 		 * them.
939c869993eSxy 		 */
940c869993eSxy 		if (!igb->tx_hcksum_enable)
941c869993eSxy 			return (B_FALSE);
942c869993eSxy 
943c869993eSxy 		*tx_hcksum_flags = HCKSUM_INET_PARTIAL | HCKSUM_IPHDRCKSUM;
944c869993eSxy 		break;
945c869993eSxy 	}
946d11274aaSPaul Guo 	case MAC_CAPAB_LSO: {
947d11274aaSPaul Guo 		mac_capab_lso_t *cap_lso = cap_data;
948d11274aaSPaul Guo 
949d11274aaSPaul Guo 		if (igb->lso_enable) {
95085f496faSRobert Mustacchi 			cap_lso->lso_flags = LSO_TX_BASIC_TCP_IPV4 |
95185f496faSRobert Mustacchi 			    LSO_TX_BASIC_TCP_IPV6;
952d11274aaSPaul Guo 			cap_lso->lso_basic_tcp_ipv4.lso_max = IGB_LSO_MAXLEN;
95385f496faSRobert Mustacchi 			cap_lso->lso_basic_tcp_ipv6.lso_max = IGB_LSO_MAXLEN;
954d11274aaSPaul Guo 			break;
955d11274aaSPaul Guo 		} else {
956d11274aaSPaul Guo 			return (B_FALSE);
957d11274aaSPaul Guo 		}
958d11274aaSPaul Guo 	}
959da14cebeSEric Cheng 	case MAC_CAPAB_RINGS: {
960da14cebeSEric Cheng 		mac_capab_rings_t *cap_rings = cap_data;
961da14cebeSEric Cheng 
962da14cebeSEric Cheng 		switch (cap_rings->mr_type) {
963da14cebeSEric Cheng 		case MAC_RING_TYPE_RX:
964da14cebeSEric Cheng 			cap_rings->mr_group_type = MAC_GROUP_TYPE_STATIC;
965da14cebeSEric Cheng 			cap_rings->mr_rnum = igb->num_rx_rings;
966da14cebeSEric Cheng 			cap_rings->mr_gnum = igb->num_rx_groups;
967da14cebeSEric Cheng 			cap_rings->mr_rget = igb_fill_ring;
968da14cebeSEric Cheng 			cap_rings->mr_gget = igb_fill_group;
969da14cebeSEric Cheng 			cap_rings->mr_gaddring = NULL;
970da14cebeSEric Cheng 			cap_rings->mr_gremring = NULL;
971c869993eSxy 
972da14cebeSEric Cheng 			break;
973da14cebeSEric Cheng 		case MAC_RING_TYPE_TX:
974da14cebeSEric Cheng 			cap_rings->mr_group_type = MAC_GROUP_TYPE_STATIC;
975da14cebeSEric Cheng 			cap_rings->mr_rnum = igb->num_tx_rings;
976da14cebeSEric Cheng 			cap_rings->mr_gnum = 0;
977da14cebeSEric Cheng 			cap_rings->mr_rget = igb_fill_ring;
978da14cebeSEric Cheng 			cap_rings->mr_gget = NULL;
979da14cebeSEric Cheng 
980da14cebeSEric Cheng 			break;
981da14cebeSEric Cheng 		default:
982da14cebeSEric Cheng 			break;
983da14cebeSEric Cheng 		}
984c869993eSxy 		break;
985c869993eSxy 	}
986da14cebeSEric Cheng 
987c1e9c696SRobert Mustacchi 	case MAC_CAPAB_LED: {
988c1e9c696SRobert Mustacchi 		mac_capab_led_t *cap_led = cap_data;
989c1e9c696SRobert Mustacchi 
990c1e9c696SRobert Mustacchi 		cap_led->mcl_flags = 0;
991c1e9c696SRobert Mustacchi 		cap_led->mcl_modes = MAC_LED_DEFAULT;
992c1e9c696SRobert Mustacchi 		if (igb->hw.mac.ops.blink_led != NULL &&
993c1e9c696SRobert Mustacchi 		    igb->hw.mac.ops.blink_led != e1000_null_ops_generic) {
994c1e9c696SRobert Mustacchi 			cap_led->mcl_modes |= MAC_LED_IDENT;
995c1e9c696SRobert Mustacchi 		}
996c1e9c696SRobert Mustacchi 		if (igb->hw.mac.ops.led_off != NULL &&
997c1e9c696SRobert Mustacchi 		    igb->hw.mac.ops.led_off != e1000_null_ops_generic) {
998c1e9c696SRobert Mustacchi 			cap_led->mcl_modes |= MAC_LED_OFF;
999c1e9c696SRobert Mustacchi 		}
1000c1e9c696SRobert Mustacchi 		if (igb->hw.mac.ops.led_on != NULL &&
1001c1e9c696SRobert Mustacchi 		    igb->hw.mac.ops.led_on != e1000_null_ops_generic) {
1002c1e9c696SRobert Mustacchi 			cap_led->mcl_modes |= MAC_LED_ON;
1003c1e9c696SRobert Mustacchi 		}
1004c1e9c696SRobert Mustacchi 		cap_led->mcl_set = igb_led_set;
1005c1e9c696SRobert Mustacchi 		break;
1006c1e9c696SRobert Mustacchi 	}
1007c1e9c696SRobert Mustacchi 
1008c869993eSxy 	default:
1009c869993eSxy 		return (B_FALSE);
1010c869993eSxy 	}
1011c869993eSxy 	return (B_TRUE);
1012c869993eSxy }
1013ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1014ac7f5757Schenlu chen - Sun Microsystems - Beijing China int
igb_m_setprop(void * arg,const char * pr_name,mac_prop_id_t pr_num,uint_t pr_valsize,const void * pr_val)1015ac7f5757Schenlu chen - Sun Microsystems - Beijing China igb_m_setprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
1016ac7f5757Schenlu chen - Sun Microsystems - Beijing China     uint_t pr_valsize, const void *pr_val)
1017ac7f5757Schenlu chen - Sun Microsystems - Beijing China {
1018ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	igb_t *igb = (igb_t *)arg;
1019ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	struct e1000_hw *hw = &igb->hw;
1020ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	int err = 0;
1021ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	uint32_t flow_control;
1022ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	uint32_t cur_mtu, new_mtu;
1023ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	uint32_t rx_size;
1024ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	uint32_t tx_size;
1025ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1026ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	mutex_enter(&igb->gen_lock);
1027ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (igb->igb_state & IGB_SUSPENDED) {
1028ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		mutex_exit(&igb->gen_lock);
1029ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return (ECANCELED);
1030ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1031ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1032ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (igb->loopback_mode != IGB_LB_NONE && igb_param_locked(pr_num)) {
1033ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		/*
1034ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		 * All en_* parameters are locked (read-only)
1035ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		 * while the device is in any sort of loopback mode.
1036ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		 */
1037ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		mutex_exit(&igb->gen_lock);
1038ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return (EBUSY);
1039ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1040ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1041ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	switch (pr_num) {
1042ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_1000FDX_CAP:
1043ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		/* read/write on copper, read-only on serdes */
1044ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
1045ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = ENOTSUP;
1046ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1047ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1048ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_en_1000fdx_cap = *(uint8_t *)pr_val;
1049ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_adv_1000fdx_cap = *(uint8_t *)pr_val;
1050ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		goto setup_link;
1051ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_100FDX_CAP:
1052ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
1053ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = ENOTSUP;
1054ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1055ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1056ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_en_100fdx_cap = *(uint8_t *)pr_val;
1057ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_adv_100fdx_cap = *(uint8_t *)pr_val;
1058ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		goto setup_link;
1059ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_100HDX_CAP:
1060ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
1061ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = ENOTSUP;
1062ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1063ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1064ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_en_100hdx_cap = *(uint8_t *)pr_val;
1065ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_adv_100hdx_cap = *(uint8_t *)pr_val;
1066ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		goto setup_link;
1067ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_10FDX_CAP:
1068ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
1069ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = ENOTSUP;
1070ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1071ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1072ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_en_10fdx_cap = *(uint8_t *)pr_val;
1073ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_adv_10fdx_cap = *(uint8_t *)pr_val;
1074ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		goto setup_link;
1075ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_10HDX_CAP:
1076ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
1077ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = ENOTSUP;
1078ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1079ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1080ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_en_10hdx_cap = *(uint8_t *)pr_val;
1081ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_adv_10hdx_cap = *(uint8_t *)pr_val;
1082ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		goto setup_link;
1083ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_AUTONEG:
1084ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
1085ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = ENOTSUP;
1086ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1087ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1088ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		igb->param_adv_autoneg_cap = *(uint8_t *)pr_val;
1089ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		goto setup_link;
1090ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_FLOWCTRL:
1091ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		bcopy(pr_val, &flow_control, sizeof (flow_control));
1092ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1093ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		switch (flow_control) {
1094ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		default:
1095ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1096ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1097ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case LINK_FLOWCTRL_NONE:
1098ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			hw->fc.requested_mode = e1000_fc_none;
1099ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1100ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case LINK_FLOWCTRL_RX:
1101ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			hw->fc.requested_mode = e1000_fc_rx_pause;
1102ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1103ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case LINK_FLOWCTRL_TX:
1104ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			hw->fc.requested_mode = e1000_fc_tx_pause;
1105ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1106ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case LINK_FLOWCTRL_BI:
1107ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			hw->fc.requested_mode = e1000_fc_full;
1108ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1109ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1110ac7f5757Schenlu chen - Sun Microsystems - Beijing China setup_link:
1111ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (err == 0) {
1112ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			if (igb_setup_link(igb, B_TRUE) != IGB_SUCCESS)
1113ac7f5757Schenlu chen - Sun Microsystems - Beijing China 				err = EINVAL;
1114ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1115ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1116ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_1000FDX_CAP:
1117ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_1000HDX_CAP:
1118ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_100T4_CAP:
1119ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_100FDX_CAP:
1120ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_100HDX_CAP:
1121ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_10FDX_CAP:
1122ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_10HDX_CAP:
1123ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_1000HDX_CAP:
1124ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_100T4_CAP:
1125ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_STATUS:
1126ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_SPEED:
1127ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_DUPLEX:
1128*42b53e0fSRobert Mustacchi 	case MAC_PROP_MEDIA:
1129ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		err = ENOTSUP; /* read-only prop. Can't set this. */
1130ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1131ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_MTU:
1132ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		/* adapter must be stopped for an MTU change */
1133ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (igb->igb_state & IGB_STARTED) {
1134ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EBUSY;
1135ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1136ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1137ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1138ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		cur_mtu = igb->default_mtu;
1139ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		bcopy(pr_val, &new_mtu, sizeof (new_mtu));
1140ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (new_mtu == cur_mtu) {
1141ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = 0;
1142ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1143ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1144ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1145ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (new_mtu < MIN_MTU || new_mtu > MAX_MTU) {
1146ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1147ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			break;
1148ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1149ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1150ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		err = mac_maxsdu_update(igb->mac_hdl, new_mtu);
1151ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (err == 0) {
1152ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->default_mtu = new_mtu;
1153ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->max_frame_size = igb->default_mtu +
1154ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			    sizeof (struct ether_vlan_header) + ETHERFCSL;
1155ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1156ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			/*
1157ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			 * Set rx buffer size
1158ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			 */
1159ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			rx_size = igb->max_frame_size + IPHDR_ALIGN_ROOM;
1160ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->rx_buf_size = ((rx_size >> 10) + ((rx_size &
1161ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			    (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
1162ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1163ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			/*
1164ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			 * Set tx buffer size
1165ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			 */
1166ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			tx_size = igb->max_frame_size;
1167ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->tx_buf_size = ((tx_size >> 10) + ((tx_size &
1168ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			    (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
1169ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1170ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1171ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_PRIVATE:
1172ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		err = igb_set_priv_prop(igb, pr_name, pr_valsize, pr_val);
1173ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1174ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	default:
1175238d8f47SDale Ghent 		err = ENOTSUP;
1176ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1177ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1178ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1179ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	mutex_exit(&igb->gen_lock);
1180ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1181ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
1182ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
1183ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return (EIO);
1184ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1185ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1186ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	return (err);
1187ac7f5757Schenlu chen - Sun Microsystems - Beijing China }
1188ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1189ac7f5757Schenlu chen - Sun Microsystems - Beijing China int
igb_m_getprop(void * arg,const char * pr_name,mac_prop_id_t pr_num,uint_t pr_valsize,void * pr_val)1190ac7f5757Schenlu chen - Sun Microsystems - Beijing China igb_m_getprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
11910dc2366fSVenugopal Iyer     uint_t pr_valsize, void *pr_val)
1192ac7f5757Schenlu chen - Sun Microsystems - Beijing China {
1193ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	igb_t *igb = (igb_t *)arg;
1194ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	struct e1000_hw *hw = &igb->hw;
1195ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	int err = 0;
1196ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	uint32_t flow_control;
1197ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	uint64_t tmp = 0;
1198ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1199ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	switch (pr_num) {
1200ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_DUPLEX:
12010dc2366fSVenugopal Iyer 		ASSERT(pr_valsize >= sizeof (link_duplex_t));
12020dc2366fSVenugopal Iyer 		bcopy(&igb->link_duplex, pr_val, sizeof (link_duplex_t));
1203ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1204ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_SPEED:
12050dc2366fSVenugopal Iyer 		ASSERT(pr_valsize >= sizeof (uint64_t));
12060dc2366fSVenugopal Iyer 		tmp = igb->link_speed * 1000000ull;
12070dc2366fSVenugopal Iyer 		bcopy(&tmp, pr_val, sizeof (tmp));
1208ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1209ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_AUTONEG:
12100dc2366fSVenugopal Iyer 		ASSERT(pr_valsize >= sizeof (uint8_t));
1211ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_adv_autoneg_cap;
1212ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1213ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_FLOWCTRL:
12140dc2366fSVenugopal Iyer 		ASSERT(pr_valsize >= sizeof (uint32_t));
12150dc2366fSVenugopal Iyer 		switch (hw->fc.requested_mode) {
12160dc2366fSVenugopal Iyer 			case e1000_fc_none:
12170dc2366fSVenugopal Iyer 				flow_control = LINK_FLOWCTRL_NONE;
12180dc2366fSVenugopal Iyer 				break;
12190dc2366fSVenugopal Iyer 			case e1000_fc_rx_pause:
12200dc2366fSVenugopal Iyer 				flow_control = LINK_FLOWCTRL_RX;
12210dc2366fSVenugopal Iyer 				break;
12220dc2366fSVenugopal Iyer 			case e1000_fc_tx_pause:
12230dc2366fSVenugopal Iyer 				flow_control = LINK_FLOWCTRL_TX;
12240dc2366fSVenugopal Iyer 				break;
12250dc2366fSVenugopal Iyer 			case e1000_fc_full:
12260dc2366fSVenugopal Iyer 				flow_control = LINK_FLOWCTRL_BI;
12270dc2366fSVenugopal Iyer 				break;
12280dc2366fSVenugopal Iyer 		}
12290dc2366fSVenugopal Iyer 		bcopy(&flow_control, pr_val, sizeof (flow_control));
1230ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1231ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_1000FDX_CAP:
1232ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_adv_1000fdx_cap;
1233ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1234ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_1000FDX_CAP:
1235ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_en_1000fdx_cap;
1236ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1237ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_1000HDX_CAP:
1238ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_adv_1000hdx_cap;
1239ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1240ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_1000HDX_CAP:
1241ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_en_1000hdx_cap;
1242ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1243ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_100T4_CAP:
1244ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_adv_100t4_cap;
1245ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1246ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_100T4_CAP:
1247ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_en_100t4_cap;
1248ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1249ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_100FDX_CAP:
1250ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_adv_100fdx_cap;
1251ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1252ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_100FDX_CAP:
1253ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_en_100fdx_cap;
1254ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1255ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_100HDX_CAP:
1256ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_adv_100hdx_cap;
1257ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1258ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_100HDX_CAP:
1259ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_en_100hdx_cap;
1260ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1261ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_10FDX_CAP:
1262ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_adv_10fdx_cap;
1263ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1264ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_10FDX_CAP:
1265ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_en_10fdx_cap;
1266ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1267ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_10HDX_CAP:
1268ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_adv_10hdx_cap;
1269ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1270ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_10HDX_CAP:
1271ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		*(uint8_t *)pr_val = igb->param_en_10hdx_cap;
1272ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1273*42b53e0fSRobert Mustacchi 	case MAC_PROP_MEDIA:
1274*42b53e0fSRobert Mustacchi 		*(mac_ether_media_t *)pr_val = e1000_link_to_media(hw,
1275*42b53e0fSRobert Mustacchi 		    igb->link_speed);
1276*42b53e0fSRobert Mustacchi 		break;
1277ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_PRIVATE:
12780dc2366fSVenugopal Iyer 		err = igb_get_priv_prop(igb, pr_name, pr_valsize, pr_val);
1279ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1280ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	default:
1281238d8f47SDale Ghent 		err = ENOTSUP;
1282ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1283ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1284ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	return (err);
1285ac7f5757Schenlu chen - Sun Microsystems - Beijing China }
1286ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
12870dc2366fSVenugopal Iyer void
igb_m_propinfo(void * arg,const char * pr_name,mac_prop_id_t pr_num,mac_prop_info_handle_t prh)12880dc2366fSVenugopal Iyer igb_m_propinfo(void *arg, const char *pr_name, mac_prop_id_t pr_num,
12890dc2366fSVenugopal Iyer     mac_prop_info_handle_t prh)
1290ac7f5757Schenlu chen - Sun Microsystems - Beijing China {
12910dc2366fSVenugopal Iyer 	igb_t *igb = (igb_t *)arg;
1292ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	struct e1000_hw *hw = &igb->hw;
12930dc2366fSVenugopal Iyer 	uint16_t phy_status, phy_ext_status;
1294ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1295ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	switch (pr_num) {
12960dc2366fSVenugopal Iyer 	case MAC_PROP_DUPLEX:
12970dc2366fSVenugopal Iyer 	case MAC_PROP_SPEED:
1298ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_1000FDX_CAP:
12990dc2366fSVenugopal Iyer 	case MAC_PROP_ADV_1000HDX_CAP:
13000dc2366fSVenugopal Iyer 	case MAC_PROP_EN_1000HDX_CAP:
13010dc2366fSVenugopal Iyer 	case MAC_PROP_ADV_100T4_CAP:
13020dc2366fSVenugopal Iyer 	case MAC_PROP_EN_100T4_CAP:
13030dc2366fSVenugopal Iyer 		mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
13040dc2366fSVenugopal Iyer 		break;
13050dc2366fSVenugopal Iyer 
1306ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_1000FDX_CAP:
1307ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
13080dc2366fSVenugopal Iyer 			mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
1309ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		} else {
13100dc2366fSVenugopal Iyer 			(void) e1000_read_phy_reg(hw, PHY_EXT_STATUS,
13110dc2366fSVenugopal Iyer 			    &phy_ext_status);
13120dc2366fSVenugopal Iyer 			mac_prop_info_set_default_uint8(prh,
1313ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			    ((phy_ext_status & IEEE_ESR_1000T_FD_CAPS) ||
13140dc2366fSVenugopal Iyer 			    (phy_ext_status & IEEE_ESR_1000X_FD_CAPS)) ? 1 : 0);
1315ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1316ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
13170dc2366fSVenugopal Iyer 
1318ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_100FDX_CAP:
1319ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_100FDX_CAP:
1320ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
13210dc2366fSVenugopal Iyer 			mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
1322ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		} else {
1323ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			(void) e1000_read_phy_reg(hw, PHY_STATUS, &phy_status);
13240dc2366fSVenugopal Iyer 			mac_prop_info_set_default_uint8(prh,
1325ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			    ((phy_status & MII_SR_100X_FD_CAPS) ||
13260dc2366fSVenugopal Iyer 			    (phy_status & MII_SR_100T2_FD_CAPS)) ? 1 : 0);
1327ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1328ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
13290dc2366fSVenugopal Iyer 
1330ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_100HDX_CAP:
1331ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_100HDX_CAP:
1332ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
13330dc2366fSVenugopal Iyer 			mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
1334ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		} else {
1335ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			(void) e1000_read_phy_reg(hw, PHY_STATUS, &phy_status);
13360dc2366fSVenugopal Iyer 			mac_prop_info_set_default_uint8(prh,
1337ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			    ((phy_status & MII_SR_100X_HD_CAPS) ||
13380dc2366fSVenugopal Iyer 			    (phy_status & MII_SR_100T2_HD_CAPS)) ? 1 : 0);
1339ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1340ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
13410dc2366fSVenugopal Iyer 
1342ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_10FDX_CAP:
1343ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_10FDX_CAP:
1344ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
13450dc2366fSVenugopal Iyer 			mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
1346ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		} else {
1347ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			(void) e1000_read_phy_reg(hw, PHY_STATUS, &phy_status);
13480dc2366fSVenugopal Iyer 			mac_prop_info_set_default_uint8(prh,
13490dc2366fSVenugopal Iyer 			    (phy_status & MII_SR_10T_FD_CAPS) ? 1 : 0);
1350ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1351ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
13520dc2366fSVenugopal Iyer 
1353ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_ADV_10HDX_CAP:
1354ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	case MAC_PROP_EN_10HDX_CAP:
1355ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (hw->phy.media_type != e1000_media_type_copper) {
13560dc2366fSVenugopal Iyer 			mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
1357ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		} else {
1358ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			(void) e1000_read_phy_reg(hw, PHY_STATUS, &phy_status);
13590dc2366fSVenugopal Iyer 			mac_prop_info_set_default_uint8(prh,
13600dc2366fSVenugopal Iyer 			    (phy_status & MII_SR_10T_HD_CAPS) ? 1 : 0);
1361ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1362ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
13630dc2366fSVenugopal Iyer 
13640dc2366fSVenugopal Iyer 	case MAC_PROP_AUTONEG:
13650dc2366fSVenugopal Iyer 		if (hw->phy.media_type != e1000_media_type_copper) {
13660dc2366fSVenugopal Iyer 			mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
13670dc2366fSVenugopal Iyer 		} else {
13680dc2366fSVenugopal Iyer 			(void) e1000_read_phy_reg(hw, PHY_STATUS, &phy_status);
13690dc2366fSVenugopal Iyer 			mac_prop_info_set_default_uint8(prh,
13700dc2366fSVenugopal Iyer 			    (phy_status & MII_SR_AUTONEG_CAPS) ? 1 : 0);
13710dc2366fSVenugopal Iyer 		}
13720dc2366fSVenugopal Iyer 		break;
13730dc2366fSVenugopal Iyer 
13740dc2366fSVenugopal Iyer 	case MAC_PROP_FLOWCTRL:
13750dc2366fSVenugopal Iyer 		mac_prop_info_set_default_link_flowctrl(prh, LINK_FLOWCTRL_BI);
13760dc2366fSVenugopal Iyer 		break;
13770dc2366fSVenugopal Iyer 
13780dc2366fSVenugopal Iyer 	case MAC_PROP_MTU:
13790dc2366fSVenugopal Iyer 		mac_prop_info_set_range_uint32(prh, MIN_MTU, MAX_MTU);
13800dc2366fSVenugopal Iyer 		break;
13810dc2366fSVenugopal Iyer 
13820dc2366fSVenugopal Iyer 	case MAC_PROP_PRIVATE:
13830dc2366fSVenugopal Iyer 		igb_priv_prop_info(igb, pr_name, prh);
1384ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		break;
1385ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
13860dc2366fSVenugopal Iyer 
1387ac7f5757Schenlu chen - Sun Microsystems - Beijing China }
1388ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1389ac7f5757Schenlu chen - Sun Microsystems - Beijing China boolean_t
igb_param_locked(mac_prop_id_t pr_num)1390ac7f5757Schenlu chen - Sun Microsystems - Beijing China igb_param_locked(mac_prop_id_t pr_num)
1391ac7f5757Schenlu chen - Sun Microsystems - Beijing China {
1392ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	/*
1393ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	 * All en_* parameters are locked (read-only) while
1394ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	 * the device is in any sort of loopback mode ...
1395ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	 */
1396ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	switch (pr_num) {
1397ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case MAC_PROP_EN_1000FDX_CAP:
1398ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case MAC_PROP_EN_1000HDX_CAP:
1399ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case MAC_PROP_EN_100T4_CAP:
1400ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case MAC_PROP_EN_100FDX_CAP:
1401ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case MAC_PROP_EN_100HDX_CAP:
1402ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case MAC_PROP_EN_10FDX_CAP:
1403ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case MAC_PROP_EN_10HDX_CAP:
1404ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case MAC_PROP_AUTONEG:
1405ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		case MAC_PROP_FLOWCTRL:
1406ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			return (B_TRUE);
1407ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1408ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	return (B_FALSE);
1409ac7f5757Schenlu chen - Sun Microsystems - Beijing China }
1410ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1411ac7f5757Schenlu chen - Sun Microsystems - Beijing China /* ARGSUSED */
1412ac7f5757Schenlu chen - Sun Microsystems - Beijing China int
igb_set_priv_prop(igb_t * igb,const char * pr_name,uint_t pr_valsize,const void * pr_val)1413ac7f5757Schenlu chen - Sun Microsystems - Beijing China igb_set_priv_prop(igb_t *igb, const char *pr_name,
1414ac7f5757Schenlu chen - Sun Microsystems - Beijing China     uint_t pr_valsize, const void *pr_val)
1415ac7f5757Schenlu chen - Sun Microsystems - Beijing China {
1416ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	int err = 0;
1417ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	long result;
1418ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	struct e1000_hw *hw = &igb->hw;
1419ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	int i;
1420ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
142143ae5505SDan McDonald 	if (strcmp(pr_name, "_eee_support") == 0) {
142243ae5505SDan McDonald 		if (pr_val == NULL)
142343ae5505SDan McDonald 			return (EINVAL);
142443ae5505SDan McDonald 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
142543ae5505SDan McDonald 		switch (result) {
142643ae5505SDan McDonald 		case 0:
142743ae5505SDan McDonald 		case 1:
142813485e69SGarrett D'Amore 			/*
142913485e69SGarrett D'Amore 			 * For now, only supported on I350/I354.
143013485e69SGarrett D'Amore 			 * Add new mac.type values (or use < instead)
143113485e69SGarrett D'Amore 			 * as new cards offer up EEE.
143213485e69SGarrett D'Amore 			 */
143313485e69SGarrett D'Amore 			switch (hw->mac.type) {
143413485e69SGarrett D'Amore 			case e1000_i350:
143513485e69SGarrett D'Amore 				/* Must set this prior to the set call. */
143613485e69SGarrett D'Amore 				hw->dev_spec._82575.eee_disable = !result;
143749b78600SRobert Mustacchi 				if (e1000_set_eee_i350(hw, result,
143849b78600SRobert Mustacchi 				    result) != E1000_SUCCESS)
143913485e69SGarrett D'Amore 					err = EIO;
144013485e69SGarrett D'Amore 				break;
144113485e69SGarrett D'Amore 			case e1000_i354:
144213485e69SGarrett D'Amore 				/* Must set this prior to the set call. */
144313485e69SGarrett D'Amore 				hw->dev_spec._82575.eee_disable = !result;
144449b78600SRobert Mustacchi 				if (e1000_set_eee_i354(hw, result,
144549b78600SRobert Mustacchi 				    result) != E1000_SUCCESS)
144613485e69SGarrett D'Amore 					err = EIO;
144713485e69SGarrett D'Amore 				break;
144813485e69SGarrett D'Amore 			default:
144943ae5505SDan McDonald 				return (ENXIO);
145043ae5505SDan McDonald 			}
145143ae5505SDan McDonald 			break;
145243ae5505SDan McDonald 		default:
145343ae5505SDan McDonald 			err = EINVAL;
145443ae5505SDan McDonald 			/* FALLTHRU */
145543ae5505SDan McDonald 		}
145643ae5505SDan McDonald 		return (err);
145743ae5505SDan McDonald 	}
1458ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (strcmp(pr_name, "_tx_copy_thresh") == 0) {
1459ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (pr_val == NULL) {
1460ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1461ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			return (err);
1462ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1463ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
1464ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (result < MIN_TX_COPY_THRESHOLD ||
1465ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		    result > MAX_TX_COPY_THRESHOLD)
1466ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1467ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		else {
1468ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->tx_copy_thresh = (uint32_t)result;
1469ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1470ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return (err);
1471ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1472ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (strcmp(pr_name, "_tx_recycle_thresh") == 0) {
1473ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (pr_val == NULL) {
1474ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1475ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			return (err);
1476ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1477ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
1478ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (result < MIN_TX_RECYCLE_THRESHOLD ||
1479ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		    result > MAX_TX_RECYCLE_THRESHOLD)
1480ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1481ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		else {
1482ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->tx_recycle_thresh = (uint32_t)result;
1483ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1484ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return (err);
1485ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1486ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (strcmp(pr_name, "_tx_overload_thresh") == 0) {
1487ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (pr_val == NULL) {
1488ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1489ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			return (err);
1490ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1491ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
1492ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (result < MIN_TX_OVERLOAD_THRESHOLD ||
1493ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		    result > MAX_TX_OVERLOAD_THRESHOLD)
1494ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1495ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		else {
1496ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->tx_overload_thresh = (uint32_t)result;
1497ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1498ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return (err);
1499ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1500ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (strcmp(pr_name, "_tx_resched_thresh") == 0) {
1501ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (pr_val == NULL) {
1502ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1503ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			return (err);
1504ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1505ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
1506ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (result < MIN_TX_RESCHED_THRESHOLD ||
150769b2d733SGuoqing Zhu 		    result > MAX_TX_RESCHED_THRESHOLD ||
150869b2d733SGuoqing Zhu 		    result > igb->tx_ring_size)
1509ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1510ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		else {
1511ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->tx_resched_thresh = (uint32_t)result;
1512ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1513ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return (err);
1514ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1515ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (strcmp(pr_name, "_rx_copy_thresh") == 0) {
1516ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (pr_val == NULL) {
1517ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1518ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			return (err);
1519ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1520ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
1521ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (result < MIN_RX_COPY_THRESHOLD ||
1522ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		    result > MAX_RX_COPY_THRESHOLD)
1523ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1524ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		else {
1525ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->rx_copy_thresh = (uint32_t)result;
1526ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1527ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return (err);
1528ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1529ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (strcmp(pr_name, "_rx_limit_per_intr") == 0) {
1530ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (pr_val == NULL) {
1531ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1532ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			return (err);
1533ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1534ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
1535ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (result < MIN_RX_LIMIT_PER_INTR ||
1536ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		    result > MAX_RX_LIMIT_PER_INTR)
1537ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1538ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		else {
1539ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->rx_limit_per_intr = (uint32_t)result;
1540ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1541ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return (err);
1542ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1543ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (strcmp(pr_name, "_intr_throttling") == 0) {
1544ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (pr_val == NULL) {
1545ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1546ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			return (err);
1547ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1548ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
1549ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1550ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		if (result < igb->capab->min_intr_throttle ||
1551ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		    result > igb->capab->max_intr_throttle)
1552ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			err = EINVAL;
1553ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		else {
1554ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			igb->intr_throttling[0] = (uint32_t)result;
1555ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1556ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			for (i = 0; i < MAX_NUM_EITR; i++)
1557ac7f5757Schenlu chen - Sun Microsystems - Beijing China 				igb->intr_throttling[i] =
1558ac7f5757Schenlu chen - Sun Microsystems - Beijing China 				    igb->intr_throttling[0];
1559ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1560ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			/* Set interrupt throttling rate */
1561ac7f5757Schenlu chen - Sun Microsystems - Beijing China 			for (i = 0; i < igb->intr_cnt; i++)
1562ac7f5757Schenlu chen - Sun Microsystems - Beijing China 				E1000_WRITE_REG(hw, E1000_EITR(i),
1563ac7f5757Schenlu chen - Sun Microsystems - Beijing China 				    igb->intr_throttling[i]);
1564ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		}
1565ac7f5757Schenlu chen - Sun Microsystems - Beijing China 		return (err);
1566ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
1567ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	return (ENOTSUP);
1568ac7f5757Schenlu chen - Sun Microsystems - Beijing China }
1569ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1570ac7f5757Schenlu chen - Sun Microsystems - Beijing China int
igb_get_priv_prop(igb_t * igb,const char * pr_name,uint_t pr_valsize,void * pr_val)15710dc2366fSVenugopal Iyer igb_get_priv_prop(igb_t *igb, const char *pr_name, uint_t pr_valsize,
15720dc2366fSVenugopal Iyer     void *pr_val)
1573ac7f5757Schenlu chen - Sun Microsystems - Beijing China {
1574ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	int value;
1575ac7f5757Schenlu chen - Sun Microsystems - Beijing China 
1576ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	if (strcmp(pr_name, "_adv_pause_cap") == 0) {
15770dc2366fSVenugopal Iyer 		value = igb->param_adv_pause_cap;
15780dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_adv_asym_pause_cap") == 0) {
15790dc2366fSVenugopal Iyer 		value = igb->param_adv_asym_pause_cap;
158043ae5505SDan McDonald 	} else if (strcmp(pr_name, "_eee_support") == 0) {
158143ae5505SDan McDonald 		/*
158243ae5505SDan McDonald 		 * For now, only supported on I350.  Add new mac.type values
158343ae5505SDan McDonald 		 * (or use < instead) as new cards offer up EEE.
158443ae5505SDan McDonald 		 */
158513485e69SGarrett D'Amore 		switch (igb->hw.mac.type) {
158613485e69SGarrett D'Amore 		case e1000_i350:
158713485e69SGarrett D'Amore 		case e1000_i354:
158813485e69SGarrett D'Amore 			value = !(igb->hw.dev_spec._82575.eee_disable);
158913485e69SGarrett D'Amore 			break;
159013485e69SGarrett D'Amore 		default:
159113485e69SGarrett D'Amore 			value = 0;
159213485e69SGarrett D'Amore 		}
15930dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_tx_copy_thresh") == 0) {
15940dc2366fSVenugopal Iyer 		value = igb->tx_copy_thresh;
15950dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_tx_recycle_thresh") == 0) {
15960dc2366fSVenugopal Iyer 		value = igb->tx_recycle_thresh;
15970dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_tx_overload_thresh") == 0) {
15980dc2366fSVenugopal Iyer 		value = igb->tx_overload_thresh;
15990dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_tx_resched_thresh") == 0) {
16000dc2366fSVenugopal Iyer 		value = igb->tx_resched_thresh;
16010dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_rx_copy_thresh") == 0) {
16020dc2366fSVenugopal Iyer 		value = igb->rx_copy_thresh;
16030dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_rx_limit_per_intr") == 0) {
16040dc2366fSVenugopal Iyer 		value = igb->rx_limit_per_intr;
16050dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_intr_throttling") == 0) {
16060dc2366fSVenugopal Iyer 		value = igb->intr_throttling[0];
16070dc2366fSVenugopal Iyer 	} else {
16080dc2366fSVenugopal Iyer 		return (ENOTSUP);
1609ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
16100dc2366fSVenugopal Iyer 
16110dc2366fSVenugopal Iyer 	(void) snprintf(pr_val, pr_valsize, "%d", value);
16120dc2366fSVenugopal Iyer 	return (0);
16130dc2366fSVenugopal Iyer }
16140dc2366fSVenugopal Iyer 
16150dc2366fSVenugopal Iyer void
igb_priv_prop_info(igb_t * igb,const char * pr_name,mac_prop_info_handle_t prh)16160dc2366fSVenugopal Iyer igb_priv_prop_info(igb_t *igb, const char *pr_name, mac_prop_info_handle_t prh)
16170dc2366fSVenugopal Iyer {
16180dc2366fSVenugopal Iyer 	char valstr[64];
16190dc2366fSVenugopal Iyer 	int value;
16200dc2366fSVenugopal Iyer 
16210dc2366fSVenugopal Iyer 	if (strcmp(pr_name, "_adv_pause_cap") == 0 ||
16220dc2366fSVenugopal Iyer 	    strcmp(pr_name, "_adv_asym_pause_cap") == 0) {
16230dc2366fSVenugopal Iyer 		mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
16240dc2366fSVenugopal Iyer 		return;
16250dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_tx_copy_thresh") == 0) {
16260dc2366fSVenugopal Iyer 		value = DEFAULT_TX_COPY_THRESHOLD;
16270dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_tx_recycle_thresh") == 0) {
16280dc2366fSVenugopal Iyer 		value = DEFAULT_TX_RECYCLE_THRESHOLD;
16290dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_tx_overload_thresh") == 0) {
16300dc2366fSVenugopal Iyer 		value = DEFAULT_TX_OVERLOAD_THRESHOLD;
16310dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_tx_resched_thresh") == 0) {
16320dc2366fSVenugopal Iyer 		value = DEFAULT_TX_RESCHED_THRESHOLD;
16330dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_rx_copy_thresh") == 0) {
16340dc2366fSVenugopal Iyer 		value = DEFAULT_RX_COPY_THRESHOLD;
16350dc2366fSVenugopal Iyer 	} else if (strcmp(pr_name, "_rx_limit_per_intr") == 0) {
16360dc2366fSVenugopal Iyer 		value = DEFAULT_RX_LIMIT_PER_INTR;
163785f496faSRobert Mustacchi 	} else if (strcmp(pr_name, "_intr_throttling") == 0) {
16380dc2366fSVenugopal Iyer 		value = igb->capab->def_intr_throttle;
16390dc2366fSVenugopal Iyer 	} else {
16400dc2366fSVenugopal Iyer 		return;
1641ac7f5757Schenlu chen - Sun Microsystems - Beijing China 	}
16420dc2366fSVenugopal Iyer 
16430dc2366fSVenugopal Iyer 	(void) snprintf(valstr, sizeof (valstr), "%d", value);
16440dc2366fSVenugopal Iyer 	mac_prop_info_set_default_str(prh, valstr);
1645ac7f5757Schenlu chen - Sun Microsystems - Beijing China }
1646