Xilinx axienet updates
Subsystems (5)
cover Xilinx axienet updates
Updates to the Xilinx AXI Ethernet driver to add support for an additional ethtool operation, and to support dynamic switching between 1000BaseX and SGMII interface modes.
Robert Hancock (3):
net: axienet: hook up nway_reset ethtool operation
dt-bindings: net: xilinx_axienet: add xlnx,switch-x-sgmii attribute
net: axienet: Support dynamic switching between 1000BaseX and SGMII
.../bindings/net/xilinx_axienet.txt | 4 ++ drivers/net/ethernet/xilinx/xilinx_axienet.h | 29 +++++--- .../net/ethernet/xilinx/xilinx_axienet_main.c | 68 +++++++++++++++++-- 3 files changed, 83 insertions(+), 18 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/3 net: axienet: hook up nway_reset ethtool operation
Hook up the nway_reset ethtool operation to the corresponding phylink function so that "ethtool -r" can be supported.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +8 -0
@@ -1469,6 +1469,13 @@ axienet_ethtools_set_link_ksettings(struct net_device *ndev,return phylink_ethtool_ksettings_set (lp->phylink, cmd); } +static int axienet_ethtools_nway_reset (struct net_device *dev) +{ +struct axienet_local *lp =netdev_priv (dev); + +return phylink_ethtool_nway_reset (lp->phylink); +} +static const struct ethtool_ops axienet_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_MAX_FRAMES , .get_drvinfo = axienet_ethtools_get_drvinfo,
@@ -1483,6 +1490,7 @@ static const struct ethtool_ops axienet_ethtool_ops = { .set_coalesce = axienet_ethtools_set_coalesce, .get_link_ksettings = axienet_ethtools_get_link_ksettings, .set_link_ksettings = axienet_ethtools_set_link_ksettings, + .nway_reset = axienet_ethtools_nway_reset, }; static void axienet_validate(struct phylink_config *config,
Signature · 1 line
2.27.0
PATCH 2/3 dt-bindings: net: xilinx_axienet: add xlnx,switch-x-sgmii attribute
In reply to Robert HancockDocument the new xlnx,switch-x-sgmii attribute which is used to indicate that the Ethernet core supports dynamic switching between 1000BaseX and SGMII.
--- Documentation/devicetree/bindings/net/xilinx_axienet.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/xilinx_axienet.txt +4 -0
@@ -38,6 +38,10 @@ Optional properties: 1 to enable partial TX checksum offload, 2 to enable full TX checksum offload - xlnx,rxcsum : Same values as xlnx,txcsum but for RX checksum offload +- xlnx,switch-x-sgmii : Boolean to indicate the Ethernet core is configured to + support both 1000BaseX and SGMII modes. If set, the phy-mode + should be set to match the mode selected on core reset (i.e. + by the basex_or_sgmii core input line). - clocks : AXI bus clock for the device. Refer to common clock bindings. Used to calculate MDIO clock divisor. If not specified, it is auto-detected from the CPU clock (but only on platforms where
Signature · 1 line
2.27.0
PATCH 3/3 net: axienet: Support dynamic switching between 1000BaseX and SGMII
In reply to Robert HancockNewer versions of the Xilinx AXI Ethernet core (specifically version 7.2 or later) allow the core to be configured with a PHY interface mode of "Both", allowing either 1000BaseX or SGMII modes to be selected at runtime. Add support for this in the driver to allow better support for applications which can use both fiber and copper SFP modules.
--- drivers/net/ethernet/xilinx/xilinx_axienet.h | 29 +++++---- .../net/ethernet/xilinx/xilinx_axienet_main.c | 60 ++++++++++++++++--- 2 files changed, 71 insertions(+), 18 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +18 -11
@@ -339,6 +339,10 @@#define DELAY_OF_ONE_MILLISEC 1000 +/* Xilinx PCS/PMA PHY register for switching 1000BaseX or SGMII */ +#define XLNX_MII_STD_SELECT_REG 0x11 +#define XLNX_MII_STD_SELECT_SGMII BIT(0) +/** * struct axidma_bd - Axi Dma buffer descriptor layout * @next: MM2S/S2MM Next Descriptor Pointer
@@ -377,22 +381,29 @@ struct axidma_bd {* @ndev: Pointer for net_device to which it will be attached. * @dev: Pointer to device structure * @phy_node: Pointer to device node structure +* @phylink: Pointer to phylink instance +* @phylink_config: phylink configuration settings +* @pcs_phy: Reference to PCS/PMA PHY if used +* @switch_x_sgmii: Whether switchable 1000BaseX/SGMII mode is enabled in the core +* @clk: Clock for AXI bus * @mii_bus: Pointer to MII bus structure * @mii_clk_div: MII bus clock divider value * @regs_start: Resource start for axienet device addresses * @regs: Base address for the axienet_local device address space * @dma_regs: Base address for the axidma device address space -* @dma_err_tasklet: Tasklet structure to process Axi DMA errors +* @dma_err_task: Work structure to process Axi DMA errors * @tx_irq: Axidma TX IRQ number * @rx_irq: Axidma RX IRQ number +* @eth_irq: Ethernet core IRQ number * @phy_mode: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X * @options: AxiEthernet option word -* @last_link: Phy link state in which the PHY was negotiated earlier * @features: Stores the extended features supported by the axienet hw * @tx_bd_v: Virtual address of the TX buffer descriptor ring * @tx_bd_p: Physical address(start address) of the TX buffer descr. ring +* @tx_bd_num: Size of TX buffer descriptor ring * @rx_bd_v: Virtual address of the RX buffer descriptor ring * @rx_bd_p: Physical address(start address) of the RX buffer descr. ring +* @rx_bd_num: Size of RX buffer descriptor ring * @tx_bd_ci: Stores the index of the Tx buffer descriptor in the ring being * accessed currently. Used while alloc. BDs before a TX starts * @tx_bd_tail: Stores the index of the Tx buffer descriptor in the ring being
@@ -414,23 +425,20 @@ struct axienet_local {struct net_device *ndev;struct device *dev; -/* Connection to PHY device */ struct device_node *phy_node;struct phylink *phylink;struct phylink_config phylink_config; -/* Reference to PCS/PMA PHY if used */ struct mdio_device *pcs_phy; -/* Clock for AXI bus */ +bool switch_x_sgmii; +struct clk *clk; -/* MDIO bus data */ -struct mii_bus *mii_bus;/* MII bus reference */ -u8 mii_clk_div;/* MII bus clock divider value */ +struct mii_bus *mii_bus; +u8 mii_clk_div; -/* IO registers, dma functions and IRQs */ resource_size_t regs_start;void __iomem *regs;void __iomem *dma_regs;
@@ -442,10 +450,9 @@ struct axienet_local {int eth_irq;phy_interface_t phy_mode; -u32 options;/* Current options word */ +u32 options;u32 features; -/* Buffer descriptors */ struct axidma_bd *tx_bd_v;dma_addr_t tx_bd_p;u32 tx_bd_num;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +53 -7
90 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH net-next 3/3] net: axienet: Support dynamic switching between 1000BaseX and SGMII
Quoted 2 lines · Robert Hancock
Newer versions of the Xilinx AXI Ethernet core (specifically version 7.2 or later) allow the core to be configured with a PHY interface mode of "Both",
Hi Robert
Is it possible to read the version of the core from a register? Is it possible to synthesizer a version 7.2 or > without this feature? I'm just wondering if the DT property is actually needed?
Quoted 37 lines
/**
* structaxidma_bd- Axi Dma buffer descriptor layout
* @next: MM2S/S2MM Next Descriptor Pointerdrivers/net/ethernet/xilinx/xilinx_axienet.h +9
-2@@ -377,22 +381,29 @@ struct axidma_bd {* @ndev: Pointer for net_device to which it will be attached. * @dev: Pointer to device structure * @phy_node: Pointer to device node structure +* @phylink: Pointer to phylink instance +* @phylink_config: phylink configuration settings +* @pcs_phy: Reference to PCS/PMA PHY if used +* @switch_x_sgmii: Whether switchable 1000BaseX/SGMII mode is enabled in the core +* @clk: Clock for AXI bus * @mii_bus: Pointer to MII bus structure * @mii_clk_div: MII bus clock divider value * @regs_start: Resource start for axienet device addresses * @regs: Base address for the axienet_local device address space * @dma_regs: Base address for the axidma device address space -* @dma_err_tasklet: Tasklet structure to process Axi DMA errors +* @dma_err_task: Work structure to process Axi DMA errors * @tx_irq: Axidma TX IRQ number * @rx_irq: Axidma RX IRQ number +* @eth_irq: Ethernet core IRQ number * @phy_mode: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X * @options: AxiEthernet option word -* @last_link: Phy link state in which the PHY was negotiated earlier * @features: Stores the extended features supported by the axienet hw * @tx_bd_v: Virtual address of the TX buffer descriptor ring * @tx_bd_p: Physical address(start address) of the TX buffer descr. ring +* @tx_bd_num: Size of TX buffer descriptor ring * @rx_bd_v: Virtual address of the RX buffer descriptor ring * @rx_bd_p: Physical address(start address) of the RX buffer descr. ring +* @rx_bd_num: Size of RX buffer descriptor ring * @tx_bd_ci: Stores the index of the Tx buffer descriptor in the ring being * accessed currently. Used while alloc. BDs before a TX starts * @tx_bd_tail: Stores the index of the Tx buffer descriptor in the ring being @@ -414,23 +425,20 @@ struct axienet_local {struct net_device *ndev;
drivers/net/ethernet/xilinx/xilinx_axienet.h struct axienet_local { · line 433
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet.h +0
-2struct device *dev; -/* Connection to PHY device */ struct device_node *phy_node;struct phylink *phylink;struct phylink_config phylink_config; -/* Reference to PCS/PMA PHY if used */ struct mdio_device *pcs_phy;
This really should of been two patches. One moving the comments around, and a second one adding the new fields.
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_mac_an_restart(struct phylink_config *config) · line 1591
Quoted 12 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +12
-0+static int axienet_mac_prepare (struct phylink_config *config,unsigned int mode, +phy_interface_t iface) +{ +struct net_device *ndev =to_net_dev (config->dev); +struct axienet_local *lp =netdev_priv (ndev); +int ret; + +switch (iface) { +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_1000BASEX : +if (!lp->switch_x_sgmii) +return 0 ;
Maybe -EOPNOTSUPP would be better?
Andrew
Re: [PATCH net-next 3/3] net: axienet: Support dynamic switching between 1000BaseX and SGMII
Quoted 9 lines · Andrew Lunn
Quoted 2 lines · Robert Hancock
Newer versions of the Xilinx AXI Ethernet core (specifically version 7.2 or later) allow the core to be configured with a PHY interface mode of "Both",
Hi Robert
Is it possible to read the version of the core from a register? Is it possible to synthesizer a version 7.2 or > without this feature? I'm just wondering if the DT property is actually needed?
The core can still be synthesized with a fixed 1000Base-X or SGMII interface mode in addition to the "Both" option, and I'm not aware of a way to determine what mode has been used based on registers, so I don't think there's really another option.
Quoted 59 lines
Quoted 45 lines
/**
* structaxidma_bd- Axi Dma buffer descriptor layout
* @next: MM2S/S2MM Next Descriptor Pointerdrivers/net/ethernet/xilinx/xilinx_axienet.h +4
-0@@ -377,22 +381,29 @@ struct axidma_bd {* @ndev: Pointer for net_device to which it will be attached. * @dev: Pointer to device structure * @phy_node: Pointer to device node structure +* @phylink: Pointer to phylink instance +* @phylink_config: phylink configuration settings +* @pcs_phy: Reference to PCS/PMA PHY if used +* @switch_x_sgmii: Whether switchable 1000BaseX/SGMII mode is enabled in the core
+ * @clk: Clock for AXI bus
* @mii_bus: Pointer to MII bus structure
* @mii_clk_div: MII bus clock divider value
* @regs_start: Resource start for axienet device addresses
* @regs: Base address for theaxienet_localdevice address space
* @dma_regs: Base address for the axidma device address space
- * @dma_err_tasklet: Tasklet structure to process Axi DMA errors
+ * @dma_err_task: Work structure to process Axi DMA errors
* @tx_irq: Axidma TX IRQ number
* @rx_irq: Axidma RX IRQ number
+ * @eth_irq: Ethernet core IRQ number
* @phy_mode: Phy type to identify between MII/GMII/RGMII/SGMII/1000
Base-X
* @options: AxiEthernet option word
- * @last_link: Phy link state in which the PHY was negotiated earlier
* @features: Stores the extended features supported by the axienet
hw
* @tx_bd_v: Virtual address of the TX buffer descriptor ring
* @tx_bd_p: Physical address(start address) of the TX buffer descr.
ring
+ * @tx_bd_num: Size of TX buffer descriptor ring
* @rx_bd_v: Virtual address of the RX buffer descriptor ring
* @rx_bd_p: Physical address(start address) of the RX buffer descr.
ring
+ * @rx_bd_num: Size of RX buffer descriptor ring
* @tx_bd_ci: Stores the index of the Tx buffer descriptor in the
ring being
* accessed currently. Used while alloc. BDs before a TX starts
* @tx_bd_tail: Stores the index of the Tx buffer descriptor in the
ring beingdrivers/net/ethernet/xilinx/xilinx_axienet.h +0
-0@@ -414,23 +425,20 @@ struct axienet_local {struct net_device *ndev;drivers/net/ethernet/xilinx/xilinx_axienet.h struct axienet_local { · line 433
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet.h +0
-2struct device *dev; -/* Connection to PHY device */ struct device_node *phy_node;struct phylink *phylink;struct phylink_config phylink_config; -/* Reference to PCS/PMA PHY if used */ struct mdio_device *pcs_phy;This really should of been two patches. One moving the comments around, and a second one adding the new fields.
Quoted 15 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_mac_an_restart(struct phylink_config *config) · line 1591
Quoted 13 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +12
-0+static int axienet_mac_prepare (struct phylink_config *config,unsigned int mode, +phy_interface_t iface) +{ +struct net_device *ndev =to_net_dev (config->dev); +struct axienet_local *lp =netdev_priv (ndev); +int ret; + +switch (iface) { +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_1000BASEX : +if (!lp->switch_x_sgmii) +return 0 ;Maybe
-EOPNOTSUPPwould be better?
From my reading of the code it appears that this function is called on startup initially even if dynamic switching is not supported, so we would need to return 0 here for that case. The validate callback should trap cases where we attempt to switch modes and that isn't supported.
Quoted 2 lines
Andrew
Signature · 3 lines
Robert Hancock Senior Hardware Designer, Calian Advanced Technologies www.calian.com
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 10 lines · On Fri, 12 Feb 2021 18:23:53 -0600 you wrote:
Updates to the Xilinx AXI Ethernet driver to add support for an additional ethtool operation, and to support dynamic switching between 1000BaseX and SGMII interface modes.
Robert Hancock (3):
net: axienet: hook upnway_resetethtool operation
dt-bindings: net:xilinx_axienet: add xlnx,switch-x-sgmii attribute
net: axienet: Support dynamic switching between 1000BaseX and SGMII[...]
Here is the summary with links:
- [net-next,1/3] net: axienet: hook up nway_reset ethtool operation
https://git.kernel.org/netdev/net-next/c/66b51663cdd0 - [net-next,2/3] dt-bindings: net: xilinx_axienet: add xlnx,switch-x-sgmii attribute https://git.kernel.org/netdev/net-next/c/eceac9d2590b - [net-next,3/3] net: axienet: Support dynamic switching between 1000BaseX and SGMII https://git.kernel.org/netdev/net-next/c/6c8f06bb2e51
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html