19860Sgdamore@opensolaris.org /* 29860Sgdamore@opensolaris.org * CDDL HEADER START 39860Sgdamore@opensolaris.org * 49860Sgdamore@opensolaris.org * The contents of this file are subject to the terms of the 59860Sgdamore@opensolaris.org * Common Development and Distribution License (the "License"). 69860Sgdamore@opensolaris.org * You may not use this file except in compliance with the License. 79860Sgdamore@opensolaris.org * 89860Sgdamore@opensolaris.org * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99860Sgdamore@opensolaris.org * or http://www.opensolaris.org/os/licensing. 109860Sgdamore@opensolaris.org * See the License for the specific language governing permissions 119860Sgdamore@opensolaris.org * and limitations under the License. 129860Sgdamore@opensolaris.org * 139860Sgdamore@opensolaris.org * When distributing Covered Code, include this CDDL HEADER in each 149860Sgdamore@opensolaris.org * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159860Sgdamore@opensolaris.org * If applicable, add the following below this CDDL HEADER, with the 169860Sgdamore@opensolaris.org * fields enclosed by brackets "[]" replaced with your own identifying 179860Sgdamore@opensolaris.org * information: Portions Copyright [yyyy] [name of copyright owner] 189860Sgdamore@opensolaris.org * 199860Sgdamore@opensolaris.org * CDDL HEADER END 209860Sgdamore@opensolaris.org */ 219860Sgdamore@opensolaris.org /* 22*11878SVenu.Iyer@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 239860Sgdamore@opensolaris.org * Use is subject to license terms. 249860Sgdamore@opensolaris.org */ 259860Sgdamore@opensolaris.org 269860Sgdamore@opensolaris.org /* 279860Sgdamore@opensolaris.org * mii.h 289860Sgdamore@opensolaris.org * Generic MII/PHY Support for MAC drivers. 299860Sgdamore@opensolaris.org */ 309860Sgdamore@opensolaris.org 319860Sgdamore@opensolaris.org #ifndef _SYS_MII_H 329860Sgdamore@opensolaris.org #define _SYS_MII_H 339860Sgdamore@opensolaris.org 349860Sgdamore@opensolaris.org #include <sys/mac_provider.h> 359860Sgdamore@opensolaris.org #include <sys/netlb.h> 369860Sgdamore@opensolaris.org 379860Sgdamore@opensolaris.org #ifdef __cplusplus 389860Sgdamore@opensolaris.org extern "C" { 399860Sgdamore@opensolaris.org #endif 409860Sgdamore@opensolaris.org 419860Sgdamore@opensolaris.org /* 429860Sgdamore@opensolaris.org * NOTES 439860Sgdamore@opensolaris.org * 449860Sgdamore@opensolaris.org * The device driver is required to protect its own registers. The 459860Sgdamore@opensolaris.org * MII common code will call MII entry points asynchronously, from a 469860Sgdamore@opensolaris.org * taskq, and holds an internal lock across such calls (except the 479860Sgdamore@opensolaris.org * notify entry point). Therefore, device drivers MUST NOT hold any 489860Sgdamore@opensolaris.org * locks across calls into the MII framework. 499860Sgdamore@opensolaris.org * 509860Sgdamore@opensolaris.org * If a device must be suspended (e.g. due to DDI_SUSPEND) the MII 519860Sgdamore@opensolaris.org * layer can be suspended by calling mii_stop(). After this point, 529860Sgdamore@opensolaris.org * the monitoring task will be suspended and the driver can be assured 539860Sgdamore@opensolaris.org * that MII will not interfere until restarted with mii_start(). 549860Sgdamore@opensolaris.org * 559860Sgdamore@opensolaris.org * Note that monitoring is not started until mii_start() is called. 569860Sgdamore@opensolaris.org * The mii_start() function may be called multiple times. It performs 579860Sgdamore@opensolaris.org * an implicit reset of the MII bus and PHY. 589860Sgdamore@opensolaris.org * 599860Sgdamore@opensolaris.org * Once started, if not already done, a probe of the MII bus is done to 609860Sgdamore@opensolaris.org * find a suitable PHY. If no PHY is found, then you won't have any 619860Sgdamore@opensolaris.org * link! Once a suitable PHY is selected, any other PHYs are isolated and 629860Sgdamore@opensolaris.org * powered down. The device driver can cause MII to re-probe the bus for 639860Sgdamore@opensolaris.org * changes to the available PHYs by calling mii_probe(). Note that this 649860Sgdamore@opensolaris.org * will also cause a full reset of all PHYs. 659860Sgdamore@opensolaris.org * 669860Sgdamore@opensolaris.org * The mii_reset entry point, which is optional, is used to notify the 679860Sgdamore@opensolaris.org * driver when the MII layer has reset the device. This can allow 689860Sgdamore@opensolaris.org * certain drivers the opportunity to "fix up" things after reset. 699860Sgdamore@opensolaris.org * Note however, that when possible, it is better if the logic is 709860Sgdamore@opensolaris.org * encoded into a vendor specific PHY module. 719860Sgdamore@opensolaris.org */ 729860Sgdamore@opensolaris.org 739860Sgdamore@opensolaris.org #ifdef _KERNEL 749860Sgdamore@opensolaris.org 759860Sgdamore@opensolaris.org typedef struct mii_handle *mii_handle_t; 769860Sgdamore@opensolaris.org typedef struct mii_ops mii_ops_t; 779860Sgdamore@opensolaris.org 789860Sgdamore@opensolaris.org struct mii_ops { 799860Sgdamore@opensolaris.org int mii_version; 809860Sgdamore@opensolaris.org uint16_t (*mii_read)(void *, uint8_t, uint8_t); 819860Sgdamore@opensolaris.org void (*mii_write)(void *, uint8_t, uint8_t, uint16_t); 829860Sgdamore@opensolaris.org void (*mii_notify)(void *, link_state_t); 839860Sgdamore@opensolaris.org void (*mii_reset)(void *); 849860Sgdamore@opensolaris.org }; 859860Sgdamore@opensolaris.org #define MII_OPS_VERSION 0 869860Sgdamore@opensolaris.org 879860Sgdamore@opensolaris.org /* 889860Sgdamore@opensolaris.org * Support routines. 899860Sgdamore@opensolaris.org */ 909860Sgdamore@opensolaris.org 919860Sgdamore@opensolaris.org /* 929860Sgdamore@opensolaris.org * mii_alloc 939860Sgdamore@opensolaris.org * 949860Sgdamore@opensolaris.org * Allocate an MII handle. Called during driver's attach(9e) 959860Sgdamore@opensolaris.org * handling, this routine is valid in kernel context only. 969860Sgdamore@opensolaris.org * 979860Sgdamore@opensolaris.org * Arguments 989860Sgdamore@opensolaris.org * 999860Sgdamore@opensolaris.org * private A private state structure, provided back to 1009860Sgdamore@opensolaris.org * entry points. 1019860Sgdamore@opensolaris.org * dip The dev_info node for the MAC driver. 1029860Sgdamore@opensolaris.org * ops Entry points into the MAC driver. 1039860Sgdamore@opensolaris.org * 1049860Sgdamore@opensolaris.org * Returns 1059860Sgdamore@opensolaris.org * Handle to MII bus on success, NULL on failure. 1069860Sgdamore@opensolaris.org */ 1079860Sgdamore@opensolaris.org mii_handle_t mii_alloc(void *private, dev_info_t *dip, mii_ops_t *ops); 1089860Sgdamore@opensolaris.org 1099860Sgdamore@opensolaris.org /* 1109860Sgdamore@opensolaris.org * mii_alloc 1119860Sgdamore@opensolaris.org * 1129860Sgdamore@opensolaris.org * Allocate an MII handle. Called during driver's attach(9e) 1139860Sgdamore@opensolaris.org * handling, this routine is valid in kernel context only. This 1149860Sgdamore@opensolaris.org * routine is an alternative to mii_alloc() for use when the 1159860Sgdamore@opensolaris.org * instance number (PPA) is not the same as the devinfo instance 1169860Sgdamore@opensolaris.org * number, and hence needs to be overridden. 1179860Sgdamore@opensolaris.org * 1189860Sgdamore@opensolaris.org * Arguments 1199860Sgdamore@opensolaris.org * 1209860Sgdamore@opensolaris.org * private A private state structure, provided back to 1219860Sgdamore@opensolaris.org * entry points. 1229860Sgdamore@opensolaris.org * dip The dev_info node for the MAC driver. 1239860Sgdamore@opensolaris.org * instance The instance (PPA) of the interface. 1249860Sgdamore@opensolaris.org * ops Entry points into the MAC driver. 1259860Sgdamore@opensolaris.org * 1269860Sgdamore@opensolaris.org * Returns 1279860Sgdamore@opensolaris.org * Handle to MII bus on success, NULL on failure. 1289860Sgdamore@opensolaris.org */ 1299860Sgdamore@opensolaris.org mii_handle_t mii_alloc_instance(void *private, dev_info_t *dip, int instance, 1309860Sgdamore@opensolaris.org mii_ops_t *ops); 1319860Sgdamore@opensolaris.org 1329860Sgdamore@opensolaris.org /* 1339860Sgdamore@opensolaris.org * mii_free 1349860Sgdamore@opensolaris.org * 1359860Sgdamore@opensolaris.org * Free an MII handle and associated resources. Call from 1369860Sgdamore@opensolaris.org * detach(9e) handling, this routine is valid in kernel context 1379860Sgdamore@opensolaris.org * only. 1389860Sgdamore@opensolaris.org */ 1399860Sgdamore@opensolaris.org void mii_free(mii_handle_t mii); 1409860Sgdamore@opensolaris.org 1419860Sgdamore@opensolaris.org /* 1429860Sgdamore@opensolaris.org * mii_set_pauseable 1439860Sgdamore@opensolaris.org * 1449860Sgdamore@opensolaris.org * Lets the MII know if the MAC layer can support pause or 1459860Sgdamore@opensolaris.org * asymetric pause capabilities. The MII layer will use this to 1469860Sgdamore@opensolaris.org * determine what capabilities should be negotiated for (along 1479860Sgdamore@opensolaris.org * with user preferences, of course.) If not called, the MII 1489860Sgdamore@opensolaris.org * will assume the device has no support for flow control. 1499860Sgdamore@opensolaris.org * 1509860Sgdamore@opensolaris.org * Arguments 1519860Sgdamore@opensolaris.org * 1529860Sgdamore@opensolaris.org * mii MII handle. 1539860Sgdamore@opensolaris.org * cap B_TRUE if the device supports symmetric of pause. 1549860Sgdamore@opensolaris.org * asym B_TRUE if the device supports asymmetric pause. 1559860Sgdamore@opensolaris.org */ 1569860Sgdamore@opensolaris.org void mii_set_pauseable(mii_handle_t mii, boolean_t cap, boolean_t asym); 1579860Sgdamore@opensolaris.org 1589860Sgdamore@opensolaris.org /* 1599860Sgdamore@opensolaris.org * mii_reset 1609860Sgdamore@opensolaris.org * 1619860Sgdamore@opensolaris.org * Schedules a reset of the MII bus. Normally not needed, but 1629860Sgdamore@opensolaris.org * can be used to perform a full master reset, including 1639860Sgdamore@opensolaris.org * rescanning for PHYs. This function may be called in any 1649860Sgdamore@opensolaris.org * context except high level interrupt context, but must be 1659860Sgdamore@opensolaris.org * called without any locks held. The reset will probably not 1669860Sgdamore@opensolaris.org * be complete until sometime after the call returns. 1679860Sgdamore@opensolaris.org * 1689860Sgdamore@opensolaris.org * Note that if mii_start has not been called, then the reset 1699860Sgdamore@opensolaris.org * will not be performed until _after_ the MII is started. 1709860Sgdamore@opensolaris.org */ 1719860Sgdamore@opensolaris.org void mii_reset(mii_handle_t mii); 1729860Sgdamore@opensolaris.org 1739860Sgdamore@opensolaris.org 1749860Sgdamore@opensolaris.org /* 1759860Sgdamore@opensolaris.org * mii_start 1769860Sgdamore@opensolaris.org * 1779860Sgdamore@opensolaris.org * Starts monitoring of the MII bus. Normally this is called as 1789860Sgdamore@opensolaris.org * a result of a driver's mac_start() entry point, but it may also 1799860Sgdamore@opensolaris.org * be called when a PHY needs to be reset or during handling of 1809860Sgdamore@opensolaris.org * DDI_RESUME. This function may be called in any context except 1819860Sgdamore@opensolaris.org * high level interrupt context, but 1829860Sgdamore@opensolaris.org * must be called without any locks held. 1839860Sgdamore@opensolaris.org */ 1849860Sgdamore@opensolaris.org void mii_start(mii_handle_t mii); 1859860Sgdamore@opensolaris.org 1869860Sgdamore@opensolaris.org /* 1879860Sgdamore@opensolaris.org * mii_stop 1889860Sgdamore@opensolaris.org * 1899860Sgdamore@opensolaris.org * Stops monitoring of the MII bus. Normally this is called as a 1909860Sgdamore@opensolaris.org * result of a driver's mac_stop() entry point. As a side 1919860Sgdamore@opensolaris.org * effect, also isolates and powers down any active PHY. On 1929860Sgdamore@opensolaris.org * return, the MII layer is guaranteed not to be executing any 1939860Sgdamore@opensolaris.org * code in the MII entry points. This function may be called in 1949860Sgdamore@opensolaris.org * any context except high level interrupt context, but must be 1959860Sgdamore@opensolaris.org * called without any locks held. 1969860Sgdamore@opensolaris.org */ 1979860Sgdamore@opensolaris.org void mii_stop(mii_handle_t mii); 1989860Sgdamore@opensolaris.org 1999860Sgdamore@opensolaris.org /* 2009860Sgdamore@opensolaris.org * mii_resume 2019860Sgdamore@opensolaris.org * 2029860Sgdamore@opensolaris.org * Starts monitoring of the MII bus. Normally this is called as 2039860Sgdamore@opensolaris.org * a part of a driver's DDI_RESUME handling. This function may 2049860Sgdamore@opensolaris.org * be called in any context except high level interrupt context, 2059860Sgdamore@opensolaris.org * but must be called without any locks held. 2069860Sgdamore@opensolaris.org */ 2079860Sgdamore@opensolaris.org void mii_resume(mii_handle_t mii); 2089860Sgdamore@opensolaris.org 2099860Sgdamore@opensolaris.org /* 2109860Sgdamore@opensolaris.org * mii_suspend 2119860Sgdamore@opensolaris.org * 2129860Sgdamore@opensolaris.org * Suspends monitoring of the MII bus. Normally this is called 2139860Sgdamore@opensolaris.org * as a part of a driver's DDI_SUSPEND handling. On return, the 2149860Sgdamore@opensolaris.org * MII layer is guaranteed not to be executing any code in the 2159860Sgdamore@opensolaris.org * MII entry points. This function may be called in any context 2169860Sgdamore@opensolaris.org * except high level interrupt context, but must be called 2179860Sgdamore@opensolaris.org * without any locks held. 2189860Sgdamore@opensolaris.org */ 2199860Sgdamore@opensolaris.org void mii_suspend(mii_handle_t mii); 2209860Sgdamore@opensolaris.org 2219860Sgdamore@opensolaris.org /* 2229860Sgdamore@opensolaris.org * mii_probe 2239860Sgdamore@opensolaris.org * 2249860Sgdamore@opensolaris.org * Used to reset the entire MII bus and probe for PHYs. This 2259860Sgdamore@opensolaris.org * routine should be called if the driver has reason to believe that 2269860Sgdamore@opensolaris.org * PHYs have changed. This is implicitly executed the first time 2279860Sgdamore@opensolaris.org * monitoring is started on the MII bus, and normally need not be 2289860Sgdamore@opensolaris.org * explicitly called. This function may be called in any context 2299860Sgdamore@opensolaris.org * except high level interrupt context, but must be called 2309860Sgdamore@opensolaris.org * without any locks held. 2319860Sgdamore@opensolaris.org */ 2329860Sgdamore@opensolaris.org void mii_probe(mii_handle_t mii); 2339860Sgdamore@opensolaris.org 2349860Sgdamore@opensolaris.org /* 2359860Sgdamore@opensolaris.org * mii_check 2369860Sgdamore@opensolaris.org * 2379860Sgdamore@opensolaris.org * Used to alert the MII layer that it should check for changes. 2389860Sgdamore@opensolaris.org * This can be called by drivers in response to link status 2399860Sgdamore@opensolaris.org * interrupts, for example, giving a quicker response to link 2409860Sgdamore@opensolaris.org * status changes without waiting for the MII timer to expire. 2419860Sgdamore@opensolaris.org * This function may be called in any context except high level 2429860Sgdamore@opensolaris.org * interrupt context, but must be called without any locks held. 2439860Sgdamore@opensolaris.org */ 2449860Sgdamore@opensolaris.org void mii_check(mii_handle_t mii); 2459860Sgdamore@opensolaris.org 2469860Sgdamore@opensolaris.org /* 2479860Sgdamore@opensolaris.org * mii_get_addr 2489860Sgdamore@opensolaris.org * 2499860Sgdamore@opensolaris.org * Used to get the PHY address that is currently active for the MII 2509860Sgdamore@opensolaris.org * bus. This function may be called in any context. 2519860Sgdamore@opensolaris.org * 2529860Sgdamore@opensolaris.org * Returns 2539860Sgdamore@opensolaris.org * 2549860Sgdamore@opensolaris.org * The PHY address (0-31) if a PHY is active on the MII bus. If 2559860Sgdamore@opensolaris.org * no PHY is active, -1 is returned. 2569860Sgdamore@opensolaris.org */ 2579860Sgdamore@opensolaris.org int mii_get_addr(mii_handle_t mii); 2589860Sgdamore@opensolaris.org 2599860Sgdamore@opensolaris.org /* 2609860Sgdamore@opensolaris.org * mii_get_id 2619860Sgdamore@opensolaris.org * 2629860Sgdamore@opensolaris.org * Used to get the identifier of the active PHY. This function 2639860Sgdamore@opensolaris.org * may be called in any context. 2649860Sgdamore@opensolaris.org * 2659860Sgdamore@opensolaris.org * Returns 2669860Sgdamore@opensolaris.org * 2679860Sgdamore@opensolaris.org * The PHY identifier register contents, encoded with the high 2689860Sgdamore@opensolaris.org * order (PHYIDH) bits in the upper word and the low order bits 2699860Sgdamore@opensolaris.org * in the lower word. If no PHY is active, the value -1 will be 2709860Sgdamore@opensolaris.org * returned. 2719860Sgdamore@opensolaris.org */ 2729860Sgdamore@opensolaris.org uint32_t mii_get_id(mii_handle_t mii); 2739860Sgdamore@opensolaris.org 2749860Sgdamore@opensolaris.org /* 2759860Sgdamore@opensolaris.org * mii_get_speed 2769860Sgdamore@opensolaris.org * 2779860Sgdamore@opensolaris.org * Used to get the speed of the active PHY. This function may be 2789860Sgdamore@opensolaris.org * called in any context. 2799860Sgdamore@opensolaris.org * 2809860Sgdamore@opensolaris.org * Returns 2819860Sgdamore@opensolaris.org * 2829860Sgdamore@opensolaris.org * The speed, in Mbps, if the active PHY has link (10, 100, or 1000), 2839860Sgdamore@opensolaris.org * otherwise 0. 2849860Sgdamore@opensolaris.org */ 2859860Sgdamore@opensolaris.org int mii_get_speed(mii_handle_t mii); 2869860Sgdamore@opensolaris.org 2879860Sgdamore@opensolaris.org /* 2889860Sgdamore@opensolaris.org * mii_get_duplex 2899860Sgdamore@opensolaris.org * 2909860Sgdamore@opensolaris.org * Used to get the duplex of the active PHY. This function may 2919860Sgdamore@opensolaris.org * be called in any context. 2929860Sgdamore@opensolaris.org * 2939860Sgdamore@opensolaris.org * Returns 2949860Sgdamore@opensolaris.org * 2959860Sgdamore@opensolaris.org * The duplex, if the active PHY has link (LINK_DUPLEX_FULL or 2969860Sgdamore@opensolaris.org * LINK_DUPLEX_HALF), otherwise LINK_DUPLEX_UNKNOWN. 2979860Sgdamore@opensolaris.org */ 2989860Sgdamore@opensolaris.org link_duplex_t mii_get_duplex(mii_handle_t mii); 2999860Sgdamore@opensolaris.org 3009860Sgdamore@opensolaris.org /* 3019860Sgdamore@opensolaris.org * mii_get_state 3029860Sgdamore@opensolaris.org * 3039860Sgdamore@opensolaris.org * Used to get the state of the link on the active PHY. This 3049860Sgdamore@opensolaris.org * function may be called in any context. 3059860Sgdamore@opensolaris.org * 3069860Sgdamore@opensolaris.org * Returns 3079860Sgdamore@opensolaris.org * 3089860Sgdamore@opensolaris.org * The link state (LINK_STATE_UP or LINK_STATE_DOWN), if known, 3099860Sgdamore@opensolaris.org * otherwise LINK_STATE_UNKNOWN. 3109860Sgdamore@opensolaris.org */ 3119860Sgdamore@opensolaris.org link_state_t mii_get_state(mii_handle_t mii); 3129860Sgdamore@opensolaris.org 3139860Sgdamore@opensolaris.org /* 3149860Sgdamore@opensolaris.org * mii_get_flowctrl 3159860Sgdamore@opensolaris.org * 3169860Sgdamore@opensolaris.org * Used to get the state of the negotiated flow control on the 3179860Sgdamore@opensolaris.org * active PHY. This function may be called in any context. 3189860Sgdamore@opensolaris.org * 3199860Sgdamore@opensolaris.org * Returns 3209860Sgdamore@opensolaris.org * 3219860Sgdamore@opensolaris.org * The flowctrl state (LINK_FLOWCTRL_NONE, LINK_FLOWCTRL_RX, 3229860Sgdamore@opensolaris.org * LINK_FLOWCTRL_TX, or LINK_FLOWCTRL_BI. 3239860Sgdamore@opensolaris.org */ 3249860Sgdamore@opensolaris.org link_flowctrl_t mii_get_flowctrl(mii_handle_t mii); 3259860Sgdamore@opensolaris.org 3269860Sgdamore@opensolaris.org /* 3279860Sgdamore@opensolaris.org * mii_get_loopmodes 3289860Sgdamore@opensolaris.org * 3299860Sgdamore@opensolaris.org * This function is used to support the LB_GET_INFO_SIZE and 3309860Sgdamore@opensolaris.org * LB_GET_INFO ioctls. It probably should not be used outside of 3319860Sgdamore@opensolaris.org * that context. The modes supplied are supported by the MII/PHY. 3329860Sgdamore@opensolaris.org * Drivers may wish to add modes for MAC internal loopbacks as well. 3339860Sgdamore@opensolaris.org * See <sys/netlb.h> for more information. 3349860Sgdamore@opensolaris.org * 3359860Sgdamore@opensolaris.org * Note that the first item in the modes array will always be the 3369860Sgdamore@opensolaris.org * mode to disable the MII/PHY loopback, and will have the value 3379860Sgdamore@opensolaris.org * MII_LOOPBACK_NONE. 3389860Sgdamore@opensolaris.org * 3399860Sgdamore@opensolaris.org * Arguments 3409860Sgdamore@opensolaris.org * 3419860Sgdamore@opensolaris.org * mii MII handle. 3429860Sgdamore@opensolaris.org * modes Location to receive an array of loopback modes. 3439860Sgdamore@opensolaris.org * Drivers should ensure that enough room is available. 3449860Sgdamore@opensolaris.org * There will never be more than MII_LOOPBACK_MAX modes 3459860Sgdamore@opensolaris.org * returned. May be NULL, in which case no data will 3469860Sgdamore@opensolaris.org * be returned to the caller. 3479860Sgdamore@opensolaris.org * 3489860Sgdamore@opensolaris.org * Returns 3499860Sgdamore@opensolaris.org * 3509860Sgdamore@opensolaris.org * Count of number of modes available, in no case larger than 3519860Sgdamore@opensolaris.org * MII_LOOPBACK_MAX. 3529860Sgdamore@opensolaris.org */ 3539860Sgdamore@opensolaris.org int mii_get_loopmodes(mii_handle_t mii, lb_property_t *modes); 3549860Sgdamore@opensolaris.org 3559860Sgdamore@opensolaris.org #define MII_LOOPBACK_MAX 16 3569860Sgdamore@opensolaris.org #define MII_LOOPBACK_NONE 0 3579860Sgdamore@opensolaris.org 3589860Sgdamore@opensolaris.org /* 3599860Sgdamore@opensolaris.org * mii_set_loopback 3609860Sgdamore@opensolaris.org * 3619860Sgdamore@opensolaris.org * Sets the loopback mode, intended for use in support of the 3629860Sgdamore@opensolaris.org * LB_SET_MODE ioctl. The mode value will be one of the values 3639860Sgdamore@opensolaris.org * returned in the modes array (see mii_get_loopmodes), or the 3649860Sgdamore@opensolaris.org * special value MII_LOOPBACK_NONE to return to normal operation. 3659860Sgdamore@opensolaris.org * 3669860Sgdamore@opensolaris.org * Arguments 3679860Sgdamore@opensolaris.org * 3689860Sgdamore@opensolaris.org * mii MII handle. 3699860Sgdamore@opensolaris.org * mode New loopback mode number; MII_LOOPBACK_NONE indicates 3709860Sgdamore@opensolaris.org * a return to normal operation. 3719860Sgdamore@opensolaris.org * 3729860Sgdamore@opensolaris.org * Returns 3739860Sgdamore@opensolaris.org * 3749860Sgdamore@opensolaris.org * Zero on success, or EINVAL if the mode is invalid or unsupported. 3759860Sgdamore@opensolaris.org */ 3769860Sgdamore@opensolaris.org int mii_set_loopback(mii_handle_t mii, uint32_t mode); 3779860Sgdamore@opensolaris.org 3789860Sgdamore@opensolaris.org /* 3799860Sgdamore@opensolaris.org * mii_get_loopback 3809860Sgdamore@opensolaris.org * 3819860Sgdamore@opensolaris.org * Queries the loopback mode, intended for use in support of the 3829860Sgdamore@opensolaris.org * LB_GET_MODE ioctl, but may be useful in programming device 3839860Sgdamore@opensolaris.org * settings that are sensitive to loopback setting. 3849860Sgdamore@opensolaris.org * 3859860Sgdamore@opensolaris.org * Returns 3869860Sgdamore@opensolaris.org * 3879860Sgdamore@opensolaris.org * The current mode number (one of the reported by 3889860Sgdamore@opensolaris.org * mii_get_loopmodes), or the special value MII_LOOPBACK_NONE 3899860Sgdamore@opensolaris.org * indicating that loopback is not in use. 3909860Sgdamore@opensolaris.org */ 3919860Sgdamore@opensolaris.org uint32_t mii_get_loopback(mii_handle_t mii); 3929860Sgdamore@opensolaris.org 3939860Sgdamore@opensolaris.org /* 3949860Sgdamore@opensolaris.org * mii_m_loop_ioctl 3959860Sgdamore@opensolaris.org * 3969860Sgdamore@opensolaris.org * Used to support the driver's mc_ioctl() for loopback ioctls. 3979860Sgdamore@opensolaris.org * If the driver is going to use the loopback optons from the 3989860Sgdamore@opensolaris.org * PHY, and isn't adding any MAC level loopback, then this function 3999860Sgdamore@opensolaris.org * can handle the entire set of ioctls, removing yet more code from 4009860Sgdamore@opensolaris.org * the driver. Ultimately, this is a very reasonable thing to do, 4019860Sgdamore@opensolaris.org * since the PHY level loopback should exercise all of the same 4029860Sgdamore@opensolaris.org * MAC level circuitry that a MAC internal loopback would do. 4039860Sgdamore@opensolaris.org * 4049860Sgdamore@opensolaris.org * Arguments 4059860Sgdamore@opensolaris.org * 4069860Sgdamore@opensolaris.org * mii MII handle. 4079860Sgdamore@opensolaris.org * wq The write queue supplied to mc_ioctl(). 4089860Sgdamore@opensolaris.org * msg The mblk from the mc_ioctl (contains an iocblk). 4099860Sgdamore@opensolaris.org * 4109860Sgdamore@opensolaris.org * Returns 4119860Sgdamore@opensolaris.org * 4129860Sgdamore@opensolaris.org * B_TRUE if the ioctl was handled by the driver. 4139860Sgdamore@opensolaris.org * B_FALSE if the ioctl was not handled, and may need to be 4149860Sgdamore@opensolaris.org * handled by the driver. 4159860Sgdamore@opensolaris.org */ 4169860Sgdamore@opensolaris.org boolean_t mii_m_loop_ioctl(mii_handle_t mii, queue_t *wq, mblk_t *msg); 4179860Sgdamore@opensolaris.org 4189860Sgdamore@opensolaris.org /* 4199860Sgdamore@opensolaris.org * mii_m_getprop 4209860Sgdamore@opensolaris.org * 4219860Sgdamore@opensolaris.org * Used to support the driver's mc_getprop() mac callback, 4229860Sgdamore@opensolaris.org * and only to be called from that function (and without any 4239860Sgdamore@opensolaris.org * locks held). This routine will process all of the properties 4249860Sgdamore@opensolaris.org * that are relevant to MII on behalf of the driver. 4259860Sgdamore@opensolaris.org * 4269860Sgdamore@opensolaris.org * Arguments 4279860Sgdamore@opensolaris.org * 4289860Sgdamore@opensolaris.org * mii MII handle. 4299860Sgdamore@opensolaris.org * name Property name. 4309860Sgdamore@opensolaris.org * id Property ID. 4319860Sgdamore@opensolaris.org * sz Size of property in bytes. 4329860Sgdamore@opensolaris.org * val Location to receive property value. 4339860Sgdamore@opensolaris.org * 4349860Sgdamore@opensolaris.org * Returns 4359860Sgdamore@opensolaris.org * 4369860Sgdamore@opensolaris.org * 0 on successful handling of property. 4379860Sgdamore@opensolaris.org * EINVAL if invalid arguments (e.g. a bad size) are supplied. 4389860Sgdamore@opensolaris.org * ENOTSUP if the prooperty is not supported by MII or the PHY. 4399860Sgdamore@opensolaris.org */ 4409860Sgdamore@opensolaris.org int mii_m_getprop(mii_handle_t mii, const char *name, mac_prop_id_t id, 441*11878SVenu.Iyer@Sun.COM uint_t sz, void *val); 4429860Sgdamore@opensolaris.org 4439860Sgdamore@opensolaris.org /* 4449860Sgdamore@opensolaris.org * mii_m_setprop 4459860Sgdamore@opensolaris.org * 4469860Sgdamore@opensolaris.org * Used to support the driver's mc_setprop() mac callback, 4479860Sgdamore@opensolaris.org * and only to be called from that function (and without any 4489860Sgdamore@opensolaris.org * locks held). This routine will process all of the properties 4499860Sgdamore@opensolaris.org * that are relevant to MII on behalf of the driver. This will 4509860Sgdamore@opensolaris.org * often result in the PHY being reset. 4519860Sgdamore@opensolaris.org * 4529860Sgdamore@opensolaris.org * Arguments 4539860Sgdamore@opensolaris.org * 4549860Sgdamore@opensolaris.org * mii MII handle. 4559860Sgdamore@opensolaris.org * name Property name. 4569860Sgdamore@opensolaris.org * id Property ID. 4579860Sgdamore@opensolaris.org * sz Size of property in bytes. 4589860Sgdamore@opensolaris.org * val Location of property value. 4599860Sgdamore@opensolaris.org * 4609860Sgdamore@opensolaris.org * Returns 4619860Sgdamore@opensolaris.org * 4629860Sgdamore@opensolaris.org * 0 on successful handling of property. 4639860Sgdamore@opensolaris.org * EINVAL if invalid arguments (e.g. a bad size) are supplied. 4649860Sgdamore@opensolaris.org * ENOTSUP if the prooperty is not supported by MII or the PHY, 4659860Sgdamore@opensolaris.org * or if the property is read-only. 4669860Sgdamore@opensolaris.org */ 4679860Sgdamore@opensolaris.org int mii_m_setprop(mii_handle_t mii, const char *name, mac_prop_id_t id, 4689860Sgdamore@opensolaris.org uint_t sz, const void *val); 4699860Sgdamore@opensolaris.org 4709860Sgdamore@opensolaris.org /* 471*11878SVenu.Iyer@Sun.COM * mii_m_propinfo 472*11878SVenu.Iyer@Sun.COM * 473*11878SVenu.Iyer@Sun.COM * Used to support the driver's mc_setprop() mac callback, 474*11878SVenu.Iyer@Sun.COM * and only to be called from that function (and without any 475*11878SVenu.Iyer@Sun.COM * locks held). 476*11878SVenu.Iyer@Sun.COM * 477*11878SVenu.Iyer@Sun.COM * Arguments 478*11878SVenu.Iyer@Sun.COM * 479*11878SVenu.Iyer@Sun.COM * mii MII handle. 480*11878SVenu.Iyer@Sun.COM * name Property name. 481*11878SVenu.Iyer@Sun.COM * id Property ID. 482*11878SVenu.Iyer@Sun.COM * prh Property info handle. 483*11878SVenu.Iyer@Sun.COM * 484*11878SVenu.Iyer@Sun.COM */ 485*11878SVenu.Iyer@Sun.COM void mii_m_propinfo(mii_handle_t mii, const char *name, mac_prop_id_t id, 486*11878SVenu.Iyer@Sun.COM mac_prop_info_handle_t prh); 487*11878SVenu.Iyer@Sun.COM 488*11878SVenu.Iyer@Sun.COM 489*11878SVenu.Iyer@Sun.COM /* 4909860Sgdamore@opensolaris.org * mii_m_getstat 4919860Sgdamore@opensolaris.org * 4929860Sgdamore@opensolaris.org * Used to support the driver's mc_getstat() mac callback for 4939860Sgdamore@opensolaris.org * statistic collection, and only to be called from that function 4949860Sgdamore@opensolaris.org * (without any locks held). This routine will process all of 4959860Sgdamore@opensolaris.org * the statistics that are relevant to MII on behalf of the 4969860Sgdamore@opensolaris.org * driver. 4979860Sgdamore@opensolaris.org * 4989860Sgdamore@opensolaris.org * Arguments 4999860Sgdamore@opensolaris.org * 5009860Sgdamore@opensolaris.org * mii MII handle. 5019860Sgdamore@opensolaris.org * stat Statistic number. 5029860Sgdamore@opensolaris.org * val Location to receive statistic value. 5039860Sgdamore@opensolaris.org * 5049860Sgdamore@opensolaris.org * Returns 5059860Sgdamore@opensolaris.org * 5069860Sgdamore@opensolaris.org * 0 on successful handling of statistic. 5079860Sgdamore@opensolaris.org * ENOTSUP if the statistic is not supported by MII. 5089860Sgdamore@opensolaris.org */ 5099860Sgdamore@opensolaris.org int mii_m_getstat(mii_handle_t mii, uint_t stat, uint64_t *val); 5109860Sgdamore@opensolaris.org 5119860Sgdamore@opensolaris.org #endif /* _KERNEL */ 5129860Sgdamore@opensolaris.org 5139860Sgdamore@opensolaris.org #ifdef __cplusplus 5149860Sgdamore@opensolaris.org } 5159860Sgdamore@opensolaris.org #endif 5169860Sgdamore@opensolaris.org 5179860Sgdamore@opensolaris.org #endif /* _SYS_MII_H */ 518