From owner-svn-src-all@FreeBSD.ORG  Sat Jul  5 19:31:23 2014
Return-Path: <owner-svn-src-all@FreeBSD.ORG>
Delivered-To: svn-src-all@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by hub.freebsd.org (Postfix) with ESMTPS id 0B02E951;
 Sat,  5 Jul 2014 19:31:23 +0000 (UTC)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id EC40825E8;
 Sat,  5 Jul 2014 19:31:22 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s65JVMMV028834;
 Sat, 5 Jul 2014 19:31:22 GMT (envelope-from loos@svn.freebsd.org)
Received: (from loos@localhost)
 by svn.freebsd.org (8.14.8/8.14.8/Submit) id s65JVMD4028833;
 Sat, 5 Jul 2014 19:31:22 GMT (envelope-from loos@svn.freebsd.org)
Message-Id: <201407051931.s65JVMD4028833@svn.freebsd.org>
From: Luiz Otavio O Souza <loos@FreeBSD.org>
Date: Sat, 5 Jul 2014 19:31:22 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r268294 - head/sys/dev/etherswitch/rtl8366
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: "SVN commit messages for the entire src tree \(except for &quot;
 user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all/>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 05 Jul 2014 19:31:23 -0000

Author: loos
Date: Sat Jul  5 19:31:22 2014
New Revision: 268294
URL: http://svnweb.freebsd.org/changeset/base/268294

Log:
  Allow the PVID setting on CPU port.
  
  Return our static list of supported media for the CPU port.
  
  Tested on TP-Link 1043ND.

Modified:
  head/sys/dev/etherswitch/rtl8366/rtl8366rb.c

Modified: head/sys/dev/etherswitch/rtl8366/rtl8366rb.c
==============================================================================
--- head/sys/dev/etherswitch/rtl8366/rtl8366rb.c	Sat Jul  5 19:30:20 2014	(r268293)
+++ head/sys/dev/etherswitch/rtl8366/rtl8366rb.c	Sat Jul  5 19:31:22 2014	(r268294)
@@ -579,13 +579,19 @@ rtl_getport(device_t dev, etherswitch_po
 	} else {
 		/* fill in fixed values for CPU port */
 		p->es_flags |= ETHERSWITCH_PORT_CPU;
-		ifmr->ifm_count = 0;
 		smi_read(dev, RTL8366RB_PLSR_BASE + (RTL8366RB_NUM_PHYS)/2, &v, RTL_WAITOK);
 		v = v >> (8 * ((RTL8366RB_NUM_PHYS) % 2));
 		rtl8366rb_update_ifmedia(v, &ifmr->ifm_status, &ifmr->ifm_active);
 		ifmr->ifm_current = ifmr->ifm_active;
 		ifmr->ifm_mask = 0;
 		ifmr->ifm_status = IFM_ACTIVE | IFM_AVALID;
+		/* Return our static media list. */
+		if (ifmr->ifm_count > 0) {
+			ifmr->ifm_count = 1;
+			ifmr->ifm_ulist[0] = IFM_MAKEWORD(IFM_ETHER, IFM_1000_T,
+			    IFM_FDX, 0);
+		} else
+			ifmr->ifm_count = 0;
 	}
 	return (0);
 }
@@ -598,7 +604,7 @@ rtl_setport(device_t dev, etherswitch_po
 	struct ifmedia *ifm;
 	struct mii_data *mii;
 
-	if (p->es_port < 0 || p->es_port >= RTL8366RB_NUM_PHYS)
+	if (p->es_port < 0 || p->es_port >= RTL8366RB_NUM_PORTS)
 		return (ENXIO);
 	sc = device_get_softc(dev);
 	vlangroup = -1;