Deleted Added
full compact
mii.c (228290) mii.c (242625)
1/* $NetBSD: mii.c,v 1.12 1999/08/03 19:41:49 drochner Exp $ */
2
3/*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/* $NetBSD: mii.c,v 1.12 1999/08/03 19:41:49 drochner Exp $ */
2
3/*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/dev/mii/mii.c 228290 2011-12-05 21:38:45Z marius $");
34__FBSDID("$FreeBSD: head/sys/dev/mii/mii.c 242625 2012-11-05 19:16:27Z dim $");
35
36/*
37 * MII bus layer, glues MII-capable network interface drivers to sharable
38 * PHY drivers. This exports an interface compatible with BSD/OS 3.0's,
39 * plus some NetBSD extensions.
40 */
41
42#include <sys/param.h>

--- 578 unchanged lines hidden (view full) ---

621
622 LIST_FOREACH(child, &mii->mii_phys, mii_list)
623 mii_phy_down(child);
624}
625
626static unsigned char
627mii_bitreverse(unsigned char x)
628{
35
36/*
37 * MII bus layer, glues MII-capable network interface drivers to sharable
38 * PHY drivers. This exports an interface compatible with BSD/OS 3.0's,
39 * plus some NetBSD extensions.
40 */
41
42#include <sys/param.h>

--- 578 unchanged lines hidden (view full) ---

621
622 LIST_FOREACH(child, &mii->mii_phys, mii_list)
623 mii_phy_down(child);
624}
625
626static unsigned char
627mii_bitreverse(unsigned char x)
628{
629 static unsigned const char const nibbletab[16] = {
629 static unsigned const char nibbletab[16] = {
630 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
631 };
632
633 return ((nibbletab[x & 15] << 4) | nibbletab[x >> 4]);
634}
635
636u_int
637mii_oui(u_int id1, u_int id2)
638{
639 u_int h;
640
641 h = (id1 << 6) | (id2 >> 10);
642
643 return ((mii_bitreverse(h >> 16) << 16) |
644 (mii_bitreverse((h >> 8) & 0xff) << 8) |
645 mii_bitreverse(h & 0xff));
646}
630 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
631 };
632
633 return ((nibbletab[x & 15] << 4) | nibbletab[x >> 4]);
634}
635
636u_int
637mii_oui(u_int id1, u_int id2)
638{
639 u_int h;
640
641 h = (id1 << 6) | (id2 >> 10);
642
643 return ((mii_bitreverse(h >> 16) << 16) |
644 (mii_bitreverse((h >> 8) & 0xff) << 8) |
645 mii_bitreverse(h & 0xff));
646}