2021-06-24 07:07:51 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/* Microchip Sparx5 Switch driver
|
|
|
|
*
|
|
|
|
* Copyright (c) 2021 Microchip Technology Inc. and its subsidiaries.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sparx5_main_regs.h"
|
|
|
|
#include "sparx5_main.h"
|
net: sparx5: add port module support
This add configuration of the Sparx5 port module instances.
Sparx5 has in total 65 logical ports (denoted D0 to D64) and 33
physical SerDes connections (S0 to S32). The 65th port (D64) is fixed
allocated to SerDes0 (S0). The remaining 64 ports can in various
multiplexing scenarios be connected to the remaining 32 SerDes using
QSGMII, or USGMII or USXGMII extenders. 32 of the ports can have a 1:1
mapping to the 32 SerDes.
Some additional ports (D65 to D69) are internal to the device and do not
connect to port modules or SerDes macros. For example, internal ports are
used for frame injection and extraction to the CPU queues.
The 65 logical ports are split up into the following blocks.
- 13 x 5G ports (D0-D11, D64)
- 32 x 2G5 ports (D16-D47)
- 12 x 10G ports (D12-D15, D48-D55)
- 8 x 25G ports (D56-D63)
Each logical port supports different line speeds, and depending on the
speeds supported, different port modules (MAC+PCS) are needed. A port
supporting 5 Gbps, 10 Gbps, or 25 Gbps as maximum line speed, will have a
DEV5G, DEV10G, or DEV25G module to support the 5 Gbps, 10 Gbps (incl 5
Gbps), or 25 Gbps (including 10 Gbps and 5 Gbps) speeds. As well as, it
will have a shadow DEV2G5 port module to support the lower speeds
(10/100/1000/2500Mbps). When a port needs to operate at lower speed and the
shadow DEV2G5 needs to be connected to its corresponding SerDes
Not all interface modes are supported in this series, but will be added at
a later stage.
Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
Signed-off-by: Bjarni Jonasson <bjarni.jonasson@microchip.com>
Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-24 07:07:52 +00:00
|
|
|
#include "sparx5_port.h"
|
2021-06-24 07:07:51 +00:00
|
|
|
|
|
|
|
/* The IFH bit position of the first VSTAX bit. This is because the
|
|
|
|
* VSTAX bit positions in Data sheet is starting from zero.
|
|
|
|
*/
|
|
|
|
#define VSTAX 73
|
|
|
|
|
2021-07-31 14:39:17 +00:00
|
|
|
#define ifh_encode_bitfield(ifh, value, pos, _width) \
|
|
|
|
({ \
|
|
|
|
u32 width = (_width); \
|
|
|
|
\
|
|
|
|
/* Max width is 5 bytes - 40 bits. In worst case this will
|
|
|
|
* spread over 6 bytes - 48 bits
|
|
|
|
*/ \
|
|
|
|
compiletime_assert(width <= 40, \
|
|
|
|
"Unsupported width, must be <= 40"); \
|
|
|
|
__ifh_encode_bitfield((ifh), (value), (pos), width); \
|
|
|
|
})
|
|
|
|
|
|
|
|
static void __ifh_encode_bitfield(void *ifh, u64 value, u32 pos, u32 width)
|
2021-06-24 07:07:51 +00:00
|
|
|
{
|
|
|
|
u8 *ifh_hdr = ifh;
|
|
|
|
/* Calculate the Start IFH byte position of this IFH bit position */
|
|
|
|
u32 byte = (35 - (pos / 8));
|
|
|
|
/* Calculate the Start bit position in the Start IFH byte */
|
|
|
|
u32 bit = (pos % 8);
|
2021-08-02 15:21:53 +00:00
|
|
|
u64 encode = GENMASK_ULL(bit + width - 1, bit) & (value << bit);
|
2021-06-24 07:07:51 +00:00
|
|
|
|
|
|
|
/* The b0-b7 goes into the start IFH byte */
|
|
|
|
if (encode & 0xFF)
|
|
|
|
ifh_hdr[byte] |= (u8)((encode & 0xFF));
|
|
|
|
/* The b8-b15 goes into the next IFH byte */
|
|
|
|
if (encode & 0xFF00)
|
|
|
|
ifh_hdr[byte - 1] |= (u8)((encode & 0xFF00) >> 8);
|
|
|
|
/* The b16-b23 goes into the next IFH byte */
|
|
|
|
if (encode & 0xFF0000)
|
|
|
|
ifh_hdr[byte - 2] |= (u8)((encode & 0xFF0000) >> 16);
|
|
|
|
/* The b24-b31 goes into the next IFH byte */
|
|
|
|
if (encode & 0xFF000000)
|
|
|
|
ifh_hdr[byte - 3] |= (u8)((encode & 0xFF000000) >> 24);
|
|
|
|
/* The b32-b39 goes into the next IFH byte */
|
|
|
|
if (encode & 0xFF00000000)
|
|
|
|
ifh_hdr[byte - 4] |= (u8)((encode & 0xFF00000000) >> 32);
|
|
|
|
/* The b40-b47 goes into the next IFH byte */
|
|
|
|
if (encode & 0xFF0000000000)
|
|
|
|
ifh_hdr[byte - 5] |= (u8)((encode & 0xFF0000000000) >> 40);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sparx5_set_port_ifh(void *ifh_hdr, u16 portno)
|
|
|
|
{
|
|
|
|
/* VSTAX.RSV = 1. MSBit must be 1 */
|
|
|
|
ifh_encode_bitfield(ifh_hdr, 1, VSTAX + 79, 1);
|
|
|
|
/* VSTAX.INGR_DROP_MODE = Enable. Don't make head-of-line blocking */
|
|
|
|
ifh_encode_bitfield(ifh_hdr, 1, VSTAX + 55, 1);
|
|
|
|
/* MISC.CPU_MASK/DPORT = Destination port */
|
|
|
|
ifh_encode_bitfield(ifh_hdr, portno, 29, 8);
|
|
|
|
/* MISC.PIPELINE_PT */
|
|
|
|
ifh_encode_bitfield(ifh_hdr, 16, 37, 5);
|
|
|
|
/* MISC.PIPELINE_ACT */
|
|
|
|
ifh_encode_bitfield(ifh_hdr, 1, 42, 3);
|
|
|
|
/* FWD.SRC_PORT = CPU */
|
|
|
|
ifh_encode_bitfield(ifh_hdr, SPX5_PORT_CPU, 46, 7);
|
|
|
|
/* FWD.SFLOW_ID (disable SFlow sampling) */
|
|
|
|
ifh_encode_bitfield(ifh_hdr, 124, 57, 7);
|
|
|
|
/* FWD.UPDATE_FCS = Enable. Enforce update of FCS. */
|
|
|
|
ifh_encode_bitfield(ifh_hdr, 1, 67, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sparx5_port_open(struct net_device *ndev)
|
|
|
|
{
|
|
|
|
struct sparx5_port *port = netdev_priv(ndev);
|
|
|
|
int err = 0;
|
|
|
|
|
net: sparx5: add port module support
This add configuration of the Sparx5 port module instances.
Sparx5 has in total 65 logical ports (denoted D0 to D64) and 33
physical SerDes connections (S0 to S32). The 65th port (D64) is fixed
allocated to SerDes0 (S0). The remaining 64 ports can in various
multiplexing scenarios be connected to the remaining 32 SerDes using
QSGMII, or USGMII or USXGMII extenders. 32 of the ports can have a 1:1
mapping to the 32 SerDes.
Some additional ports (D65 to D69) are internal to the device and do not
connect to port modules or SerDes macros. For example, internal ports are
used for frame injection and extraction to the CPU queues.
The 65 logical ports are split up into the following blocks.
- 13 x 5G ports (D0-D11, D64)
- 32 x 2G5 ports (D16-D47)
- 12 x 10G ports (D12-D15, D48-D55)
- 8 x 25G ports (D56-D63)
Each logical port supports different line speeds, and depending on the
speeds supported, different port modules (MAC+PCS) are needed. A port
supporting 5 Gbps, 10 Gbps, or 25 Gbps as maximum line speed, will have a
DEV5G, DEV10G, or DEV25G module to support the 5 Gbps, 10 Gbps (incl 5
Gbps), or 25 Gbps (including 10 Gbps and 5 Gbps) speeds. As well as, it
will have a shadow DEV2G5 port module to support the lower speeds
(10/100/1000/2500Mbps). When a port needs to operate at lower speed and the
shadow DEV2G5 needs to be connected to its corresponding SerDes
Not all interface modes are supported in this series, but will be added at
a later stage.
Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
Signed-off-by: Bjarni Jonasson <bjarni.jonasson@microchip.com>
Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-24 07:07:52 +00:00
|
|
|
sparx5_port_enable(port, true);
|
2021-06-24 07:07:51 +00:00
|
|
|
err = phylink_of_phy_connect(port->phylink, port->of_node, 0);
|
|
|
|
if (err) {
|
|
|
|
netdev_err(ndev, "Could not attach to PHY\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
phylink_start(port->phylink);
|
|
|
|
|
|
|
|
if (!ndev->phydev) {
|
|
|
|
/* power up serdes */
|
|
|
|
port->conf.power_down = false;
|
net: sparx5: add port module support
This add configuration of the Sparx5 port module instances.
Sparx5 has in total 65 logical ports (denoted D0 to D64) and 33
physical SerDes connections (S0 to S32). The 65th port (D64) is fixed
allocated to SerDes0 (S0). The remaining 64 ports can in various
multiplexing scenarios be connected to the remaining 32 SerDes using
QSGMII, or USGMII or USXGMII extenders. 32 of the ports can have a 1:1
mapping to the 32 SerDes.
Some additional ports (D65 to D69) are internal to the device and do not
connect to port modules or SerDes macros. For example, internal ports are
used for frame injection and extraction to the CPU queues.
The 65 logical ports are split up into the following blocks.
- 13 x 5G ports (D0-D11, D64)
- 32 x 2G5 ports (D16-D47)
- 12 x 10G ports (D12-D15, D48-D55)
- 8 x 25G ports (D56-D63)
Each logical port supports different line speeds, and depending on the
speeds supported, different port modules (MAC+PCS) are needed. A port
supporting 5 Gbps, 10 Gbps, or 25 Gbps as maximum line speed, will have a
DEV5G, DEV10G, or DEV25G module to support the 5 Gbps, 10 Gbps (incl 5
Gbps), or 25 Gbps (including 10 Gbps and 5 Gbps) speeds. As well as, it
will have a shadow DEV2G5 port module to support the lower speeds
(10/100/1000/2500Mbps). When a port needs to operate at lower speed and the
shadow DEV2G5 needs to be connected to its corresponding SerDes
Not all interface modes are supported in this series, but will be added at
a later stage.
Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
Signed-off-by: Bjarni Jonasson <bjarni.jonasson@microchip.com>
Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-24 07:07:52 +00:00
|
|
|
if (port->conf.serdes_reset)
|
|
|
|
err = sparx5_serdes_set(port->sparx5, port, &port->conf);
|
|
|
|
else
|
|
|
|
err = phy_power_on(port->serdes);
|
2021-06-24 07:07:51 +00:00
|
|
|
if (err)
|
|
|
|
netdev_err(ndev, "%s failed\n", __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sparx5_port_stop(struct net_device *ndev)
|
|
|
|
{
|
|
|
|
struct sparx5_port *port = netdev_priv(ndev);
|
|
|
|
int err = 0;
|
|
|
|
|
net: sparx5: add port module support
This add configuration of the Sparx5 port module instances.
Sparx5 has in total 65 logical ports (denoted D0 to D64) and 33
physical SerDes connections (S0 to S32). The 65th port (D64) is fixed
allocated to SerDes0 (S0). The remaining 64 ports can in various
multiplexing scenarios be connected to the remaining 32 SerDes using
QSGMII, or USGMII or USXGMII extenders. 32 of the ports can have a 1:1
mapping to the 32 SerDes.
Some additional ports (D65 to D69) are internal to the device and do not
connect to port modules or SerDes macros. For example, internal ports are
used for frame injection and extraction to the CPU queues.
The 65 logical ports are split up into the following blocks.
- 13 x 5G ports (D0-D11, D64)
- 32 x 2G5 ports (D16-D47)
- 12 x 10G ports (D12-D15, D48-D55)
- 8 x 25G ports (D56-D63)
Each logical port supports different line speeds, and depending on the
speeds supported, different port modules (MAC+PCS) are needed. A port
supporting 5 Gbps, 10 Gbps, or 25 Gbps as maximum line speed, will have a
DEV5G, DEV10G, or DEV25G module to support the 5 Gbps, 10 Gbps (incl 5
Gbps), or 25 Gbps (including 10 Gbps and 5 Gbps) speeds. As well as, it
will have a shadow DEV2G5 port module to support the lower speeds
(10/100/1000/2500Mbps). When a port needs to operate at lower speed and the
shadow DEV2G5 needs to be connected to its corresponding SerDes
Not all interface modes are supported in this series, but will be added at
a later stage.
Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
Signed-off-by: Bjarni Jonasson <bjarni.jonasson@microchip.com>
Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-24 07:07:52 +00:00
|
|
|
sparx5_port_enable(port, false);
|
2021-06-24 07:07:51 +00:00
|
|
|
phylink_stop(port->phylink);
|
|
|
|
phylink_disconnect_phy(port->phylink);
|
|
|
|
|
|
|
|
if (!ndev->phydev) {
|
net: sparx5: add port module support
This add configuration of the Sparx5 port module instances.
Sparx5 has in total 65 logical ports (denoted D0 to D64) and 33
physical SerDes connections (S0 to S32). The 65th port (D64) is fixed
allocated to SerDes0 (S0). The remaining 64 ports can in various
multiplexing scenarios be connected to the remaining 32 SerDes using
QSGMII, or USGMII or USXGMII extenders. 32 of the ports can have a 1:1
mapping to the 32 SerDes.
Some additional ports (D65 to D69) are internal to the device and do not
connect to port modules or SerDes macros. For example, internal ports are
used for frame injection and extraction to the CPU queues.
The 65 logical ports are split up into the following blocks.
- 13 x 5G ports (D0-D11, D64)
- 32 x 2G5 ports (D16-D47)
- 12 x 10G ports (D12-D15, D48-D55)
- 8 x 25G ports (D56-D63)
Each logical port supports different line speeds, and depending on the
speeds supported, different port modules (MAC+PCS) are needed. A port
supporting 5 Gbps, 10 Gbps, or 25 Gbps as maximum line speed, will have a
DEV5G, DEV10G, or DEV25G module to support the 5 Gbps, 10 Gbps (incl 5
Gbps), or 25 Gbps (including 10 Gbps and 5 Gbps) speeds. As well as, it
will have a shadow DEV2G5 port module to support the lower speeds
(10/100/1000/2500Mbps). When a port needs to operate at lower speed and the
shadow DEV2G5 needs to be connected to its corresponding SerDes
Not all interface modes are supported in this series, but will be added at
a later stage.
Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
Signed-off-by: Bjarni Jonasson <bjarni.jonasson@microchip.com>
Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-24 07:07:52 +00:00
|
|
|
/* power down serdes */
|
2021-06-24 07:07:51 +00:00
|
|
|
port->conf.power_down = true;
|
net: sparx5: add port module support
This add configuration of the Sparx5 port module instances.
Sparx5 has in total 65 logical ports (denoted D0 to D64) and 33
physical SerDes connections (S0 to S32). The 65th port (D64) is fixed
allocated to SerDes0 (S0). The remaining 64 ports can in various
multiplexing scenarios be connected to the remaining 32 SerDes using
QSGMII, or USGMII or USXGMII extenders. 32 of the ports can have a 1:1
mapping to the 32 SerDes.
Some additional ports (D65 to D69) are internal to the device and do not
connect to port modules or SerDes macros. For example, internal ports are
used for frame injection and extraction to the CPU queues.
The 65 logical ports are split up into the following blocks.
- 13 x 5G ports (D0-D11, D64)
- 32 x 2G5 ports (D16-D47)
- 12 x 10G ports (D12-D15, D48-D55)
- 8 x 25G ports (D56-D63)
Each logical port supports different line speeds, and depending on the
speeds supported, different port modules (MAC+PCS) are needed. A port
supporting 5 Gbps, 10 Gbps, or 25 Gbps as maximum line speed, will have a
DEV5G, DEV10G, or DEV25G module to support the 5 Gbps, 10 Gbps (incl 5
Gbps), or 25 Gbps (including 10 Gbps and 5 Gbps) speeds. As well as, it
will have a shadow DEV2G5 port module to support the lower speeds
(10/100/1000/2500Mbps). When a port needs to operate at lower speed and the
shadow DEV2G5 needs to be connected to its corresponding SerDes
Not all interface modes are supported in this series, but will be added at
a later stage.
Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
Signed-off-by: Bjarni Jonasson <bjarni.jonasson@microchip.com>
Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-24 07:07:52 +00:00
|
|
|
if (port->conf.serdes_reset)
|
|
|
|
err = sparx5_serdes_set(port->sparx5, port, &port->conf);
|
|
|
|
else
|
|
|
|
err = phy_power_off(port->serdes);
|
2021-06-24 07:07:51 +00:00
|
|
|
if (err)
|
|
|
|
netdev_err(ndev, "%s failed\n", __func__);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-24 07:07:55 +00:00
|
|
|
static void sparx5_set_rx_mode(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct sparx5_port *port = netdev_priv(dev);
|
|
|
|
struct sparx5 *sparx5 = port->sparx5;
|
|
|
|
|
|
|
|
if (!test_bit(port->portno, sparx5->bridge_mask))
|
|
|
|
__dev_mc_sync(dev, sparx5_mc_sync, sparx5_mc_unsync);
|
|
|
|
}
|
|
|
|
|
2021-06-24 07:07:51 +00:00
|
|
|
static int sparx5_port_get_phys_port_name(struct net_device *dev,
|
|
|
|
char *buf, size_t len)
|
|
|
|
{
|
|
|
|
struct sparx5_port *port = netdev_priv(dev);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = snprintf(buf, len, "p%d", port->portno);
|
|
|
|
if (ret >= len)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sparx5_set_mac_address(struct net_device *dev, void *p)
|
|
|
|
{
|
2021-06-24 07:07:53 +00:00
|
|
|
struct sparx5_port *port = netdev_priv(dev);
|
|
|
|
struct sparx5 *sparx5 = port->sparx5;
|
2021-06-24 07:07:51 +00:00
|
|
|
const struct sockaddr *addr = p;
|
|
|
|
|
|
|
|
if (!is_valid_ether_addr(addr->sa_data))
|
|
|
|
return -EADDRNOTAVAIL;
|
|
|
|
|
2021-06-24 07:07:53 +00:00
|
|
|
/* Remove current */
|
|
|
|
sparx5_mact_forget(sparx5, dev->dev_addr, port->pvid);
|
|
|
|
|
|
|
|
/* Add new */
|
|
|
|
sparx5_mact_learn(sparx5, PGID_CPU, addr->sa_data, port->pvid);
|
|
|
|
|
2021-06-24 07:07:51 +00:00
|
|
|
/* Record the address */
|
|
|
|
ether_addr_copy(dev->dev_addr, addr->sa_data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-24 07:07:53 +00:00
|
|
|
static int sparx5_get_port_parent_id(struct net_device *dev,
|
|
|
|
struct netdev_phys_item_id *ppid)
|
|
|
|
{
|
|
|
|
struct sparx5_port *sparx5_port = netdev_priv(dev);
|
|
|
|
struct sparx5 *sparx5 = sparx5_port->sparx5;
|
|
|
|
|
|
|
|
ppid->id_len = sizeof(sparx5->base_mac);
|
|
|
|
memcpy(&ppid->id, &sparx5->base_mac, ppid->id_len);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-24 07:07:51 +00:00
|
|
|
static const struct net_device_ops sparx5_port_netdev_ops = {
|
|
|
|
.ndo_open = sparx5_port_open,
|
|
|
|
.ndo_stop = sparx5_port_stop,
|
|
|
|
.ndo_start_xmit = sparx5_port_xmit_impl,
|
2021-06-24 07:07:55 +00:00
|
|
|
.ndo_set_rx_mode = sparx5_set_rx_mode,
|
2021-06-24 07:07:51 +00:00
|
|
|
.ndo_get_phys_port_name = sparx5_port_get_phys_port_name,
|
|
|
|
.ndo_set_mac_address = sparx5_set_mac_address,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
2021-06-24 07:07:57 +00:00
|
|
|
.ndo_get_stats64 = sparx5_get_stats64,
|
2021-06-24 07:07:53 +00:00
|
|
|
.ndo_get_port_parent_id = sparx5_get_port_parent_id,
|
2021-06-24 07:07:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool sparx5_netdevice_check(const struct net_device *dev)
|
|
|
|
{
|
|
|
|
return dev && (dev->netdev_ops == &sparx5_port_netdev_ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct net_device *sparx5_create_netdev(struct sparx5 *sparx5, u32 portno)
|
|
|
|
{
|
|
|
|
struct sparx5_port *spx5_port;
|
|
|
|
struct net_device *ndev;
|
|
|
|
u64 val;
|
|
|
|
|
|
|
|
ndev = devm_alloc_etherdev(sparx5->dev, sizeof(struct sparx5_port));
|
|
|
|
if (!ndev)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
SET_NETDEV_DEV(ndev, sparx5->dev);
|
|
|
|
spx5_port = netdev_priv(ndev);
|
|
|
|
spx5_port->ndev = ndev;
|
|
|
|
spx5_port->sparx5 = sparx5;
|
|
|
|
spx5_port->portno = portno;
|
|
|
|
sparx5_set_port_ifh(spx5_port->ifh, portno);
|
|
|
|
|
|
|
|
ndev->netdev_ops = &sparx5_port_netdev_ops;
|
2021-06-24 07:07:57 +00:00
|
|
|
ndev->ethtool_ops = &sparx5_ethtool_ops;
|
2021-06-24 07:07:51 +00:00
|
|
|
|
|
|
|
val = ether_addr_to_u64(sparx5->base_mac) + portno + 1;
|
|
|
|
u64_to_ether_addr(val, ndev->dev_addr);
|
|
|
|
|
|
|
|
return ndev;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sparx5_register_netdevs(struct sparx5 *sparx5)
|
|
|
|
{
|
|
|
|
int portno;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
for (portno = 0; portno < SPX5_PORTS; portno++)
|
|
|
|
if (sparx5->ports[portno]) {
|
|
|
|
err = register_netdev(sparx5->ports[portno]->ndev);
|
|
|
|
if (err) {
|
|
|
|
dev_err(sparx5->dev,
|
|
|
|
"port: %02u: netdev registration failed\n",
|
|
|
|
portno);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
sparx5_port_inj_timer_setup(sparx5->ports[portno]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sparx5_destroy_netdevs(struct sparx5 *sparx5)
|
|
|
|
{
|
|
|
|
struct sparx5_port *port;
|
|
|
|
int portno;
|
|
|
|
|
|
|
|
for (portno = 0; portno < SPX5_PORTS; portno++) {
|
|
|
|
port = sparx5->ports[portno];
|
|
|
|
if (port && port->phylink) {
|
|
|
|
/* Disconnect the phy */
|
|
|
|
rtnl_lock();
|
|
|
|
sparx5_port_stop(port->ndev);
|
|
|
|
phylink_disconnect_phy(port->phylink);
|
|
|
|
rtnl_unlock();
|
|
|
|
phylink_destroy(port->phylink);
|
|
|
|
port->phylink = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sparx5_unregister_netdevs(struct sparx5 *sparx5)
|
|
|
|
{
|
|
|
|
int portno;
|
|
|
|
|
|
|
|
for (portno = 0; portno < SPX5_PORTS; portno++)
|
|
|
|
if (sparx5->ports[portno])
|
|
|
|
unregister_netdev(sparx5->ports[portno]->ndev);
|
|
|
|
}
|
|
|
|
|