xref: /onnv-gate/usr/src/uts/common/io/ixgbe/ixgbe_gld.c (revision 13006:22e6d3edaab5)
16621Sbt150084 /*
26621Sbt150084  * CDDL HEADER START
36621Sbt150084  *
46621Sbt150084  * The contents of this file are subject to the terms of the
56621Sbt150084  * Common Development and Distribution License (the "License").
66621Sbt150084  * You may not use this file except in compliance with the License.
76621Sbt150084  *
88275SEric Cheng  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
98275SEric Cheng  * or http://www.opensolaris.org/os/licensing.
106621Sbt150084  * See the License for the specific language governing permissions
116621Sbt150084  * and limitations under the License.
126621Sbt150084  *
138275SEric Cheng  * When distributing Covered Code, include this CDDL HEADER in each
148275SEric Cheng  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156621Sbt150084  * If applicable, add the following below this CDDL HEADER, with the
166621Sbt150084  * fields enclosed by brackets "[]" replaced with your own identifying
176621Sbt150084  * information: Portions Copyright [yyyy] [name of copyright owner]
186621Sbt150084  *
196621Sbt150084  * CDDL HEADER END
206621Sbt150084  */
216621Sbt150084 
226621Sbt150084 /*
23*13006SChenlu.Chen@Sun.COM  * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
24*13006SChenlu.Chen@Sun.COM  */
25*13006SChenlu.Chen@Sun.COM 
26*13006SChenlu.Chen@Sun.COM /*
27*13006SChenlu.Chen@Sun.COM  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
288275SEric Cheng  */
296621Sbt150084 
306621Sbt150084 #include "ixgbe_sw.h"
316621Sbt150084 
326621Sbt150084 /*
336621Sbt150084  * Bring the device out of the reset/quiesced state that it
346621Sbt150084  * was in when the interface was registered.
356621Sbt150084  */
366621Sbt150084 int
ixgbe_m_start(void * arg)376621Sbt150084 ixgbe_m_start(void *arg)
386621Sbt150084 {
396621Sbt150084 	ixgbe_t *ixgbe = (ixgbe_t *)arg;
406621Sbt150084 
416621Sbt150084 	mutex_enter(&ixgbe->gen_lock);
426621Sbt150084 
436621Sbt150084 	if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
446621Sbt150084 		mutex_exit(&ixgbe->gen_lock);
456621Sbt150084 		return (ECANCELED);
466621Sbt150084 	}
476621Sbt150084 
4810376SChenlu.Chen@Sun.COM 	if (ixgbe_start(ixgbe, B_TRUE) != IXGBE_SUCCESS) {
496621Sbt150084 		mutex_exit(&ixgbe->gen_lock);
506621Sbt150084 		return (EIO);
516621Sbt150084 	}
526621Sbt150084 
5311233SPaul.Guo@Sun.COM 	atomic_or_32(&ixgbe->ixgbe_state, IXGBE_STARTED);
546621Sbt150084 
556621Sbt150084 	mutex_exit(&ixgbe->gen_lock);
566621Sbt150084 
576621Sbt150084 	/*
586621Sbt150084 	 * Enable and start the watchdog timer
596621Sbt150084 	 */
606621Sbt150084 	ixgbe_enable_watchdog_timer(ixgbe);
616621Sbt150084 
626621Sbt150084 	return (0);
636621Sbt150084 }
646621Sbt150084 
656621Sbt150084 /*
666621Sbt150084  * Stop the device and put it in a reset/quiesced state such
676621Sbt150084  * that the interface can be unregistered.
686621Sbt150084  */
696621Sbt150084 void
ixgbe_m_stop(void * arg)706621Sbt150084 ixgbe_m_stop(void *arg)
716621Sbt150084 {
726621Sbt150084 	ixgbe_t *ixgbe = (ixgbe_t *)arg;
736621Sbt150084 
746621Sbt150084 	mutex_enter(&ixgbe->gen_lock);
756621Sbt150084 
766621Sbt150084 	if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
776621Sbt150084 		mutex_exit(&ixgbe->gen_lock);
786621Sbt150084 		return;
796621Sbt150084 	}
806621Sbt150084 
8111233SPaul.Guo@Sun.COM 	atomic_and_32(&ixgbe->ixgbe_state, ~IXGBE_STARTED);
826621Sbt150084 
8310376SChenlu.Chen@Sun.COM 	ixgbe_stop(ixgbe, B_TRUE);
846621Sbt150084 
856621Sbt150084 	mutex_exit(&ixgbe->gen_lock);
866621Sbt150084 
876621Sbt150084 	/*
886621Sbt150084 	 * Disable and stop the watchdog timer
896621Sbt150084 	 */
906621Sbt150084 	ixgbe_disable_watchdog_timer(ixgbe);
916621Sbt150084 }
926621Sbt150084 
936621Sbt150084 /*
946621Sbt150084  * Set the promiscuity of the device.
956621Sbt150084  */
966621Sbt150084 int
ixgbe_m_promisc(void * arg,boolean_t on)976621Sbt150084 ixgbe_m_promisc(void *arg, boolean_t on)
986621Sbt150084 {
996621Sbt150084 	ixgbe_t *ixgbe = (ixgbe_t *)arg;
1006621Sbt150084 	uint32_t reg_val;
1016621Sbt150084 	struct ixgbe_hw *hw = &ixgbe->hw;
1026621Sbt150084 
1036621Sbt150084 	mutex_enter(&ixgbe->gen_lock);
1046621Sbt150084 
1056621Sbt150084 	if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
1066621Sbt150084 		mutex_exit(&ixgbe->gen_lock);
1076621Sbt150084 		return (ECANCELED);
1086621Sbt150084 	}
1096621Sbt150084 	reg_val = IXGBE_READ_REG(hw, IXGBE_FCTRL);
1106621Sbt150084 
1116621Sbt150084 	if (on)
1126621Sbt150084 		reg_val |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
1136621Sbt150084 	else
1146621Sbt150084 		reg_val &= (~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE));
1156621Sbt150084 
1166621Sbt150084 	IXGBE_WRITE_REG(&ixgbe->hw, IXGBE_FCTRL, reg_val);
1176621Sbt150084 
1186621Sbt150084 	mutex_exit(&ixgbe->gen_lock);
1196621Sbt150084 
1206621Sbt150084 	return (0);
1216621Sbt150084 }
1226621Sbt150084 
1236621Sbt150084 /*
1246621Sbt150084  * Add/remove the addresses to/from the set of multicast
1256621Sbt150084  * addresses for which the device will receive packets.
1266621Sbt150084  */
1276621Sbt150084 int
ixgbe_m_multicst(void * arg,boolean_t add,const uint8_t * mcst_addr)1286621Sbt150084 ixgbe_m_multicst(void *arg, boolean_t add, const uint8_t *mcst_addr)
1296621Sbt150084 {
1306621Sbt150084 	ixgbe_t *ixgbe = (ixgbe_t *)arg;
1316621Sbt150084 	int result;
1326621Sbt150084 
1336621Sbt150084 	mutex_enter(&ixgbe->gen_lock);
1346621Sbt150084 
1356621Sbt150084 	if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
1366621Sbt150084 		mutex_exit(&ixgbe->gen_lock);
1376621Sbt150084 		return (ECANCELED);
1386621Sbt150084 	}
1396621Sbt150084 
1406621Sbt150084 	result = (add) ? ixgbe_multicst_add(ixgbe, mcst_addr)
1416621Sbt150084 	    : ixgbe_multicst_remove(ixgbe, mcst_addr);
1426621Sbt150084 
1436621Sbt150084 	mutex_exit(&ixgbe->gen_lock);
1446621Sbt150084 
1456621Sbt150084 	return (result);
1466621Sbt150084 }
1476621Sbt150084 
1486621Sbt150084 /*
1496621Sbt150084  * Pass on M_IOCTL messages passed to the DLD, and support
1506621Sbt150084  * private IOCTLs for debugging and ndd.
1516621Sbt150084  */
1526621Sbt150084 void
ixgbe_m_ioctl(void * arg,queue_t * q,mblk_t * mp)1536621Sbt150084 ixgbe_m_ioctl(void *arg, queue_t *q, mblk_t *mp)
1546621Sbt150084 {
1556621Sbt150084 	ixgbe_t *ixgbe = (ixgbe_t *)arg;
1566621Sbt150084 	struct iocblk *iocp;
1576621Sbt150084 	enum ioc_reply status;
1586621Sbt150084 
1596621Sbt150084 	iocp = (struct iocblk *)(uintptr_t)mp->b_rptr;
1606621Sbt150084 	iocp->ioc_error = 0;
1616621Sbt150084 
16210376SChenlu.Chen@Sun.COM 	mutex_enter(&ixgbe->gen_lock);
16310376SChenlu.Chen@Sun.COM 	if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
16410376SChenlu.Chen@Sun.COM 		mutex_exit(&ixgbe->gen_lock);
16510376SChenlu.Chen@Sun.COM 		miocnak(q, mp, 0, EINVAL);
16610376SChenlu.Chen@Sun.COM 		return;
16710376SChenlu.Chen@Sun.COM 	}
16810376SChenlu.Chen@Sun.COM 	mutex_exit(&ixgbe->gen_lock);
16910376SChenlu.Chen@Sun.COM 
1706621Sbt150084 	switch (iocp->ioc_cmd) {
1716621Sbt150084 	case LB_GET_INFO_SIZE:
1726621Sbt150084 	case LB_GET_INFO:
1736621Sbt150084 	case LB_GET_MODE:
1746621Sbt150084 	case LB_SET_MODE:
1756621Sbt150084 		status = ixgbe_loopback_ioctl(ixgbe, iocp, mp);
1766621Sbt150084 		break;
1776621Sbt150084 
1786621Sbt150084 	default:
1796621Sbt150084 		status = IOC_INVAL;
1806621Sbt150084 		break;
1816621Sbt150084 	}
1826621Sbt150084 
1836621Sbt150084 	/*
1846621Sbt150084 	 * Decide how to reply
1856621Sbt150084 	 */
1866621Sbt150084 	switch (status) {
1876621Sbt150084 	default:
1886621Sbt150084 	case IOC_INVAL:
1896621Sbt150084 		/*
1906621Sbt150084 		 * Error, reply with a NAK and EINVAL or the specified error
1916621Sbt150084 		 */
1926621Sbt150084 		miocnak(q, mp, 0, iocp->ioc_error == 0 ?
1936621Sbt150084 		    EINVAL : iocp->ioc_error);
1946621Sbt150084 		break;
1956621Sbt150084 
1966621Sbt150084 	case IOC_DONE:
1976621Sbt150084 		/*
1986621Sbt150084 		 * OK, reply already sent
1996621Sbt150084 		 */
2006621Sbt150084 		break;
2016621Sbt150084 
2026621Sbt150084 	case IOC_ACK:
2036621Sbt150084 		/*
2046621Sbt150084 		 * OK, reply with an ACK
2056621Sbt150084 		 */
2066621Sbt150084 		miocack(q, mp, 0, 0);
2076621Sbt150084 		break;
2086621Sbt150084 
2096621Sbt150084 	case IOC_REPLY:
2106621Sbt150084 		/*
2116621Sbt150084 		 * OK, send prepared reply as ACK or NAK
2126621Sbt150084 		 */
2136621Sbt150084 		mp->b_datap->db_type = iocp->ioc_error == 0 ?
2146621Sbt150084 		    M_IOCACK : M_IOCNAK;
2156621Sbt150084 		qreply(q, mp);
2166621Sbt150084 		break;
2176621Sbt150084 	}
2186621Sbt150084 }
2196621Sbt150084 
2206621Sbt150084 /*
2216621Sbt150084  * Obtain the MAC's capabilities and associated data from
2226621Sbt150084  * the driver.
2236621Sbt150084  */
2246621Sbt150084 boolean_t
ixgbe_m_getcapab(void * arg,mac_capab_t cap,void * cap_data)2256621Sbt150084 ixgbe_m_getcapab(void *arg, mac_capab_t cap, void *cap_data)
2266621Sbt150084 {
2276621Sbt150084 	ixgbe_t *ixgbe = (ixgbe_t *)arg;
2286621Sbt150084 
2296621Sbt150084 	switch (cap) {
2306621Sbt150084 	case MAC_CAPAB_HCKSUM: {
2316621Sbt150084 		uint32_t *tx_hcksum_flags = cap_data;
2326621Sbt150084 
2336621Sbt150084 		/*
2346621Sbt150084 		 * We advertise our capabilities only if tx hcksum offload is
2356621Sbt150084 		 * enabled.  On receive, the stack will accept checksummed
2366621Sbt150084 		 * packets anyway, even if we haven't said we can deliver
2376621Sbt150084 		 * them.
2386621Sbt150084 		 */
2396621Sbt150084 		if (!ixgbe->tx_hcksum_enable)
2406621Sbt150084 			return (B_FALSE);
2416621Sbt150084 
2426621Sbt150084 		*tx_hcksum_flags = HCKSUM_INET_PARTIAL | HCKSUM_IPHDRCKSUM;
2436621Sbt150084 		break;
2446621Sbt150084 	}
2457167Sgg161487 	case MAC_CAPAB_LSO: {
2467167Sgg161487 		mac_capab_lso_t *cap_lso = cap_data;
2477167Sgg161487 
2487167Sgg161487 		if (ixgbe->lso_enable) {
2497167Sgg161487 			cap_lso->lso_flags = LSO_TX_BASIC_TCP_IPV4;
2507167Sgg161487 			cap_lso->lso_basic_tcp_ipv4.lso_max = IXGBE_LSO_MAXLEN;
2517167Sgg161487 			break;
2527167Sgg161487 		} else {
2537167Sgg161487 			return (B_FALSE);
2547167Sgg161487 		}
2557167Sgg161487 	}
2568275SEric Cheng 	case MAC_CAPAB_RINGS: {
2578275SEric Cheng 		mac_capab_rings_t *cap_rings = cap_data;
2586621Sbt150084 
2598275SEric Cheng 		switch (cap_rings->mr_type) {
2608275SEric Cheng 		case MAC_RING_TYPE_RX:
2618275SEric Cheng 			cap_rings->mr_group_type = MAC_GROUP_TYPE_STATIC;
2628275SEric Cheng 			cap_rings->mr_rnum = ixgbe->num_rx_rings;
2638275SEric Cheng 			cap_rings->mr_gnum = ixgbe->num_rx_groups;
2648275SEric Cheng 			cap_rings->mr_rget = ixgbe_fill_ring;
2658275SEric Cheng 			cap_rings->mr_gget = ixgbe_fill_group;
2668275SEric Cheng 			cap_rings->mr_gaddring = NULL;
2678275SEric Cheng 			cap_rings->mr_gremring = NULL;
2688275SEric Cheng 			break;
2698275SEric Cheng 		case MAC_RING_TYPE_TX:
2708275SEric Cheng 			cap_rings->mr_group_type = MAC_GROUP_TYPE_STATIC;
2718275SEric Cheng 			cap_rings->mr_rnum = ixgbe->num_tx_rings;
2728275SEric Cheng 			cap_rings->mr_gnum = 0;
2738275SEric Cheng 			cap_rings->mr_rget = ixgbe_fill_ring;
2748275SEric Cheng 			cap_rings->mr_gget = NULL;
2758275SEric Cheng 			break;
2768275SEric Cheng 		default:
2778275SEric Cheng 			break;
2788275SEric Cheng 		}
2796621Sbt150084 		break;
2806621Sbt150084 	}
2816621Sbt150084 	default:
2826621Sbt150084 		return (B_FALSE);
2836621Sbt150084 	}
2846621Sbt150084 	return (B_TRUE);
2856621Sbt150084 }
28610376SChenlu.Chen@Sun.COM 
28710376SChenlu.Chen@Sun.COM int
ixgbe_m_setprop(void * arg,const char * pr_name,mac_prop_id_t pr_num,uint_t pr_valsize,const void * pr_val)28810376SChenlu.Chen@Sun.COM ixgbe_m_setprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
28910376SChenlu.Chen@Sun.COM     uint_t pr_valsize, const void *pr_val)
29010376SChenlu.Chen@Sun.COM {
29110376SChenlu.Chen@Sun.COM 	ixgbe_t *ixgbe = (ixgbe_t *)arg;
29210376SChenlu.Chen@Sun.COM 	struct ixgbe_hw *hw = &ixgbe->hw;
29310376SChenlu.Chen@Sun.COM 	int err = 0;
29410376SChenlu.Chen@Sun.COM 	uint32_t flow_control;
29510376SChenlu.Chen@Sun.COM 	uint32_t cur_mtu, new_mtu;
29610376SChenlu.Chen@Sun.COM 	uint32_t rx_size;
29710376SChenlu.Chen@Sun.COM 	uint32_t tx_size;
29810376SChenlu.Chen@Sun.COM 
29910376SChenlu.Chen@Sun.COM 	mutex_enter(&ixgbe->gen_lock);
30010376SChenlu.Chen@Sun.COM 	if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
30110376SChenlu.Chen@Sun.COM 		mutex_exit(&ixgbe->gen_lock);
30210376SChenlu.Chen@Sun.COM 		return (ECANCELED);
30310376SChenlu.Chen@Sun.COM 	}
30410376SChenlu.Chen@Sun.COM 
30510376SChenlu.Chen@Sun.COM 	if (ixgbe->loopback_mode != IXGBE_LB_NONE &&
30610376SChenlu.Chen@Sun.COM 	    ixgbe_param_locked(pr_num)) {
30710376SChenlu.Chen@Sun.COM 		/*
30810376SChenlu.Chen@Sun.COM 		 * All en_* parameters are locked (read-only)
30910376SChenlu.Chen@Sun.COM 		 * while the device is in any sort of loopback mode.
31010376SChenlu.Chen@Sun.COM 		 */
31110376SChenlu.Chen@Sun.COM 		mutex_exit(&ixgbe->gen_lock);
31210376SChenlu.Chen@Sun.COM 		return (EBUSY);
31310376SChenlu.Chen@Sun.COM 	}
31410376SChenlu.Chen@Sun.COM 
31510376SChenlu.Chen@Sun.COM 	switch (pr_num) {
31610376SChenlu.Chen@Sun.COM 	case MAC_PROP_EN_10GFDX_CAP:
31710376SChenlu.Chen@Sun.COM 		/* read/write on copper, read-only on serdes */
31810376SChenlu.Chen@Sun.COM 		if (ixgbe->hw.phy.media_type != ixgbe_media_type_copper) {
31910376SChenlu.Chen@Sun.COM 			err = ENOTSUP;
32010376SChenlu.Chen@Sun.COM 			break;
32110376SChenlu.Chen@Sun.COM 		} else {
32210376SChenlu.Chen@Sun.COM 			ixgbe->param_en_10000fdx_cap = *(uint8_t *)pr_val;
32310376SChenlu.Chen@Sun.COM 			ixgbe->param_adv_10000fdx_cap = *(uint8_t *)pr_val;
32410376SChenlu.Chen@Sun.COM 			goto setup_link;
32510376SChenlu.Chen@Sun.COM 		}
32610376SChenlu.Chen@Sun.COM 	case MAC_PROP_EN_1000FDX_CAP:
32710376SChenlu.Chen@Sun.COM 		/* read/write on copper, read-only on serdes */
32810376SChenlu.Chen@Sun.COM 		if (ixgbe->hw.phy.media_type != ixgbe_media_type_copper) {
32910376SChenlu.Chen@Sun.COM 			err = ENOTSUP;
33010376SChenlu.Chen@Sun.COM 			break;
33110376SChenlu.Chen@Sun.COM 		} else {
33210376SChenlu.Chen@Sun.COM 			ixgbe->param_en_1000fdx_cap = *(uint8_t *)pr_val;
33310376SChenlu.Chen@Sun.COM 			ixgbe->param_adv_1000fdx_cap = *(uint8_t *)pr_val;
33410376SChenlu.Chen@Sun.COM 			goto setup_link;
33510376SChenlu.Chen@Sun.COM 		}
33610376SChenlu.Chen@Sun.COM 	case MAC_PROP_EN_100FDX_CAP:
33710376SChenlu.Chen@Sun.COM 		/* read/write on copper, read-only on serdes */
33810376SChenlu.Chen@Sun.COM 		if (ixgbe->hw.phy.media_type != ixgbe_media_type_copper) {
33910376SChenlu.Chen@Sun.COM 			err = ENOTSUP;
34010376SChenlu.Chen@Sun.COM 			break;
34110376SChenlu.Chen@Sun.COM 		} else {
34210376SChenlu.Chen@Sun.COM 			ixgbe->param_en_100fdx_cap = *(uint8_t *)pr_val;
34310376SChenlu.Chen@Sun.COM 			ixgbe->param_adv_100fdx_cap = *(uint8_t *)pr_val;
34410376SChenlu.Chen@Sun.COM 			goto setup_link;
34510376SChenlu.Chen@Sun.COM 		}
34610376SChenlu.Chen@Sun.COM 	case MAC_PROP_AUTONEG:
34710376SChenlu.Chen@Sun.COM 		/* read/write on copper, read-only on serdes */
34810376SChenlu.Chen@Sun.COM 		if (ixgbe->hw.phy.media_type != ixgbe_media_type_copper) {
34910376SChenlu.Chen@Sun.COM 			err = ENOTSUP;
35010376SChenlu.Chen@Sun.COM 			break;
35110376SChenlu.Chen@Sun.COM 		} else {
35210376SChenlu.Chen@Sun.COM 			ixgbe->param_adv_autoneg_cap = *(uint8_t *)pr_val;
35310376SChenlu.Chen@Sun.COM 			goto setup_link;
35410376SChenlu.Chen@Sun.COM 		}
35510376SChenlu.Chen@Sun.COM 	case MAC_PROP_FLOWCTRL:
35610376SChenlu.Chen@Sun.COM 		bcopy(pr_val, &flow_control, sizeof (flow_control));
35710376SChenlu.Chen@Sun.COM 
35810376SChenlu.Chen@Sun.COM 		switch (flow_control) {
35910376SChenlu.Chen@Sun.COM 		default:
36010376SChenlu.Chen@Sun.COM 			err = EINVAL;
36110376SChenlu.Chen@Sun.COM 			break;
36210376SChenlu.Chen@Sun.COM 		case LINK_FLOWCTRL_NONE:
36310376SChenlu.Chen@Sun.COM 			hw->fc.requested_mode = ixgbe_fc_none;
36410376SChenlu.Chen@Sun.COM 			break;
36510376SChenlu.Chen@Sun.COM 		case LINK_FLOWCTRL_RX:
36610376SChenlu.Chen@Sun.COM 			hw->fc.requested_mode = ixgbe_fc_rx_pause;
36710376SChenlu.Chen@Sun.COM 			break;
36810376SChenlu.Chen@Sun.COM 		case LINK_FLOWCTRL_TX:
36910376SChenlu.Chen@Sun.COM 			hw->fc.requested_mode = ixgbe_fc_tx_pause;
37010376SChenlu.Chen@Sun.COM 			break;
37110376SChenlu.Chen@Sun.COM 		case LINK_FLOWCTRL_BI:
37210376SChenlu.Chen@Sun.COM 			hw->fc.requested_mode = ixgbe_fc_full;
37310376SChenlu.Chen@Sun.COM 			break;
37410376SChenlu.Chen@Sun.COM 		}
37510376SChenlu.Chen@Sun.COM setup_link:
37610376SChenlu.Chen@Sun.COM 		if (err == 0) {
37710376SChenlu.Chen@Sun.COM 			if (ixgbe_driver_setup_link(ixgbe, B_TRUE) !=
37810376SChenlu.Chen@Sun.COM 			    IXGBE_SUCCESS)
37910376SChenlu.Chen@Sun.COM 				err = EINVAL;
38010376SChenlu.Chen@Sun.COM 		}
38110376SChenlu.Chen@Sun.COM 		break;
38210376SChenlu.Chen@Sun.COM 	case MAC_PROP_ADV_10GFDX_CAP:
38310376SChenlu.Chen@Sun.COM 	case MAC_PROP_ADV_1000FDX_CAP:
38410376SChenlu.Chen@Sun.COM 	case MAC_PROP_ADV_100FDX_CAP:
38510376SChenlu.Chen@Sun.COM 	case MAC_PROP_STATUS:
38610376SChenlu.Chen@Sun.COM 	case MAC_PROP_SPEED:
38710376SChenlu.Chen@Sun.COM 	case MAC_PROP_DUPLEX:
38810376SChenlu.Chen@Sun.COM 		err = ENOTSUP; /* read-only prop. Can't set this. */
38910376SChenlu.Chen@Sun.COM 		break;
39010376SChenlu.Chen@Sun.COM 	case MAC_PROP_MTU:
39110376SChenlu.Chen@Sun.COM 		cur_mtu = ixgbe->default_mtu;
39210376SChenlu.Chen@Sun.COM 		bcopy(pr_val, &new_mtu, sizeof (new_mtu));
39310376SChenlu.Chen@Sun.COM 		if (new_mtu == cur_mtu) {
39410376SChenlu.Chen@Sun.COM 			err = 0;
39510376SChenlu.Chen@Sun.COM 			break;
39610376SChenlu.Chen@Sun.COM 		}
39710376SChenlu.Chen@Sun.COM 
39811150SZhen.W@Sun.COM 		if (new_mtu < DEFAULT_MTU || new_mtu > ixgbe->capab->max_mtu) {
39910376SChenlu.Chen@Sun.COM 			err = EINVAL;
40010376SChenlu.Chen@Sun.COM 			break;
40110376SChenlu.Chen@Sun.COM 		}
40210376SChenlu.Chen@Sun.COM 
40310376SChenlu.Chen@Sun.COM 		if (ixgbe->ixgbe_state & IXGBE_STARTED) {
40410376SChenlu.Chen@Sun.COM 			err = EBUSY;
40510376SChenlu.Chen@Sun.COM 			break;
40610376SChenlu.Chen@Sun.COM 		}
40710376SChenlu.Chen@Sun.COM 
40810376SChenlu.Chen@Sun.COM 		err = mac_maxsdu_update(ixgbe->mac_hdl, new_mtu);
40910376SChenlu.Chen@Sun.COM 		if (err == 0) {
41010376SChenlu.Chen@Sun.COM 			ixgbe->default_mtu = new_mtu;
41110376SChenlu.Chen@Sun.COM 			ixgbe->max_frame_size = ixgbe->default_mtu +
41210376SChenlu.Chen@Sun.COM 			    sizeof (struct ether_vlan_header) + ETHERFCSL;
41310376SChenlu.Chen@Sun.COM 
41410376SChenlu.Chen@Sun.COM 			/*
41510376SChenlu.Chen@Sun.COM 			 * Set rx buffer size
41610376SChenlu.Chen@Sun.COM 			 */
41710376SChenlu.Chen@Sun.COM 			rx_size = ixgbe->max_frame_size + IPHDR_ALIGN_ROOM;
41810376SChenlu.Chen@Sun.COM 			ixgbe->rx_buf_size = ((rx_size >> 10) + ((rx_size &
41910376SChenlu.Chen@Sun.COM 			    (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
42010376SChenlu.Chen@Sun.COM 
42110376SChenlu.Chen@Sun.COM 			/*
42210376SChenlu.Chen@Sun.COM 			 * Set tx buffer size
42310376SChenlu.Chen@Sun.COM 			 */
42410376SChenlu.Chen@Sun.COM 			tx_size = ixgbe->max_frame_size;
42510376SChenlu.Chen@Sun.COM 			ixgbe->tx_buf_size = ((tx_size >> 10) + ((tx_size &
42610376SChenlu.Chen@Sun.COM 			    (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
42710376SChenlu.Chen@Sun.COM 		}
42810376SChenlu.Chen@Sun.COM 		break;
42910376SChenlu.Chen@Sun.COM 	case MAC_PROP_PRIVATE:
43010376SChenlu.Chen@Sun.COM 		err = ixgbe_set_priv_prop(ixgbe, pr_name, pr_valsize, pr_val);
43110376SChenlu.Chen@Sun.COM 		break;
43210376SChenlu.Chen@Sun.COM 	default:
43310376SChenlu.Chen@Sun.COM 		err = EINVAL;
43410376SChenlu.Chen@Sun.COM 		break;
43510376SChenlu.Chen@Sun.COM 	}
43610376SChenlu.Chen@Sun.COM 	mutex_exit(&ixgbe->gen_lock);
43710376SChenlu.Chen@Sun.COM 	return (err);
43810376SChenlu.Chen@Sun.COM }
43910376SChenlu.Chen@Sun.COM 
44010376SChenlu.Chen@Sun.COM int
ixgbe_m_getprop(void * arg,const char * pr_name,mac_prop_id_t pr_num,uint_t pr_valsize,void * pr_val)44110376SChenlu.Chen@Sun.COM ixgbe_m_getprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
44211878SVenu.Iyer@Sun.COM     uint_t pr_valsize, void *pr_val)
44310376SChenlu.Chen@Sun.COM {
44410376SChenlu.Chen@Sun.COM 	ixgbe_t *ixgbe = (ixgbe_t *)arg;
44510376SChenlu.Chen@Sun.COM 	struct ixgbe_hw *hw = &ixgbe->hw;
44610376SChenlu.Chen@Sun.COM 	int err = 0;
44710376SChenlu.Chen@Sun.COM 	uint32_t flow_control;
44810376SChenlu.Chen@Sun.COM 	uint64_t tmp = 0;
44910376SChenlu.Chen@Sun.COM 
45010376SChenlu.Chen@Sun.COM 	switch (pr_num) {
45110376SChenlu.Chen@Sun.COM 	case MAC_PROP_DUPLEX:
45211878SVenu.Iyer@Sun.COM 		ASSERT(pr_valsize >= sizeof (link_duplex_t));
45311878SVenu.Iyer@Sun.COM 		bcopy(&ixgbe->link_duplex, pr_val,
45411878SVenu.Iyer@Sun.COM 		    sizeof (link_duplex_t));
45510376SChenlu.Chen@Sun.COM 		break;
45610376SChenlu.Chen@Sun.COM 	case MAC_PROP_SPEED:
45711878SVenu.Iyer@Sun.COM 		ASSERT(pr_valsize >= sizeof (uint64_t));
45811878SVenu.Iyer@Sun.COM 		tmp = ixgbe->link_speed * 1000000ull;
45911878SVenu.Iyer@Sun.COM 		bcopy(&tmp, pr_val, sizeof (tmp));
46010376SChenlu.Chen@Sun.COM 		break;
46110376SChenlu.Chen@Sun.COM 	case MAC_PROP_AUTONEG:
46211878SVenu.Iyer@Sun.COM 		*(uint8_t *)pr_val = ixgbe->param_adv_autoneg_cap;
46310376SChenlu.Chen@Sun.COM 		break;
46410376SChenlu.Chen@Sun.COM 	case MAC_PROP_FLOWCTRL:
46511878SVenu.Iyer@Sun.COM 		ASSERT(pr_valsize >= sizeof (uint32_t));
46611878SVenu.Iyer@Sun.COM 
46711878SVenu.Iyer@Sun.COM 		switch (hw->fc.requested_mode) {
46811878SVenu.Iyer@Sun.COM 			case ixgbe_fc_none:
46910376SChenlu.Chen@Sun.COM 				flow_control = LINK_FLOWCTRL_NONE;
47011878SVenu.Iyer@Sun.COM 				break;
47111878SVenu.Iyer@Sun.COM 			case ixgbe_fc_rx_pause:
47211878SVenu.Iyer@Sun.COM 				flow_control = LINK_FLOWCTRL_RX;
47310376SChenlu.Chen@Sun.COM 				break;
47411878SVenu.Iyer@Sun.COM 			case ixgbe_fc_tx_pause:
47511878SVenu.Iyer@Sun.COM 				flow_control = LINK_FLOWCTRL_TX;
47611878SVenu.Iyer@Sun.COM 				break;
47711878SVenu.Iyer@Sun.COM 			case ixgbe_fc_full:
47811878SVenu.Iyer@Sun.COM 				flow_control = LINK_FLOWCTRL_BI;
47911878SVenu.Iyer@Sun.COM 				break;
48011878SVenu.Iyer@Sun.COM 		}
48111878SVenu.Iyer@Sun.COM 		bcopy(&flow_control, pr_val, sizeof (flow_control));
48210376SChenlu.Chen@Sun.COM 		break;
48310376SChenlu.Chen@Sun.COM 	case MAC_PROP_ADV_10GFDX_CAP:
48411878SVenu.Iyer@Sun.COM 		*(uint8_t *)pr_val = ixgbe->param_adv_10000fdx_cap;
48510376SChenlu.Chen@Sun.COM 		break;
48610376SChenlu.Chen@Sun.COM 	case MAC_PROP_EN_10GFDX_CAP:
48711878SVenu.Iyer@Sun.COM 		*(uint8_t *)pr_val = ixgbe->param_en_10000fdx_cap;
48810376SChenlu.Chen@Sun.COM 		break;
48910376SChenlu.Chen@Sun.COM 	case MAC_PROP_ADV_1000FDX_CAP:
49011878SVenu.Iyer@Sun.COM 		*(uint8_t *)pr_val = ixgbe->param_adv_1000fdx_cap;
49110376SChenlu.Chen@Sun.COM 		break;
49210376SChenlu.Chen@Sun.COM 	case MAC_PROP_EN_1000FDX_CAP:
49311878SVenu.Iyer@Sun.COM 		*(uint8_t *)pr_val = ixgbe->param_en_1000fdx_cap;
49410376SChenlu.Chen@Sun.COM 		break;
49510376SChenlu.Chen@Sun.COM 	case MAC_PROP_ADV_100FDX_CAP:
49611878SVenu.Iyer@Sun.COM 		*(uint8_t *)pr_val = ixgbe->param_adv_100fdx_cap;
49710376SChenlu.Chen@Sun.COM 		break;
49810376SChenlu.Chen@Sun.COM 	case MAC_PROP_EN_100FDX_CAP:
49911878SVenu.Iyer@Sun.COM 		*(uint8_t *)pr_val = ixgbe->param_en_100fdx_cap;
50010376SChenlu.Chen@Sun.COM 		break;
50110376SChenlu.Chen@Sun.COM 	case MAC_PROP_PRIVATE:
50210376SChenlu.Chen@Sun.COM 		err = ixgbe_get_priv_prop(ixgbe, pr_name,
50311878SVenu.Iyer@Sun.COM 		    pr_valsize, pr_val);
50410376SChenlu.Chen@Sun.COM 		break;
50510376SChenlu.Chen@Sun.COM 	default:
50610376SChenlu.Chen@Sun.COM 		err = EINVAL;
50710376SChenlu.Chen@Sun.COM 		break;
50810376SChenlu.Chen@Sun.COM 	}
50910376SChenlu.Chen@Sun.COM 	return (err);
51010376SChenlu.Chen@Sun.COM }
51110376SChenlu.Chen@Sun.COM 
51211878SVenu.Iyer@Sun.COM void
ixgbe_m_propinfo(void * arg,const char * pr_name,mac_prop_id_t pr_num,mac_prop_info_handle_t prh)51311878SVenu.Iyer@Sun.COM ixgbe_m_propinfo(void *arg, const char *pr_name, mac_prop_id_t pr_num,
51411878SVenu.Iyer@Sun.COM     mac_prop_info_handle_t prh)
51511878SVenu.Iyer@Sun.COM {
51611878SVenu.Iyer@Sun.COM 	ixgbe_t *ixgbe = (ixgbe_t *)arg;
51711878SVenu.Iyer@Sun.COM 	uint_t perm;
51811878SVenu.Iyer@Sun.COM 
51911878SVenu.Iyer@Sun.COM 	switch (pr_num) {
52011878SVenu.Iyer@Sun.COM 	case MAC_PROP_DUPLEX:
52111878SVenu.Iyer@Sun.COM 	case MAC_PROP_SPEED:
522*13006SChenlu.Chen@Sun.COM 		mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
523*13006SChenlu.Chen@Sun.COM 		break;
524*13006SChenlu.Chen@Sun.COM 
52511878SVenu.Iyer@Sun.COM 	case MAC_PROP_ADV_100FDX_CAP:
52611878SVenu.Iyer@Sun.COM 	case MAC_PROP_ADV_1000FDX_CAP:
52711878SVenu.Iyer@Sun.COM 	case MAC_PROP_ADV_10GFDX_CAP:
52811878SVenu.Iyer@Sun.COM 		mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
529*13006SChenlu.Chen@Sun.COM 		mac_prop_info_set_default_uint8(prh, 1);
53011878SVenu.Iyer@Sun.COM 		break;
53111878SVenu.Iyer@Sun.COM 
53211878SVenu.Iyer@Sun.COM 	case MAC_PROP_AUTONEG:
53311878SVenu.Iyer@Sun.COM 	case MAC_PROP_EN_10GFDX_CAP:
53411878SVenu.Iyer@Sun.COM 	case MAC_PROP_EN_1000FDX_CAP:
53511878SVenu.Iyer@Sun.COM 	case MAC_PROP_EN_100FDX_CAP:
53611878SVenu.Iyer@Sun.COM 		perm = (ixgbe->hw.phy.media_type == ixgbe_media_type_copper) ?
53711878SVenu.Iyer@Sun.COM 		    MAC_PROP_PERM_RW : MAC_PROP_PERM_READ;
53811878SVenu.Iyer@Sun.COM 		mac_prop_info_set_perm(prh, perm);
539*13006SChenlu.Chen@Sun.COM 		mac_prop_info_set_default_uint8(prh, 1);
54011878SVenu.Iyer@Sun.COM 		break;
54111878SVenu.Iyer@Sun.COM 
54211878SVenu.Iyer@Sun.COM 	case MAC_PROP_FLOWCTRL:
54311878SVenu.Iyer@Sun.COM 		mac_prop_info_set_default_link_flowctrl(prh,
54411878SVenu.Iyer@Sun.COM 		    LINK_FLOWCTRL_NONE);
54511878SVenu.Iyer@Sun.COM 		break;
54611878SVenu.Iyer@Sun.COM 
54711878SVenu.Iyer@Sun.COM 	case MAC_PROP_MTU:
54811878SVenu.Iyer@Sun.COM 		mac_prop_info_set_range_uint32(prh,
54911878SVenu.Iyer@Sun.COM 		    DEFAULT_MTU, ixgbe->capab->max_mtu);
55011878SVenu.Iyer@Sun.COM 		break;
55111878SVenu.Iyer@Sun.COM 
55211878SVenu.Iyer@Sun.COM 	case MAC_PROP_PRIVATE: {
55311878SVenu.Iyer@Sun.COM 		char valstr[64];
55411878SVenu.Iyer@Sun.COM 		int value;
55511878SVenu.Iyer@Sun.COM 
55611878SVenu.Iyer@Sun.COM 		bzero(valstr, sizeof (valstr));
55711878SVenu.Iyer@Sun.COM 
55811878SVenu.Iyer@Sun.COM 		if (strcmp(pr_name, "_adv_pause_cap") == 0 ||
55911878SVenu.Iyer@Sun.COM 		    strcmp(pr_name, "_adv_asym_pause_cap") == 0) {
56011878SVenu.Iyer@Sun.COM 			mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
56111878SVenu.Iyer@Sun.COM 			return;
56211878SVenu.Iyer@Sun.COM 		}
56311878SVenu.Iyer@Sun.COM 
56411878SVenu.Iyer@Sun.COM 		if (strcmp(pr_name, "_tx_copy_thresh") == 0) {
56511878SVenu.Iyer@Sun.COM 			value = DEFAULT_TX_COPY_THRESHOLD;
56611878SVenu.Iyer@Sun.COM 		} else if (strcmp(pr_name, "_tx_recycle_thresh") == 0) {
56711878SVenu.Iyer@Sun.COM 			value = DEFAULT_TX_RECYCLE_THRESHOLD;
56811878SVenu.Iyer@Sun.COM 		} else if (strcmp(pr_name, "_tx_overload_thresh") == 0) {
56911878SVenu.Iyer@Sun.COM 			value = DEFAULT_TX_OVERLOAD_THRESHOLD;
57011878SVenu.Iyer@Sun.COM 		} else if (strcmp(pr_name, "_tx_resched_thresh") == 0) {
57111878SVenu.Iyer@Sun.COM 			value = DEFAULT_TX_RESCHED_THRESHOLD;
57211878SVenu.Iyer@Sun.COM 		} else 	if (strcmp(pr_name, "_rx_copy_thresh") == 0) {
57311878SVenu.Iyer@Sun.COM 			value = DEFAULT_RX_COPY_THRESHOLD;
57411878SVenu.Iyer@Sun.COM 		} else 	if (strcmp(pr_name, "_rx_limit_per_intr") == 0) {
57511878SVenu.Iyer@Sun.COM 			value = DEFAULT_RX_LIMIT_PER_INTR;
57611878SVenu.Iyer@Sun.COM 		} 	if (strcmp(pr_name, "_intr_throttling") == 0) {
57711878SVenu.Iyer@Sun.COM 			value = ixgbe->capab->def_intr_throttle;
57811878SVenu.Iyer@Sun.COM 		} else {
57911878SVenu.Iyer@Sun.COM 			return;
58011878SVenu.Iyer@Sun.COM 		}
58111878SVenu.Iyer@Sun.COM 
58211878SVenu.Iyer@Sun.COM 		(void) snprintf(valstr, sizeof (valstr), "%x", value);
58311878SVenu.Iyer@Sun.COM 	}
58411878SVenu.Iyer@Sun.COM 	}
58511878SVenu.Iyer@Sun.COM }
58611878SVenu.Iyer@Sun.COM 
58710376SChenlu.Chen@Sun.COM boolean_t
ixgbe_param_locked(mac_prop_id_t pr_num)58810376SChenlu.Chen@Sun.COM ixgbe_param_locked(mac_prop_id_t pr_num)
58910376SChenlu.Chen@Sun.COM {
59010376SChenlu.Chen@Sun.COM 	/*
59110376SChenlu.Chen@Sun.COM 	 * All en_* parameters are locked (read-only) while
59210376SChenlu.Chen@Sun.COM 	 * the device is in any sort of loopback mode ...
59310376SChenlu.Chen@Sun.COM 	 */
59410376SChenlu.Chen@Sun.COM 	switch (pr_num) {
59510376SChenlu.Chen@Sun.COM 		case MAC_PROP_EN_10GFDX_CAP:
59610376SChenlu.Chen@Sun.COM 		case MAC_PROP_EN_1000FDX_CAP:
59710376SChenlu.Chen@Sun.COM 		case MAC_PROP_EN_100FDX_CAP:
59810376SChenlu.Chen@Sun.COM 		case MAC_PROP_AUTONEG:
59910376SChenlu.Chen@Sun.COM 		case MAC_PROP_FLOWCTRL:
60010376SChenlu.Chen@Sun.COM 			return (B_TRUE);
60110376SChenlu.Chen@Sun.COM 	}
60210376SChenlu.Chen@Sun.COM 	return (B_FALSE);
60310376SChenlu.Chen@Sun.COM }
60410376SChenlu.Chen@Sun.COM 
60510376SChenlu.Chen@Sun.COM /* ARGSUSED */
60610376SChenlu.Chen@Sun.COM int
ixgbe_set_priv_prop(ixgbe_t * ixgbe,const char * pr_name,uint_t pr_valsize,const void * pr_val)60710376SChenlu.Chen@Sun.COM ixgbe_set_priv_prop(ixgbe_t *ixgbe, const char *pr_name,
60810376SChenlu.Chen@Sun.COM     uint_t pr_valsize, const void *pr_val)
60910376SChenlu.Chen@Sun.COM {
61010376SChenlu.Chen@Sun.COM 	int err = 0;
61110376SChenlu.Chen@Sun.COM 	long result;
61210376SChenlu.Chen@Sun.COM 	struct ixgbe_hw *hw = &ixgbe->hw;
61310376SChenlu.Chen@Sun.COM 	int i;
61410376SChenlu.Chen@Sun.COM 
61510376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_tx_copy_thresh") == 0) {
61610376SChenlu.Chen@Sun.COM 		if (pr_val == NULL) {
61710376SChenlu.Chen@Sun.COM 			err = EINVAL;
61810376SChenlu.Chen@Sun.COM 			return (err);
61910376SChenlu.Chen@Sun.COM 		}
62010376SChenlu.Chen@Sun.COM 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
62110376SChenlu.Chen@Sun.COM 		if (result < MIN_TX_COPY_THRESHOLD ||
62210376SChenlu.Chen@Sun.COM 		    result > MAX_TX_COPY_THRESHOLD)
62310376SChenlu.Chen@Sun.COM 			err = EINVAL;
62410376SChenlu.Chen@Sun.COM 		else {
62510376SChenlu.Chen@Sun.COM 			ixgbe->tx_copy_thresh = (uint32_t)result;
62610376SChenlu.Chen@Sun.COM 		}
62710376SChenlu.Chen@Sun.COM 		return (err);
62810376SChenlu.Chen@Sun.COM 	}
62910376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_tx_recycle_thresh") == 0) {
63010376SChenlu.Chen@Sun.COM 		if (pr_val == NULL) {
63110376SChenlu.Chen@Sun.COM 			err = EINVAL;
63210376SChenlu.Chen@Sun.COM 			return (err);
63310376SChenlu.Chen@Sun.COM 		}
63410376SChenlu.Chen@Sun.COM 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
63510376SChenlu.Chen@Sun.COM 		if (result < MIN_TX_RECYCLE_THRESHOLD ||
63610376SChenlu.Chen@Sun.COM 		    result > MAX_TX_RECYCLE_THRESHOLD)
63710376SChenlu.Chen@Sun.COM 			err = EINVAL;
63810376SChenlu.Chen@Sun.COM 		else {
63910376SChenlu.Chen@Sun.COM 			ixgbe->tx_recycle_thresh = (uint32_t)result;
64010376SChenlu.Chen@Sun.COM 		}
64110376SChenlu.Chen@Sun.COM 		return (err);
64210376SChenlu.Chen@Sun.COM 	}
64310376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_tx_overload_thresh") == 0) {
64410376SChenlu.Chen@Sun.COM 		if (pr_val == NULL) {
64510376SChenlu.Chen@Sun.COM 			err = EINVAL;
64610376SChenlu.Chen@Sun.COM 			return (err);
64710376SChenlu.Chen@Sun.COM 		}
64810376SChenlu.Chen@Sun.COM 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
64910376SChenlu.Chen@Sun.COM 		if (result < MIN_TX_OVERLOAD_THRESHOLD ||
65010376SChenlu.Chen@Sun.COM 		    result > MAX_TX_OVERLOAD_THRESHOLD)
65110376SChenlu.Chen@Sun.COM 			err = EINVAL;
65210376SChenlu.Chen@Sun.COM 		else {
65310376SChenlu.Chen@Sun.COM 			ixgbe->tx_overload_thresh = (uint32_t)result;
65410376SChenlu.Chen@Sun.COM 		}
65510376SChenlu.Chen@Sun.COM 		return (err);
65610376SChenlu.Chen@Sun.COM 	}
65710376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_tx_resched_thresh") == 0) {
65810376SChenlu.Chen@Sun.COM 		if (pr_val == NULL) {
65910376SChenlu.Chen@Sun.COM 			err = EINVAL;
66010376SChenlu.Chen@Sun.COM 			return (err);
66110376SChenlu.Chen@Sun.COM 		}
66210376SChenlu.Chen@Sun.COM 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
66310376SChenlu.Chen@Sun.COM 		if (result < MIN_TX_RESCHED_THRESHOLD ||
66410376SChenlu.Chen@Sun.COM 		    result > MAX_TX_RESCHED_THRESHOLD)
66510376SChenlu.Chen@Sun.COM 			err = EINVAL;
66610376SChenlu.Chen@Sun.COM 		else {
66710376SChenlu.Chen@Sun.COM 			ixgbe->tx_resched_thresh = (uint32_t)result;
66810376SChenlu.Chen@Sun.COM 		}
66910376SChenlu.Chen@Sun.COM 		return (err);
67010376SChenlu.Chen@Sun.COM 	}
67110376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_rx_copy_thresh") == 0) {
67210376SChenlu.Chen@Sun.COM 		if (pr_val == NULL) {
67310376SChenlu.Chen@Sun.COM 			err = EINVAL;
67410376SChenlu.Chen@Sun.COM 			return (err);
67510376SChenlu.Chen@Sun.COM 		}
67610376SChenlu.Chen@Sun.COM 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
67710376SChenlu.Chen@Sun.COM 		if (result < MIN_RX_COPY_THRESHOLD ||
67810376SChenlu.Chen@Sun.COM 		    result > MAX_RX_COPY_THRESHOLD)
67910376SChenlu.Chen@Sun.COM 			err = EINVAL;
68010376SChenlu.Chen@Sun.COM 		else {
68110376SChenlu.Chen@Sun.COM 			ixgbe->rx_copy_thresh = (uint32_t)result;
68210376SChenlu.Chen@Sun.COM 		}
68310376SChenlu.Chen@Sun.COM 		return (err);
68410376SChenlu.Chen@Sun.COM 	}
68510376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_rx_limit_per_intr") == 0) {
68610376SChenlu.Chen@Sun.COM 		if (pr_val == NULL) {
68710376SChenlu.Chen@Sun.COM 			err = EINVAL;
68810376SChenlu.Chen@Sun.COM 			return (err);
68910376SChenlu.Chen@Sun.COM 		}
69010376SChenlu.Chen@Sun.COM 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
69110376SChenlu.Chen@Sun.COM 		if (result < MIN_RX_LIMIT_PER_INTR ||
69210376SChenlu.Chen@Sun.COM 		    result > MAX_RX_LIMIT_PER_INTR)
69310376SChenlu.Chen@Sun.COM 			err = EINVAL;
69410376SChenlu.Chen@Sun.COM 		else {
69510376SChenlu.Chen@Sun.COM 			ixgbe->rx_limit_per_intr = (uint32_t)result;
69610376SChenlu.Chen@Sun.COM 		}
69710376SChenlu.Chen@Sun.COM 		return (err);
69810376SChenlu.Chen@Sun.COM 	}
69910376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_intr_throttling") == 0) {
70010376SChenlu.Chen@Sun.COM 		if (pr_val == NULL) {
70110376SChenlu.Chen@Sun.COM 			err = EINVAL;
70210376SChenlu.Chen@Sun.COM 			return (err);
70310376SChenlu.Chen@Sun.COM 		}
70410376SChenlu.Chen@Sun.COM 		(void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
70510376SChenlu.Chen@Sun.COM 
70610376SChenlu.Chen@Sun.COM 		if (result < ixgbe->capab->min_intr_throttle ||
70710376SChenlu.Chen@Sun.COM 		    result > ixgbe->capab->max_intr_throttle)
70810376SChenlu.Chen@Sun.COM 			err = EINVAL;
70910376SChenlu.Chen@Sun.COM 		else {
71010376SChenlu.Chen@Sun.COM 			ixgbe->intr_throttling[0] = (uint32_t)result;
71110376SChenlu.Chen@Sun.COM 
71210376SChenlu.Chen@Sun.COM 			/*
71310376SChenlu.Chen@Sun.COM 			 * 82599 requires the interupt throttling rate is
71410376SChenlu.Chen@Sun.COM 			 * a multiple of 8. This is enforced by the register
71510376SChenlu.Chen@Sun.COM 			 * definiton.
71610376SChenlu.Chen@Sun.COM 			 */
71710376SChenlu.Chen@Sun.COM 			if (hw->mac.type == ixgbe_mac_82599EB)
71810376SChenlu.Chen@Sun.COM 				ixgbe->intr_throttling[0] =
71910376SChenlu.Chen@Sun.COM 				    ixgbe->intr_throttling[0] & 0xFF8;
72010376SChenlu.Chen@Sun.COM 
72110376SChenlu.Chen@Sun.COM 			for (i = 0; i < MAX_INTR_VECTOR; i++)
72210376SChenlu.Chen@Sun.COM 				ixgbe->intr_throttling[i] =
72310376SChenlu.Chen@Sun.COM 				    ixgbe->intr_throttling[0];
72410376SChenlu.Chen@Sun.COM 
72510376SChenlu.Chen@Sun.COM 			/* Set interrupt throttling rate */
72610376SChenlu.Chen@Sun.COM 			for (i = 0; i < ixgbe->intr_cnt; i++)
72710376SChenlu.Chen@Sun.COM 				IXGBE_WRITE_REG(hw, IXGBE_EITR(i),
72810376SChenlu.Chen@Sun.COM 				    ixgbe->intr_throttling[i]);
72910376SChenlu.Chen@Sun.COM 		}
73010376SChenlu.Chen@Sun.COM 		return (err);
73110376SChenlu.Chen@Sun.COM 	}
73210376SChenlu.Chen@Sun.COM 	return (ENOTSUP);
73310376SChenlu.Chen@Sun.COM }
73410376SChenlu.Chen@Sun.COM 
73510376SChenlu.Chen@Sun.COM int
ixgbe_get_priv_prop(ixgbe_t * ixgbe,const char * pr_name,uint_t pr_valsize,void * pr_val)73610376SChenlu.Chen@Sun.COM ixgbe_get_priv_prop(ixgbe_t *ixgbe, const char *pr_name,
73711878SVenu.Iyer@Sun.COM     uint_t pr_valsize, void *pr_val)
73810376SChenlu.Chen@Sun.COM {
73910376SChenlu.Chen@Sun.COM 	int err = ENOTSUP;
74010376SChenlu.Chen@Sun.COM 	int value;
74110376SChenlu.Chen@Sun.COM 
74210376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_adv_pause_cap") == 0) {
74311878SVenu.Iyer@Sun.COM 		value = ixgbe->param_adv_pause_cap;
74410376SChenlu.Chen@Sun.COM 		err = 0;
74510376SChenlu.Chen@Sun.COM 		goto done;
74610376SChenlu.Chen@Sun.COM 	}
74710376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_adv_asym_pause_cap") == 0) {
74811878SVenu.Iyer@Sun.COM 		value = ixgbe->param_adv_asym_pause_cap;
74910376SChenlu.Chen@Sun.COM 		err = 0;
75010376SChenlu.Chen@Sun.COM 		goto done;
75110376SChenlu.Chen@Sun.COM 	}
75210376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_tx_copy_thresh") == 0) {
75311878SVenu.Iyer@Sun.COM 		value = ixgbe->tx_copy_thresh;
75410376SChenlu.Chen@Sun.COM 		err = 0;
75510376SChenlu.Chen@Sun.COM 		goto done;
75610376SChenlu.Chen@Sun.COM 	}
75710376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_tx_recycle_thresh") == 0) {
75811878SVenu.Iyer@Sun.COM 		value = ixgbe->tx_recycle_thresh;
75910376SChenlu.Chen@Sun.COM 		err = 0;
76010376SChenlu.Chen@Sun.COM 		goto done;
76110376SChenlu.Chen@Sun.COM 	}
76210376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_tx_overload_thresh") == 0) {
76311878SVenu.Iyer@Sun.COM 		value = ixgbe->tx_overload_thresh;
76410376SChenlu.Chen@Sun.COM 		err = 0;
76510376SChenlu.Chen@Sun.COM 		goto done;
76610376SChenlu.Chen@Sun.COM 	}
76710376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_tx_resched_thresh") == 0) {
76811878SVenu.Iyer@Sun.COM 		value = ixgbe->tx_resched_thresh;
76910376SChenlu.Chen@Sun.COM 		err = 0;
77010376SChenlu.Chen@Sun.COM 		goto done;
77110376SChenlu.Chen@Sun.COM 	}
77210376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_rx_copy_thresh") == 0) {
77311878SVenu.Iyer@Sun.COM 		value = ixgbe->rx_copy_thresh;
77410376SChenlu.Chen@Sun.COM 		err = 0;
77510376SChenlu.Chen@Sun.COM 		goto done;
77610376SChenlu.Chen@Sun.COM 	}
77710376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_rx_limit_per_intr") == 0) {
77811878SVenu.Iyer@Sun.COM 		value = ixgbe->rx_limit_per_intr;
77910376SChenlu.Chen@Sun.COM 		err = 0;
78010376SChenlu.Chen@Sun.COM 		goto done;
78110376SChenlu.Chen@Sun.COM 	}
78210376SChenlu.Chen@Sun.COM 	if (strcmp(pr_name, "_intr_throttling") == 0) {
78311878SVenu.Iyer@Sun.COM 		value = ixgbe->intr_throttling[0];
78410376SChenlu.Chen@Sun.COM 		err = 0;
78510376SChenlu.Chen@Sun.COM 		goto done;
78610376SChenlu.Chen@Sun.COM 	}
78710376SChenlu.Chen@Sun.COM done:
78810376SChenlu.Chen@Sun.COM 	if (err == 0) {
78910376SChenlu.Chen@Sun.COM 		(void) snprintf(pr_val, pr_valsize, "%d", value);
79010376SChenlu.Chen@Sun.COM 	}
79110376SChenlu.Chen@Sun.COM 	return (err);
79210376SChenlu.Chen@Sun.COM }
793