1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2023 Oxide Computer Company
14 */
15
16 /*
17 * illumos additions to the e1000 common code for sharing between igb and
18 * e1000g.
19 */
20
21 #include "e1000_illumos.h"
22
23 /*
24 * Attempt to map the internal link settings in the device to known media types.
25 * This is a bit complicated because of how the common code abstracts some of
26 * the PHY information. In particular, the link mode to the internal serdes does
27 * not tell us much about how the external connectivity is designed. This makes
28 * it hard to figure out if we are actually using backplane connectivity that
29 * would operate in a KX or SGMII mode.
30 */
31 mac_ether_media_t
e1000_link_to_media(struct e1000_hw * hw,uint32_t speed)32 e1000_link_to_media(struct e1000_hw *hw, uint32_t speed)
33 {
34 /*
35 * If we enable 2.5G support for the i354 backplane, then we should go
36 * and update this case for 2.5G.
37 */
38 switch (speed) {
39 case SPEED_1000:
40 switch (hw->phy.media_type) {
41 case e1000_media_type_copper:
42 return (ETHER_MEDIA_1000BASE_T);
43 /*
44 * The internal serdes flag is often still used when
45 * communicating with fiber based media.
46 */
47 case e1000_media_type_fiber:
48 case e1000_media_type_internal_serdes:
49 /*
50 * While the e1000api common code internally has logic
51 * to actually pull out the specific SFF identifier for
52 * this device, that is not easily accessible for us so
53 * we return this as a generic fiber case. Given the
54 * lack of updates to the common code, we may want to
55 * reasonably plumb this through in the future.
56 */
57 return (ETHER_MEDIA_1000BASE_X);
58 default:
59 return (ETHER_MEDIA_UNKNOWN);
60 }
61 break;
62 case SPEED_100:
63 switch (hw->phy.media_type) {
64 case e1000_media_type_copper:
65 /*
66 * While there are standard bits in the PHY to indicate
67 * support for 100BASE-T2 and 100BASE-4 support, we have
68 * not seen any parts that suggest they actually support
69 * this in their datasheets. This is true as far back as
70 * the 82540 (which is derived from the 82542) whose
71 * datasheet covers all PCI and PCI-X controllers of a
72 * generation. It is also seemingly true for most newer
73 * controllers and PHYs. We've spot-checked the 82574,
74 * 82575, 82576, I350, I210, I211, and I217 datasheets.
75 * This leaves us fairly convinced it is safe to assume
76 * 100BASE-TX.
77 */
78 return (ETHER_MEDIA_100BASE_TX);
79 case e1000_media_type_fiber:
80 return (ETHER_MEDIA_100BASE_FX);
81 default:
82 return (ETHER_MEDIA_UNKNOWN);
83 }
84 case SPEED_10:
85 if (hw->phy.media_type == e1000_media_type_copper)
86 return (ETHER_MEDIA_10BASE_T);
87 return (ETHER_MEDIA_UNKNOWN);
88 default:
89 return (ETHER_MEDIA_NONE);
90 }
91 }
92