From owner-svn-src-head@freebsd.org Thu May 31 02:10:50 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD3BAEF4DA9; Thu, 31 May 2018 02:10:50 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 909E487EA0; Thu, 31 May 2018 02:10:50 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7336713AC6; Thu, 31 May 2018 02:10:50 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4V2AoRC051212; Thu, 31 May 2018 02:10:50 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4V2AoJZ051211; Thu, 31 May 2018 02:10:50 GMT (envelope-from np@FreeBSD.org) Message-Id: <201805310210.w4V2AoJZ051211@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Thu, 31 May 2018 02:10:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334409 - head/sys/dev/cxgbe X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/sys/dev/cxgbe X-SVN-Commit-Revision: 334409 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 May 2018 02:10:51 -0000 Author: np Date: Thu May 31 02:10:50 2018 New Revision: 334409 URL: https://svnweb.freebsd.org/changeset/base/334409 Log: cxgbe(4): Implement ifm_change callback. Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Thu May 31 01:01:35 2018 (r334408) +++ head/sys/dev/cxgbe/t4_main.c Thu May 31 02:10:50 2018 (r334409) @@ -529,6 +529,7 @@ static int set_params__post_init(struct adapter *); static void t4_set_desc(struct adapter *); static void build_medialist(struct port_info *, struct ifmedia *); static void init_l1cfg(struct port_info *); +static int apply_l1cfg(struct port_info *); static int cxgbe_init_synchronized(struct vi_info *); static int cxgbe_uninit_synchronized(struct vi_info *); static void quiesce_txq(struct adapter *, struct sge_txq *); @@ -2077,14 +2078,42 @@ cxgbe_get_counter(struct ifnet *ifp, ift_counter c) } } +/* + * The kernel picks a media from the list we had provided so we do not have to + * validate the request. + */ static int cxgbe_media_change(struct ifnet *ifp) { struct vi_info *vi = ifp->if_softc; + struct port_info *pi = vi->pi; + struct ifmedia *ifm = &pi->media; + struct link_config *lc = &pi->link_cfg; + struct adapter *sc = pi->adapter; + int rc; - device_printf(vi->dev, "%s unimplemented.\n", __func__); - - return (EOPNOTSUPP); + rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4mec"); + if (rc != 0) + return (rc); + PORT_LOCK(pi); + if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO) { + MPASS(lc->supported & FW_PORT_CAP_ANEG); + lc->requested_aneg = AUTONEG_ENABLE; + } else { + lc->requested_aneg = AUTONEG_DISABLE; + lc->requested_speed = + ifmedia_baudrate(ifm->ifm_media) / 1000000; + lc->requested_fc = 0; + if (IFM_OPTIONS(ifm->ifm_media) & IFM_ETH_RXPAUSE) + lc->requested_fc |= PAUSE_RX; + if (IFM_OPTIONS(ifm->ifm_media) & IFM_ETH_TXPAUSE) + lc->requested_fc |= PAUSE_TX; + } + if (pi->up_vis > 0) + rc = apply_l1cfg(pi); + PORT_UNLOCK(pi); + end_synchronized_op(sc, 0); + return (rc); } /*