Skip to content

Commit ed4d421

Browse files
maass-hamburgdkalowsk
authored andcommitted
drivers: ethernet: remove phy related configs from eth config
remove phy related configs from eth config. phy related configs chould go directly into the phy. Most ethernet drivers didn't support the now removed functions yet. Users should instead use `phy_configure_link()` together with the `net_eth_get_phy()` function. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
1 parent c169ac0 commit ed4d421

File tree

10 files changed

+19
-407
lines changed

10 files changed

+19
-407
lines changed

drivers/ethernet/dwc_xgmac/eth_dwc_xgmac.c

Lines changed: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ struct eth_dwc_xgmac_dev_data {
4949
bool dev_started;
5050
/* This field specifies the ethernet link type full duplex or half duplex. */
5151
bool enable_full_duplex;
52-
/* Ethernet auto-negotiation status. */
53-
bool auto_neg;
5452
/* Ethernet promiscuous mode status. */
5553
bool promisc_mode;
5654
/* Ethernet interface structure associated with this device. */
@@ -1478,41 +1476,6 @@ static int eth_dwc_xgmac_send(const struct device *dev, struct net_pkt *pkt)
14781476
return -EIO;
14791477
}
14801478

1481-
static enum phy_link_speed get_phy_adv_speeds(bool auto_neg, bool duplex_mode,
1482-
enum eth_dwc_xgmac_link_speed link_speed)
1483-
{
1484-
enum phy_link_speed adv_speeds = 0u;
1485-
1486-
if (auto_neg) {
1487-
adv_speeds = LINK_HALF_1000BASE | LINK_HALF_1000BASE | LINK_HALF_100BASE |
1488-
LINK_FULL_100BASE | LINK_HALF_10BASE | LINK_FULL_10BASE;
1489-
} else {
1490-
if (duplex_mode) {
1491-
switch (link_speed) {
1492-
case LINK_1GBIT:
1493-
adv_speeds = LINK_FULL_1000BASE;
1494-
break;
1495-
case LINK_100MBIT:
1496-
adv_speeds = LINK_FULL_100BASE;
1497-
break;
1498-
default:
1499-
adv_speeds = LINK_FULL_10BASE;
1500-
}
1501-
} else {
1502-
switch (link_speed) {
1503-
case LINK_1GBIT:
1504-
adv_speeds = LINK_HALF_1000BASE;
1505-
break;
1506-
case LINK_100MBIT:
1507-
adv_speeds = LINK_HALF_100BASE;
1508-
break;
1509-
default:
1510-
adv_speeds = LINK_HALF_10BASE;
1511-
}
1512-
}
1513-
}
1514-
return adv_speeds;
1515-
}
15161479
#ifdef CONFIG_ETH_DWC_XGMAC_HW_FILTERING
15171480
static inline uint32_t get_free_mac_addr_indx(const struct device *dev)
15181481
{
@@ -1561,56 +1524,12 @@ static inline void disable_filter_for_mac_addr(const struct device *dev, uint8_t
15611524
static int eth_dwc_xgmac_set_config(const struct device *dev, enum ethernet_config_type type,
15621525
const struct ethernet_config *config)
15631526
{
1564-
const struct eth_dwc_xgmac_config *dev_conf = (struct eth_dwc_xgmac_config *)dev->config;
15651527
struct eth_dwc_xgmac_dev_data *dev_data = (struct eth_dwc_xgmac_dev_data *)dev->data;
1566-
const struct device *phy = dev_conf->phy_dev;
1567-
enum phy_link_speed adv_speeds;
15681528

15691529
int retval = 0;
15701530

15711531
(void)k_mutex_lock(&dev_data->dev_cfg_lock, K_FOREVER);
15721532
switch (type) {
1573-
case ETHERNET_CONFIG_TYPE_AUTO_NEG:
1574-
if (dev_data->auto_neg != config->auto_negotiation) {
1575-
dev_data->auto_neg = config->auto_negotiation;
1576-
adv_speeds =
1577-
get_phy_adv_speeds(dev_data->auto_neg, dev_data->enable_full_duplex,
1578-
dev_data->link_speed);
1579-
retval = phy_configure_link(phy, adv_speeds);
1580-
} else {
1581-
retval = -EALREADY;
1582-
}
1583-
break;
1584-
case ETHERNET_CONFIG_TYPE_LINK:
1585-
if ((config->l.link_10bt && dev_data->link_speed == LINK_10MBIT) ||
1586-
(config->l.link_100bt && dev_data->link_speed == LINK_100MBIT) ||
1587-
(config->l.link_1000bt && dev_data->link_speed == LINK_1GBIT)) {
1588-
retval = -EALREADY;
1589-
break;
1590-
}
1591-
1592-
if (config->l.link_1000bt) {
1593-
dev_data->link_speed = LINK_1GBIT;
1594-
} else if (config->l.link_100bt) {
1595-
dev_data->link_speed = LINK_100MBIT;
1596-
} else if (config->l.link_10bt) {
1597-
dev_data->link_speed = LINK_10MBIT;
1598-
}
1599-
adv_speeds = get_phy_adv_speeds(dev_data->auto_neg, dev_data->enable_full_duplex,
1600-
dev_data->link_speed);
1601-
retval = phy_configure_link(phy, adv_speeds);
1602-
break;
1603-
case ETHERNET_CONFIG_TYPE_DUPLEX:
1604-
if (config->full_duplex == dev_data->enable_full_duplex) {
1605-
retval = -EALREADY;
1606-
break;
1607-
}
1608-
dev_data->enable_full_duplex = config->full_duplex;
1609-
1610-
adv_speeds = get_phy_adv_speeds(dev_data->auto_neg, dev_data->enable_full_duplex,
1611-
dev_data->link_speed);
1612-
retval = phy_configure_link(phy, adv_speeds);
1613-
break;
16141533
case ETHERNET_CONFIG_TYPE_MAC_ADDRESS:
16151534
memcpy(dev_data->mac_addr, config->mac_address.addr, ETH_MAC_ADDRESS_SIZE);
16161535
retval = net_if_set_link_addr(dev_data->iface, dev_data->mac_addr,
@@ -1682,8 +1601,7 @@ static enum ethernet_hw_caps eth_dwc_xgmac_get_capabilities(const struct device
16821601
ARG_UNUSED(dev);
16831602
enum ethernet_hw_caps caps = (enum ethernet_hw_caps)0;
16841603

1685-
caps = (ETHERNET_LINK_1000BASE | ETHERNET_LINK_100BASE | ETHERNET_LINK_10BASE |
1686-
ETHERNET_AUTO_NEGOTIATION_SET | ETHERNET_DUPLEX_SET);
1604+
caps = (ETHERNET_LINK_1000BASE | ETHERNET_LINK_100BASE | ETHERNET_LINK_10BASE);
16871605

16881606
#ifdef CONFIG_ETH_DWC_XGMAC_RX_CS_OFFLOAD
16891607
caps |= ETHERNET_HW_RX_CHKSUM_OFFLOAD;
@@ -1783,7 +1701,6 @@ static const struct ethernet_api eth_dwc_xgmac_apis = {
17831701
static struct eth_dwc_xgmac_dev_data eth_dwc_xgmac##port##_dev_data = { \
17841702
.mac_addr = DT_INST_PROP(port, local_mac_address), \
17851703
.link_speed = DT_INST_PROP(port, max_speed), \
1786-
.auto_neg = true, \
17871704
.enable_full_duplex = DT_INST_PROP(port, full_duplex_mode_en), \
17881705
.dma_rx_desc = &eth_dwc_xgmac##port##_rx_desc[0u][0u], \
17891706
.dma_tx_desc = &eth_dwc_xgmac##port##_tx_desc[0u][0u], \

drivers/ethernet/eth_gecko.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,7 @@ static enum ethernet_hw_caps eth_gecko_get_capabilities(const struct device *dev
631631
{
632632
ARG_UNUSED(dev);
633633

634-
return (ETHERNET_AUTO_NEGOTIATION_SET | ETHERNET_LINK_10BASE |
635-
ETHERNET_LINK_100BASE | ETHERNET_DUPLEX_SET);
634+
return (ETHERNET_LINK_10BASE | ETHERNET_LINK_100BASE);
636635
}
637636

638637
static const struct ethernet_api eth_api = {

drivers/ethernet/eth_nxp_s32_gmac.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,6 @@ static enum ethernet_hw_caps eth_nxp_s32_get_capabilities(const struct device *d
564564
#if (FEATURE_GMAC_RGMII_EN == 1U)
565565
| ETHERNET_LINK_1000BASE
566566
#endif
567-
| ETHERNET_DUPLEX_SET
568567
| ETHERNET_HW_TX_CHKSUM_OFFLOAD
569568
| ETHERNET_HW_RX_CHKSUM_OFFLOAD
570569
#if defined(CONFIG_NET_VLAN)

drivers/ethernet/eth_xlnx_gem.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,6 @@ static enum ethernet_hw_caps eth_xlnx_gem_get_capabilities(
649649
caps |= ETHERNET_HW_TX_CHKSUM_OFFLOAD;
650650
}
651651

652-
if (dev_conf->enable_fdx) {
653-
caps |= ETHERNET_DUPLEX_SET;
654-
}
655-
656652
caps |= ETHERNET_PROMISC_MODE;
657653

658654
return caps;

include/zephyr/net/ethernet.h

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,20 @@ enum ethernet_hw_caps {
149149
/** VLAN supported */
150150
ETHERNET_HW_VLAN = BIT(2),
151151

152-
/** Enabling/disabling auto negotiation supported */
153-
ETHERNET_AUTO_NEGOTIATION_SET = BIT(3),
154-
155152
/** 10 Mbits link supported */
156-
ETHERNET_LINK_10BASE = BIT(4),
153+
ETHERNET_LINK_10BASE = BIT(3),
157154

158155
/** 100 Mbits link supported */
159-
ETHERNET_LINK_100BASE = BIT(5),
156+
ETHERNET_LINK_100BASE = BIT(4),
160157

161158
/** 1 Gbits link supported */
162-
ETHERNET_LINK_1000BASE = BIT(6),
159+
ETHERNET_LINK_1000BASE = BIT(5),
163160

164-
/** Changing duplex (half/full) supported */
165-
ETHERNET_DUPLEX_SET = BIT(7),
161+
/** 2.5 Gbits link supported */
162+
ETHERNET_LINK_2500BASE = BIT(6),
163+
164+
/** 5 Gbits link supported */
165+
ETHERNET_LINK_5000BASE = BIT(7),
166166

167167
/** IEEE 802.1AS (gPTP) clock supported */
168168
ETHERNET_PTP = BIT(8),
@@ -202,20 +202,11 @@ enum ethernet_hw_caps {
202202

203203
/** TX-Injection supported */
204204
ETHERNET_TXINJECTION_MODE = BIT(20),
205-
206-
/** 2.5 Gbits link supported */
207-
ETHERNET_LINK_2500BASE = BIT(21),
208-
209-
/** 5 Gbits link supported */
210-
ETHERNET_LINK_5000BASE = BIT(22),
211205
};
212206

213207
/** @cond INTERNAL_HIDDEN */
214208

215209
enum ethernet_config_type {
216-
ETHERNET_CONFIG_TYPE_AUTO_NEG,
217-
ETHERNET_CONFIG_TYPE_LINK,
218-
ETHERNET_CONFIG_TYPE_DUPLEX,
219210
ETHERNET_CONFIG_TYPE_MAC_ADDRESS,
220211
ETHERNET_CONFIG_TYPE_QAV_PARAM,
221212
ETHERNET_CONFIG_TYPE_QBV_PARAM,
@@ -499,17 +490,9 @@ enum ethernet_checksum_support {
499490

500491
struct ethernet_config {
501492
union {
502-
bool auto_negotiation;
503-
bool full_duplex;
504493
bool promisc_mode;
505494
bool txinjection_mode;
506495

507-
struct {
508-
bool link_10bt;
509-
bool link_100bt;
510-
bool link_1000bt;
511-
} l;
512-
513496
struct net_eth_addr mac_address;
514497

515498
struct ethernet_t1s_param t1s_param;

include/zephyr/net/ethernet_mgmt.h

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ extern "C" {
3838
#define NET_ETHERNET_EVENT (NET_ETHERNET_BASE | NET_MGMT_EVENT_BIT)
3939

4040
enum net_request_ethernet_cmd {
41-
NET_REQUEST_ETHERNET_CMD_SET_AUTO_NEGOTIATION = 1,
42-
NET_REQUEST_ETHERNET_CMD_SET_LINK,
43-
NET_REQUEST_ETHERNET_CMD_SET_DUPLEX,
44-
NET_REQUEST_ETHERNET_CMD_SET_MAC_ADDRESS,
41+
NET_REQUEST_ETHERNET_CMD_SET_MAC_ADDRESS = 1,
4542
NET_REQUEST_ETHERNET_CMD_SET_QAV_PARAM,
4643
NET_REQUEST_ETHERNET_CMD_SET_QBV_PARAM,
4744
NET_REQUEST_ETHERNET_CMD_SET_QBU_PARAM,
@@ -59,21 +56,6 @@ enum net_request_ethernet_cmd {
5956
NET_REQUEST_ETHERNET_CMD_SET_MAC_FILTER,
6057
};
6158

62-
#define NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION \
63-
(NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_AUTO_NEGOTIATION)
64-
65-
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION);
66-
67-
#define NET_REQUEST_ETHERNET_SET_LINK \
68-
(NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_LINK)
69-
70-
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_LINK);
71-
72-
#define NET_REQUEST_ETHERNET_SET_DUPLEX \
73-
(NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_DUPLEX)
74-
75-
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_DUPLEX);
76-
7759
#define NET_REQUEST_ETHERNET_SET_MAC_ADDRESS \
7860
(NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_MAC_ADDRESS)
7961

@@ -162,17 +144,9 @@ struct ethernet_txtime_param;
162144

163145
struct ethernet_req_params {
164146
union {
165-
bool auto_negotiation;
166-
bool full_duplex;
167147
bool promisc_mode;
168148
bool txinjection_mode;
169149

170-
struct {
171-
bool link_10bt;
172-
bool link_100bt;
173-
bool link_1000bt;
174-
} l;
175-
176150
struct net_eth_addr mac_address;
177151

178152
struct ethernet_qav_param qav_param;

subsys/net/l2/ethernet/ethernet_mgmt.c

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -47,46 +47,7 @@ static int ethernet_set_config(uint32_t mgmt_request,
4747
return -EINVAL;
4848
}
4949

50-
if (mgmt_request == NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION) {
51-
if (!is_hw_caps_supported(dev,
52-
ETHERNET_AUTO_NEGOTIATION_SET)) {
53-
return -ENOTSUP;
54-
}
55-
56-
config.auto_negotiation = params->auto_negotiation;
57-
type = ETHERNET_CONFIG_TYPE_AUTO_NEG;
58-
} else if (mgmt_request == NET_REQUEST_ETHERNET_SET_LINK) {
59-
if (params->l.link_10bt) {
60-
if (!is_hw_caps_supported(dev, ETHERNET_LINK_10BASE)) {
61-
return -ENOTSUP;
62-
}
63-
64-
config.l.link_10bt = true;
65-
} else if (params->l.link_100bt) {
66-
if (!is_hw_caps_supported(dev, ETHERNET_LINK_100BASE)) {
67-
return -ENOTSUP;
68-
}
69-
70-
config.l.link_100bt = true;
71-
} else if (params->l.link_1000bt) {
72-
if (!is_hw_caps_supported(dev, ETHERNET_LINK_1000BASE)) {
73-
return -ENOTSUP;
74-
}
75-
76-
config.l.link_1000bt = true;
77-
} else {
78-
return -EINVAL;
79-
}
80-
81-
type = ETHERNET_CONFIG_TYPE_LINK;
82-
} else if (mgmt_request == NET_REQUEST_ETHERNET_SET_DUPLEX) {
83-
if (!is_hw_caps_supported(dev, ETHERNET_DUPLEX_SET)) {
84-
return -ENOTSUP;
85-
}
86-
87-
config.full_duplex = params->full_duplex;
88-
type = ETHERNET_CONFIG_TYPE_DUPLEX;
89-
} else if (mgmt_request == NET_REQUEST_ETHERNET_SET_MAC_ADDRESS) {
50+
if (mgmt_request == NET_REQUEST_ETHERNET_SET_MAC_ADDRESS) {
9051
if (net_if_is_admin_up(iface)) {
9152
return -EACCES;
9253
}
@@ -219,15 +180,6 @@ static int ethernet_set_config(uint32_t mgmt_request,
219180
return api->set_config(net_if_get_device(iface), type, &config);
220181
}
221182

222-
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION,
223-
ethernet_set_config);
224-
225-
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_LINK,
226-
ethernet_set_config);
227-
228-
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_DUPLEX,
229-
ethernet_set_config);
230-
231183
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS,
232184
ethernet_set_config);
233185

subsys/net/lib/shell/iface.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ static struct ethernet_capabilities eth_hw_caps[] = {
4444
EC(ETHERNET_HW_RX_CHKSUM_OFFLOAD, "RX checksum offload"),
4545
EC(ETHERNET_HW_VLAN, "Virtual LAN"),
4646
EC(ETHERNET_HW_VLAN_TAG_STRIP, "VLAN Tag stripping"),
47-
EC(ETHERNET_AUTO_NEGOTIATION_SET, "Auto negotiation"),
4847
EC(ETHERNET_LINK_10BASE, "10 Mbits"),
4948
EC(ETHERNET_LINK_100BASE, "100 Mbits"),
5049
EC(ETHERNET_LINK_1000BASE, "1 Gbits"),
51-
EC(ETHERNET_DUPLEX_SET, "Half/full duplex"),
50+
EC(ETHERNET_LINK_2500BASE, "2.5 Gbits"),
51+
EC(ETHERNET_LINK_5000BASE, "5 Gbits"),
5252
EC(ETHERNET_PTP, "IEEE 802.1AS gPTP clock"),
5353
EC(ETHERNET_QAV, "IEEE 802.1Qav (credit shaping)"),
5454
EC(ETHERNET_QBV, "IEEE 802.1Qbv (scheduled traffic)"),
@@ -61,8 +61,6 @@ static struct ethernet_capabilities eth_hw_caps[] = {
6161
EC(ETHERNET_DSA_CONDUIT_PORT, "DSA conduit port"),
6262
EC(ETHERNET_TXTIME, "TXTIME supported"),
6363
EC(ETHERNET_TXINJECTION_MODE, "TX-Injection supported"),
64-
EC(ETHERNET_LINK_2500BASE, "2.5 Gbits"),
65-
EC(ETHERNET_LINK_5000BASE, "5 Gbits"),
6664
};
6765

6866
static void print_supported_ethernet_capabilities(

0 commit comments

Comments
 (0)