15 *
16 * 3. Neither the name of the author nor the names of its contributors may be
17 * used to endorse or promote products derived from this software without
18 * specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 * DAMAGE.
32 */
33
34 /*
35 * Change log
36 */
37
38 /*
39 * TODO:
40 * implement DELAYED_START
41 */
42
43 /*
44 * System Header files.
45 */
46 #include <sys/types.h>
47 #include <sys/conf.h>
48 #include <sys/debug.h>
49 #include <sys/kmem.h>
50 #include <sys/vtrace.h>
51 #include <sys/ethernet.h>
52 #include <sys/modctl.h>
53 #include <sys/errno.h>
54 #include <sys/ddi.h>
2034 if (dp->ugc.usbgc_mii_an_oneshot) {
2035 goto autonego;
2036 }
2037 /* PHY will restart autonego automatically */
2038 dp->mii_state = MII_STATE_AUTONEGOTIATING;
2039 dp->mii_timer = dp->ugc.usbgc_mii_an_timeout;
2040 dp->mii_interval = dp->ugc.usbgc_mii_an_watch_interval;
2041 goto next;
2042
2043 case MII_ACTION_RSA:
2044 if (!dp->mii_supress_msg) {
2045 cmn_err(CE_CONT, "!%s: restarting auto-negotiation",
2046 dp->name);
2047 }
2048 dp->mii_supress_msg = B_TRUE;
2049 goto autonego;
2050
2051 default:
2052 cmn_err(CE_PANIC, "!%s: unknowm linkdown action: %d",
2053 dp->name, dp->ugc.usbgc_mii_linkdown_action);
2054 dp->mii_supress_msg = B_TRUE;
2055 }
2056 /* NOTREACHED */
2057
2058 reset_phy:
2059 if (!dp->mii_supress_msg) {
2060 cmn_err(CE_CONT, "!%s: resetting PHY", dp->name);
2061 }
2062 dp->mii_state = MII_STATE_RESETTING;
2063 dp->mii_timer = dp->ugc.usbgc_mii_reset_timeout;
2064 if (!dp->ugc.usbgc_mii_dont_reset) {
2065 usbgem_mii_write(dp, MII_CONTROL, MII_CONTROL_RESET, &err);
2066 if (err != USB_SUCCESS) {
2067 goto usberr;
2068 }
2069 }
2070 dp->mii_interval = WATCH_INTERVAL_FAST;
2071 goto next;
2072
2073 autonego:
2074 if (!dp->mii_supress_msg) {
|
15 *
16 * 3. Neither the name of the author nor the names of its contributors may be
17 * used to endorse or promote products derived from this software without
18 * specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 * DAMAGE.
32 */
33
34 /*
35 * Copyright 2019 Joyent, Inc.
36 */
37
38 /*
39 * Change log
40 */
41
42 /*
43 * TODO:
44 * implement DELAYED_START
45 */
46
47 /*
48 * System Header files.
49 */
50 #include <sys/types.h>
51 #include <sys/conf.h>
52 #include <sys/debug.h>
53 #include <sys/kmem.h>
54 #include <sys/vtrace.h>
55 #include <sys/ethernet.h>
56 #include <sys/modctl.h>
57 #include <sys/errno.h>
58 #include <sys/ddi.h>
2038 if (dp->ugc.usbgc_mii_an_oneshot) {
2039 goto autonego;
2040 }
2041 /* PHY will restart autonego automatically */
2042 dp->mii_state = MII_STATE_AUTONEGOTIATING;
2043 dp->mii_timer = dp->ugc.usbgc_mii_an_timeout;
2044 dp->mii_interval = dp->ugc.usbgc_mii_an_watch_interval;
2045 goto next;
2046
2047 case MII_ACTION_RSA:
2048 if (!dp->mii_supress_msg) {
2049 cmn_err(CE_CONT, "!%s: restarting auto-negotiation",
2050 dp->name);
2051 }
2052 dp->mii_supress_msg = B_TRUE;
2053 goto autonego;
2054
2055 default:
2056 cmn_err(CE_PANIC, "!%s: unknowm linkdown action: %d",
2057 dp->name, dp->ugc.usbgc_mii_linkdown_action);
2058 }
2059 /* NOTREACHED */
2060
2061 reset_phy:
2062 if (!dp->mii_supress_msg) {
2063 cmn_err(CE_CONT, "!%s: resetting PHY", dp->name);
2064 }
2065 dp->mii_state = MII_STATE_RESETTING;
2066 dp->mii_timer = dp->ugc.usbgc_mii_reset_timeout;
2067 if (!dp->ugc.usbgc_mii_dont_reset) {
2068 usbgem_mii_write(dp, MII_CONTROL, MII_CONTROL_RESET, &err);
2069 if (err != USB_SUCCESS) {
2070 goto usberr;
2071 }
2072 }
2073 dp->mii_interval = WATCH_INTERVAL_FAST;
2074 goto next;
2075
2076 autonego:
2077 if (!dp->mii_supress_msg) {
|