NC-SI PHY Support
Subsystems (3)
v2 cover NC-SI PHY Support
This series introduces support for the NC-SI protocol to u-boot, functionality which so far has only been available in vendor trees.
NC-SI (Network Controller Sideband Interface) is a protocol to manage a sideband connection to a proper network interface, for example a BMC (Baseboard Management Controller) sharing the NIC of the host system. Probing and configuration occurs by communicating with the "remote" NIC via NC-SI control frames (Ethernet header 0x88f8).
Since the RFC[0] the changes have been split out into a few different patches to make the overall changes more obvious. Additionally a few small improvements have been added including adding a check to see if NC-SI is already configured, and marking the PHY bus "reset" as invalid since it does not define a bus.
An example of NC-SI setup before a normal network command:
=> dhcpnet_loop: configuring NCSI first
ethernet at 1e660000: link up, 100 Mbps full-duplex mac:0c:c4:7a:d5:48:43
NCSI: probing channels
NCSI: configuring channel 0
NCSI: configuration done!
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 10.61.161.188 (255 ms)
[0]: https://patchwork.ozlabs.org/patch/1107087/
Changes in v2:
- Fix endianess issue when setting MAC address
- Make checksum offsets easier to read
- Instantiate per-phy ncsi_priv structures
- Update ncsi command help text
- Used update ncsi-pkt.h version to include SPDX header
Samuel Mendoza-Jonas (4):
phy: Add support for the NC-SI protocol
phy: Include NC-SI in phy setup
net/ftgmac100: Add NC-SI mode support
net: NC-SI setup and handling
cmd/Kconfig | 8 + cmd/net.c | 18 + drivers/net/ftgmac100.c | 39 +- drivers/net/phy/Kconfig | 4 + drivers/net/phy/Makefile | 1 + drivers/net/phy/ncsi.c | 896 +++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 7 + include/net.h | 3 +- include/net/ncsi-pkt.h | 442 +++++++++++++++++++ include/net/ncsi.h | 14 + include/phy.h | 12 + include/phy_interface.h | 2 + net/net.c | 27 +- 13 files changed, 1461 insertions(+), 12 deletions(-) create mode 100644 drivers/net/phy/ncsi.c create mode 100644 include/net/ncsi-pkt.h create mode 100644 include/net/ncsi.h
Signature · 1 line
2.21.0
PATCH v2 1/4 phy: Add support for the NC-SI protocol
This introduces support for the NC-SI protocol, modelled as a phy driver for other ethernet drivers to consume.
NC-SI (Network Controller Sideband Interface) is a protocol to manage a sideband connection to a proper network interface, for example a BMC (Baseboard Management Controller) sharing the NIC of the host system. Probing and configuration occurs by communicating with the "remote" NIC via NC-SI control frames (Ethernet header 0x88f8).
This implementation is roughly based on the upstream Linux implementation[0], with a reduced feature set and an emphasis on getting a link up as fast as possible rather than probing the full possible topology of the bus.
The current phy model relies on the network being "up", sending NC-SI command frames via net_send_packet() and receiving them from the net_loop() loop (added in a following patch).
The ncsi-pkt.h header[1] is copied from the Linux kernel for consistent field definitions.
[0]: https://github.com/torvalds/linux/tree/master/net/ncsi
[1]: https://github.com/torvalds/linux/blob/master/net/ncsi/ncsi-pkt.h
---
v2:
- Fix endianess issue when setting MAC address
- Make checksum offsets easier to read
- Instantiate per-phy ncsi_priv structures
- Used update ncsi-pkt.h version to include SPDX header
drivers/net/phy/Kconfig | 4 + drivers/net/phy/Makefile | 1 + drivers/net/phy/ncsi.c | 896 +++++++++++++++++++++++++++++++++++++++ include/net.h | 1 + include/net/ncsi-pkt.h | 442 +++++++++++++++++++ include/net/ncsi.h | 14 + include/phy.h | 1 + 7 files changed, 1359 insertions(+) create mode 100644 drivers/net/phy/ncsi.c create mode 100644 include/net/ncsi-pkt.h create mode 100644 include/net/ncsi.h
drivers/net/phy/Kconfig +4 -0
@@ -238,4 +238,8 @@ config PHY_FIXED on, the link is always up with fixed speed and fixed duplex-setting. More information: doc/device-tree-bindings/net/fixed-link.txt +config PHY_NCSI + bool "NC-SI based PHY" + depends on DM_ETH + endif #PHYLIB
drivers/net/phy/Makefile +1 -0
@@ -30,3 +30,4 @@ obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o obj-$(CONFIG_PHY_VITESSE) += vitesse.o obj-$(CONFIG_PHY_MSCC) += mscc.o obj-$(CONFIG_PHY_FIXED) += fixed.o +obj-$(CONFIG_PHY_NCSI) += ncsi.o
drivers/net/phy/ncsi.c new file +896 -0
896 lines not on this page · raw message
include/net.h +1 -0
@@ -343,6 +343,7 @@ struct vlan_ethernet_hdr {#define PROT_VLAN 0x8100/* IEEE 802.1q protocol */ #define PROT_IPV6 0x86dd/* IPv6 over bluebook */ #define PROT_PPP_SES 0x8864/* PPPoE session messages */ +#define PROT_NCSI 0x88f8/* NC-SI control packets */ #define IPPROTO_ICMP 1/* Internet Control Message Protocol */ #define IPPROTO_UDP 17/* User Datagram Protocol */
include/net/ncsi-pkt.h new file +442 -0
442 lines not on this page · raw message
include/net/ncsi.h new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* NC-SI PHY +* +* Copyright (C) 2019, IBM Corporation. +*/ + +#include <common.h> +#include <phy.h> + +bool ncsi_active (void ); +void ncsi_receive (struct ethernet_hdr *et,struct ip_udp_hdr *ip, +unsigned int len); +void ncsi_probe_packages (void );
include/phy.h +1 -0
@@ -17,6 +17,7 @@#include <phy_interface.h> #define PHY_FIXED_ID 0xa5a55a5a +#define PHY_NCSI_ID 0xbeefcafe#define PHY_MAX_ADDR 32
Signature · 1 line
2.21.0
Re: [PATCH v2 1/4] phy: Add support for the NC-SI protocol
Quoted 24 lines · Samuel Mendoza-Jonas
This introduces support for the NC-SI protocol, modelled as a phy driver for other ethernet drivers to consume.
NC-SI (Network Controller Sideband Interface) is a protocol to manage a sideband connection to a proper network interface, for example a BMC (Baseboard Management Controller) sharing the NIC of the host system. Probing and configuration occurs by communicating with the "remote" NIC via NC-SI control frames (Ethernet header
0x88f8).This implementation is roughly based on the upstream Linux implementation[0], with a reduced feature set and an emphasis on getting a link up as fast as possible rather than probing the full possible topology of the bus.
The current phy model relies on the network being "up", sending NC-SI command frames vianet_send_packet()and receiving them from thenet_loop()loop (added in a following patch).The
ncsi-pkt.hheader[1] is copied from the Linux kernel for consistent field definitions.[0]: https://github.com/torvalds/linux/tree/master/net/ncsi
[1]: https://github.com/torvalds/linux/blob/master/net/ncsi/ncsi-pkt.h
Quoted 7 lines
Signed-off-by Samuel Mendoza-Jonas <[email protected]>---
v2:
- Fix endianess issue when setting MAC address
- Make checksum offsets easier to read
- Instantiate per-phyncsi_privstructures
- Used updatencsi-pkt.hversion to include SPDX header
Thanks, the updates look good.
Re: [U-Boot] [PATCH v2 1/4] phy: Add support for the NC-SI protocol
In reply to Samuel Mendoza-JonasQuoted 18 lines · Samuel Mendoza-Jonas
This introduces support for the NC-SI protocol, modelled as a phy driver for other ethernet drivers to consume.
NC-SI (Network Controller Sideband Interface) is a protocol to manage a sideband connection to a proper network interface, for example a BMC (Baseboard Management Controller) sharing the NIC of the host system. Probing and configuration occurs by communicating with the "remote" NIC via NC-SI control frames (Ethernet header
0x88f8).This implementation is roughly based on the upstream Linux implementation[0], with a reduced feature set and an emphasis on getting a link up as fast as possible rather than probing the full possible topology of the bus.
The current phy model relies on the network being "up", sending NC-SI command frames vianet_send_packet()and receiving them from thenet_loop()loop (added in a following patch).
Quoted 7 lines
The
ncsi-pkt.hheader[1] is copied from the Linux kernel for consistent field definitions.[0]: https://github.com/torvalds/linux/tree/master/net/ncsi
[1]: https://github.com/torvalds/linux/blob/master/net/ncsi/ncsi-pkt.hSigned-off-by Samuel Mendoza-Jonas <[email protected]>
PATCH v2 2/4 phy: Include NC-SI in phy setup
In reply to Samuel Mendoza-JonasAdd NC-SI to the usual phy handling. This makes two notable changes:
- Somewhat similar to a fixed phy, phy_connect() will create an NC-SI phy if CONFIG_PHY_NCSI is defined.
- An early return is added to phy_read() and phy_write() to handle a case like the NC-SI phy which does not define a bus.
--- drivers/net/phy/phy.c | 7 +++++++ include/phy.h | 11 +++++++++++ include/phy_interface.h | 2 ++ 3 files changed, 20 insertions(+)
drivers/net/phy/phy.c +7 -0
@@ -539,6 +539,9 @@ int phy_init(void)#endif #ifdef CONFIG_PHY_FIXED phy_fixed_init (); +#endif +#ifdef CONFIG_PHY_NCSI +phy_ncsi_init ();#endif return 0 ; }
@@ -947,6 +950,10 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr, phydev =phy_connect_fixed (bus, dev, interface);#endif +#ifdef CONFIG_PHY_NCSI + phydev =phy_device_create (bus,0 ,PHY_NCSI_ID , false, interface); +#endif +if (!phydev) phydev =phy_find_by_mask (bus, mask, interface);
include/phy.h +11 -0
@@ -163,6 +163,11 @@ static inline int phy_read(struct phy_device *phydev, int devad, int regnum) {struct mii_dev *bus = phydev->bus; +if (!bus || !bus->read) { +debug ("%s: No bus configured\n" , __func__); +return -1 ; + } +return bus->read (bus, phydev->addr, devad, regnum); }
@@ -171,6 +176,11 @@ static inline int phy_write(struct phy_device *phydev, int devad, int regnum, {struct mii_dev *bus = phydev->bus; +if (!bus || !bus->read) { +debug ("%s: No bus configured\n" , __func__); +return -1 ; + } +return bus->write (bus, phydev->addr, devad, regnum, val); }
@@ -312,6 +322,7 @@ int phy_vitesse_init(void);int phy_xilinx_init (void );int phy_mscc_init (void );int phy_fixed_init (void ); +int phy_ncsi_init (void );int board_phy_config (struct phy_device *phydev);int get_phy_id (struct mii_dev *bus,int addr,int devad,u32 *phy_id);
include/phy_interface.h +2 -0
@@ -31,6 +31,7 @@ typedef enum {PHY_INTERFACE_MODE_XLAUI ,PHY_INTERFACE_MODE_CAUI2 ,PHY_INTERFACE_MODE_CAUI4 , +PHY_INTERFACE_MODE_NCSI ,PHY_INTERFACE_MODE_NONE ,/* Must be last */ PHY_INTERFACE_MODE_COUNT,
@@ -58,6 +59,7 @@ static const char * const phy_interface_strings[] = { [PHY_INTERFACE_MODE_XLAUI] = "xlaui4", [PHY_INTERFACE_MODE_CAUI2] = "caui2", [PHY_INTERFACE_MODE_CAUI4] = "caui4", + [PHY_INTERFACE_MODE_NCSI] = "NC-SI", [PHY_INTERFACE_MODE_NONE] = "", };
Signature · 1 line
2.21.0
Re: [PATCH v2 2/4] phy: Include NC-SI in phy setup
Quoted 8 lines · Samuel Mendoza-Jonas
Add NC-SI to the usual phy handling. This makes two notable changes:
- Somewhat similar to a fixed phy,phy_connect()will create an NC-SI phy ifCONFIG_PHY_NCSIis defined.
- An early return is added tophy_read()andphy_write()to handle a case like the NC-SI phy which does not define a bus.Signed-off-by Samuel Mendoza-Jonas <[email protected]>
Re: [U-Boot] [PATCH v2 2/4] phy: Include NC-SI in phy setup
In reply to Samuel Mendoza-JonasQuoted 8 lines · Samuel Mendoza-Jonas
Add NC-SI to the usual phy handling. This makes two notable changes:
- Somewhat similar to a fixed phy,phy_connect()will create an NC-SI phy ifCONFIG_PHY_NCSIis defined.
- An early return is added tophy_read()andphy_write()to handle a case like the NC-SI phy which does not define a bus.Signed-off-by Samuel Mendoza-Jonas <[email protected]>
PATCH v2 3/4 net/ftgmac100: Add NC-SI mode support
In reply to Samuel Mendoza-JonasUpdate the ftgmac100 driver to support NC-SI instead of an mdio phy where available. This is a common setup for Aspeed AST2x00 platforms.
NC-SI mode is determined from the device-tree if either phy-mode sets it or the use-ncsi property exists. If set then normal mdio setup is skipped in favour of the NC-SI phy.
--- drivers/net/ftgmac100.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)
drivers/net/ftgmac100.c +29 -10
@@ -18,6 +18,7 @@#include <wait_bit.h> #include <linux/io.h> #include <linux/iopoll.h> +#include <net/ncsi.h> #include "ftgmac100.h"
@@ -81,6 +82,7 @@ struct ftgmac100_data {struct mii_dev *bus;u32 phy_mode;u32 max_speed; +bool ncsi_mode;struct clk_bulk clks;
@@ -181,7 +183,7 @@ static int ftgmac100_phy_adjust_link(struct ftgmac100_data *priv)struct phy_device *phydev = priv->phydev;u32 maccr; -if (!phydev->link) { +if (!phydev->link && !priv->ncsi_mode) {dev_err (phydev->dev,"No link\n" );return -EREMOTEIO ; }
@@ -217,7 +219,8 @@ static int ftgmac100_phy_init(struct udevice *dev)if (!phydev)return -ENODEV ; - phydev->supported &=PHY_GBIT_FEATURES ; +if (!priv->ncsi_mode) + phydev->supported &=PHY_GBIT_FEATURES ;if (priv->max_speed) { ret =phy_set_supported (phydev, priv->max_speed);if (ret)
@@ -275,7 +278,8 @@ static void ftgmac100_stop(struct udevice *dev)writel (0 , &ftgmac100->maccr); -phy_shutdown (priv->phydev); +if (!priv->ncsi_mode) +phy_shutdown (priv->phydev); }static int ftgmac100_start (struct udevice *dev)
@@ -513,6 +517,7 @@ static int ftgmac100_ofdata_to_platdata(struct udevice *dev) pdata->iobase =devfdt_get_addr (dev); pdata->phy_interface =-1 ; phy_mode =dev_read_string (dev,"phy-mode" ); +if (phy_mode) pdata->phy_interface =phy_get_interface_by_name (phy_mode);if (pdata->phy_interface ==-1 ) {
@@ -537,8 +542,13 @@ static int ftgmac100_probe(struct udevice *dev) {struct eth_pdata *pdata =dev_get_platdata (dev);struct ftgmac100_data *priv =dev_get_priv (dev); +const char *phy_mode;int ret; + phy_mode =dev_read_string (dev,"phy-mode" ); + priv->ncsi_mode =dev_read_bool (dev,"use-ncsi" ) || + (phy_mode &&strcmp (phy_mode,"NC-SI" ) ==0 ); + priv->iobase = (struct ftgmac100 *)pdata->iobase; priv->phy_mode = pdata->phy_interface; priv->max_speed = pdata->max_speed;
@@ -548,10 +558,15 @@ static int ftgmac100_probe(struct udevice *dev)if (ret) goto out; - ret =ftgmac100_mdio_init (dev); -if (ret) { -dev_err (dev,"Failed to initialize mdiobus: %d\n" , ret); - goto out; +if (priv->ncsi_mode) { +printf ("%s - NCSI detected\n" , __func__); + }else { + ret =ftgmac100_mdio_init (dev); +if (ret) { +dev_err (dev,"Failed to initialize mdiobus: %d\n" , ret); + goto out; + } + } ret =ftgmac100_phy_init (dev);
@@ -571,9 +586,13 @@ static int ftgmac100_remove(struct udevice *dev) {struct ftgmac100_data *priv =dev_get_priv (dev); -free (priv->phydev); -mdio_unregister (priv->bus); -mdio_free (priv->bus); +if (!priv->ncsi_mode) { +free (priv->phydev); +mdio_unregister (priv->bus); +mdio_free (priv->bus); + }else { +free (priv->phydev); + }clk_release_bulk (&priv->clks);return 0 ;
Signature · 1 line
2.21.0
Re: [PATCH v2 3/4] net/ftgmac100: Add NC-SI mode support
Quoted 8 lines · Samuel Mendoza-Jonas
Update the ftgmac100 driver to support NC-SI instead of an mdio phy where available. This is a common setup for Aspeed AST2x00 platforms.
NC-SI mode is determined from the device-tree if either phy-mode sets it or the use-ncsi property exists. If set then normal mdio setup is skipped in favour of the NC-SI phy.
Signed-off-by Samuel Mendoza-Jonas <[email protected]>
LGTM. Some very minor remarks below in case you resend.
Thanks,
C.
Quoted 62 lines
--- drivers/net/ftgmac100.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)drivers/net/ftgmac100.c +8
-3@@ -18,6 +18,7 @@#include <wait_bit.h> #include <linux/io.h> #include <linux/iopoll.h> +#include <net/ncsi.h> #include "ftgmac100.h" @@ -81,6 +82,7 @@ struct ftgmac100_data {struct mii_dev *bus;u32 phy_mode;u32 max_speed; +bool ncsi_mode;struct clk_bulk clks;@@ -181,7 +183,7 @@ static int ftgmac100_phy_adjust_link(struct ftgmac100_data *priv)struct phy_device *phydev = priv->phydev;u32 maccr; -if (!phydev->link) { +if (!phydev->link && !priv->ncsi_mode) {dev_err (phydev->dev,"No link\n" );return -EREMOTEIO ; }@@ -217,7 +219,8 @@ static int ftgmac100_phy_init(struct udevice *dev)if (!phydev)return -ENODEV ; - phydev->supported &=PHY_GBIT_FEATURES ; +if (!priv->ncsi_mode) + phydev->supported &=PHY_GBIT_FEATURES ;if (priv->max_speed) { ret =phy_set_supported (phydev, priv->max_speed);if (ret)@@ -275,7 +278,8 @@ static void ftgmac100_stop(struct udevice *dev)writel (0 , &ftgmac100->maccr); -phy_shutdown (priv->phydev); +if (!priv->ncsi_mode) +phy_shutdown (priv->phydev); }static int ftgmac100_start (struct udevice *dev)@@ -513,6 +517,7 @@ static int ftgmac100_ofdata_to_platdata(struct udevice *dev) pdata->iobase =devfdt_get_addr (dev); pdata->phy_interface =-1 ; phy_mode =dev_read_string (dev,"phy-mode" ); +if (phy_mode) pdata->phy_interface =phy_get_interface_by_name (phy_mode);if (pdata->phy_interface ==-1 ) {
drivers/net/ftgmac100.c static int ftgmac100_probe(struct udevice *dev) · line 550
Quoted 9 lines
drivers/net/ftgmac100.c +4
-0@@ -537,8 +542,13 @@ static int ftgmac100_probe(struct udevice *dev) {struct eth_pdata *pdata =dev_get_platdata (dev);struct ftgmac100_data *priv =dev_get_priv (dev); +const char *phy_mode;int ret; + phy_mode =dev_read_string (dev,"phy-mode" ); + priv->ncsi_mode =dev_read_bool (dev,"use-ncsi" ) || + (phy_mode &&strcmp (phy_mode,"NC-SI" ) ==0 );
strncmp() may be ? I think a helper routine would make sense.
Quoted 5 lines
drivers/net/ftgmac100.c +1
-0+ priv->iobase = (struct ftgmac100 *)pdata->iobase; priv->phy_mode = pdata->phy_interface; priv->max_speed = pdata->max_speed;
drivers/net/ftgmac100.c static int ftgmac100_probe(struct udevice *dev) · line 562
Quoted 9 lines
drivers/net/ftgmac100.c +2
-4@@ -548,10 +558,15 @@ static int ftgmac100_probe(struct udevice *dev)if (ret) goto out; - ret =ftgmac100_mdio_init (dev); -if (ret) { -dev_err (dev,"Failed to initialize mdiobus: %d\n" , ret); - goto out; +if (priv->ncsi_mode) { +printf ("%s - NCSI detected\n" , __func__);
"NC-SI"
Quoted 28 lines
drivers/net/ftgmac100.c +14
-3+ }else { + ret =ftgmac100_mdio_init (dev); +if (ret) { +dev_err (dev,"Failed to initialize mdiobus: %d\n" , ret); + goto out; + } + } ret =ftgmac100_phy_init (dev);@@ -571,9 +586,13 @@ static int ftgmac100_remove(struct udevice *dev) {struct ftgmac100_data *priv =dev_get_priv (dev); -free (priv->phydev); -mdio_unregister (priv->bus); -mdio_free (priv->bus); +if (!priv->ncsi_mode) { +free (priv->phydev); +mdio_unregister (priv->bus); +mdio_free (priv->bus); + }else { +free (priv->phydev); + }clk_release_bulk (&priv->clks);return 0 ;
Re: [U-Boot] [PATCH v2 3/4] net/ftgmac100: Add NC-SI mode support
In reply to Samuel Mendoza-JonasQuoted 85 lines · Samuel Mendoza-Jonas
Update the ftgmac100 driver to support NC-SI instead of an mdio phy where available. This is a common setup for Aspeed AST2x00 platforms.
NC-SI mode is determined from the device-tree if either phy-mode sets it or the use-ncsi property exists. If set then normal mdio setup is skipped in favour of the NC-SI phy.
Signed-off-by Samuel Mendoza-Jonas <[email protected]>--- drivers/net/ftgmac100.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)drivers/net/ftgmac100.c +13
-3@@ -18,6 +18,7 @@#include <wait_bit.h> #include <linux/io.h> #include <linux/iopoll.h> +#include <net/ncsi.h> #include "ftgmac100.h" @@ -81,6 +82,7 @@ struct ftgmac100_data {struct mii_dev *bus;u32 phy_mode;u32 max_speed; +bool ncsi_mode;struct clk_bulk clks;@@ -181,7 +183,7 @@ static int ftgmac100_phy_adjust_link(struct ftgmac100_data *priv)struct phy_device *phydev = priv->phydev;u32 maccr; -if (!phydev->link) { +if (!phydev->link && !priv->ncsi_mode) {dev_err (phydev->dev,"No link\n" );return -EREMOTEIO ; }@@ -217,7 +219,8 @@ static int ftgmac100_phy_init(struct udevice *dev)if (!phydev)return -ENODEV ; - phydev->supported &=PHY_GBIT_FEATURES ; +if (!priv->ncsi_mode) + phydev->supported &=PHY_GBIT_FEATURES ;if (priv->max_speed) { ret =phy_set_supported (phydev, priv->max_speed);if (ret)@@ -275,7 +278,8 @@ static void ftgmac100_stop(struct udevice *dev)writel (0 , &ftgmac100->maccr); -phy_shutdown (priv->phydev); +if (!priv->ncsi_mode) +phy_shutdown (priv->phydev); }static int ftgmac100_start (struct udevice *dev)@@ -513,6 +517,7 @@ static int ftgmac100_ofdata_to_platdata(struct udevice *dev) pdata->iobase =devfdt_get_addr (dev); pdata->phy_interface =-1 ; phy_mode =dev_read_string (dev,"phy-mode" ); +if (phy_mode) pdata->phy_interface =phy_get_interface_by_name (phy_mode);if (pdata->phy_interface ==-1 ) {@@ -537,8 +542,13 @@ static int ftgmac100_probe(struct udevice *dev) {struct eth_pdata *pdata =dev_get_platdata (dev);struct ftgmac100_data *priv =dev_get_priv (dev); +const char *phy_mode;int ret; + phy_mode =dev_read_string (dev,"phy-mode" ); + priv->ncsi_mode =dev_read_bool (dev,"use-ncsi" ) || + (phy_mode &&strcmp (phy_mode,"NC-SI" ) ==0 ); + priv->iobase = (struct ftgmac100 *)pdata->iobase; priv->phy_mode = pdata->phy_interface; priv->max_speed = pdata->max_speed;
drivers/net/ftgmac100.c static int ftgmac100_probe(struct udevice *dev) · line 562
Quoted 9 lines
drivers/net/ftgmac100.c +2
-4@@ -548,10 +558,15 @@ static int ftgmac100_probe(struct udevice *dev)if (ret) goto out; - ret =ftgmac100_mdio_init (dev); -if (ret) { -dev_err (dev,"Failed to initialize mdiobus: %d\n" , ret); - goto out; +if (priv->ncsi_mode) { +printf ("%s - NCSI detected\n" , __func__);
NC-SI
Quoted 11 lines
drivers/net/ftgmac100.c +7
-0+ }else { + ret =ftgmac100_mdio_init (dev); +if (ret) { +dev_err (dev,"Failed to initialize mdiobus: %d\n" , ret); + goto out; + } + } ret =ftgmac100_phy_init (dev);
drivers/net/ftgmac100.c static int ftgmac100_remove(struct udevice *dev) · line 576
Quoted 6 lines
drivers/net/ftgmac100.c +0
-3@@ -571,9 +586,13 @@ static int ftgmac100_remove(struct udevice *dev) {struct ftgmac100_data *priv =dev_get_priv (dev); -free (priv->phydev); -mdio_unregister (priv->bus); -mdio_free (priv->bus);
This should be before the test like it was and eliminate the else... free(priv->phydev);
Quoted 17 lines
drivers/net/ftgmac100.c +7
-1+if (!priv->ncsi_mode) { +free (priv->phydev); +mdio_unregister (priv->bus); +mdio_free (priv->bus); + }else { +free (priv->phydev); + }clk_release_bulk (&priv->clks);return 0 ; --2.21.0
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v2 4/4 net: NC-SI setup and handling
In reply to Samuel Mendoza-JonasAdd the handling of NC-SI ethernet frames, and add a check at the start of net_loop() to configure NC-SI before starting other network commands. This also adds an "ncsi" command to manually start NC-SI configuration.
---
v2: Update ncsi command help text
cmd/Kconfig | 8 ++++++++ cmd/net.c | 18 ++++++++++++++++++ include/net.h | 2 +- net/net.c | 27 ++++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-)
cmd/Kconfig +8 -0
@@ -1332,6 +1332,14 @@ config CMD_LINK_LOCAL help Acquire a network IP address using the link-local protocol +config CMD_NCSI + bool "ncsi" + depends on PHY_NCSI + help + Manually configure the attached NIC via NC-SI. + Normally this happens automatically before other network + operations. + endif config CMD_ETHSW
cmd/net.c +18 -0
@@ -457,3 +457,21 @@ U_BOOT_CMD( );#endif /* CONFIG_CMD_LINK_LOCAL */ + +#if defined(CONFIG_CMD_NCSI ) +static int do_ncsi (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) +{ +if (net_loop (NCSI ) <0 ) +return CMD_RET_FAILURE ; + +return CMD_RET_SUCCESS ; +} + +U_BOOT_CMD ( + ncsi,1 ,1 , do_ncsi, +"Configure attached NIC via NC-SI" , +"" +); + +#endif /* CONFIG_CMD_NCSI */
include/net.h +1 -1
@@ -531,7 +531,7 @@ extern int net_restart_wrap; /* Tried all network devices */enum proto_t {BOOTP ,RARP ,ARP ,TFTPGET ,DHCP ,PING ,DNS ,NFS ,CDP ,NETCONS ,SNTP , -TFTPSRV ,TFTPPUT ,LINKLOCAL ,FASTBOOT ,WOL +TFTPSRV ,TFTPPUT ,LINKLOCAL ,FASTBOOT ,WOL ,NCSI };extern char net_boot_file_name[1024 ];/* Boot File name */
net/net.c +26 -1
@@ -95,6 +95,7 @@#include <net.h> #include <net/fastboot.h> #include <net/tftp.h> +#include <net/ncsi.h> #if defined(CONFIG_LED_STATUS )#include <miiphy.h> #include <status_led.h>
@@ -407,6 +408,16 @@ int net_loop(enum proto_t protocol) net_try_count =1 ;debug_cond (DEBUG_INT_STATE ,"--- net_loop Entry\n" ); +#ifdef CONFIG_PHY_NCSI +if (protocol !=NCSI && !ncsi_active ()) { +printf ("%s: configuring NCSI first\n" , __func__); +if (net_loop (NCSI ) <0 ) +return ret; +eth_init_state_only (); + goto restart; + } +#endif +bootstage_mark_name (BOOTSTAGE_ID_ETH_START ,"eth_start" );net_init ();if (eth_is_on_demand_init () || protocol !=NETCONS ) {
@@ -420,6 +431,7 @@ int net_loop(enum proto_t protocol) }else {eth_init_state_only (); } + restart: #ifdef CONFIG_USB_KEYBOARD net_busy_flag =0 ;
@@ -526,6 +538,11 @@ restart:case WOL :wol_start ();break ; +#endif +#if defined(CONFIG_CMD_NCSI ) +case NCSI : +ncsi_probe_packages (); +break ;#endif default :break ;
@@ -637,7 +654,7 @@ restart:env_set_hex ("filesize" , net_boot_file_size);env_set_hex ("fileaddr" , load_addr); } -if (protocol !=NETCONS ) +if (protocol !=NETCONS && protocol !=NCSI )eth_halt ();else eth_halt_state_only ();
@@ -1318,6 +1335,11 @@ void net_process_received_packet(uchar *in_packet, int len)case PROT_WOL :wol_receive (ip, len);break ; +#endif +#ifdef CONFIG_PHY_NCSI +case PROT_NCSI : +ncsi_receive (et, ip, len); +break ;#endif } }
@@ -1379,6 +1401,9 @@ common:#ifdef CONFIG_CMD_RARP case RARP : +#endif +#ifdef CONFIG_CMD_NCSI +case NCSI :#endif case BOOTP :case CDP :
Signature · 1 line
2.21.0
Re: [PATCH v2 4/4] net: NC-SI setup and handling
Quoted 20 lines · Samuel Mendoza-Jonas
Add the handling of NC-SI ethernet frames, and add a check at the start of
net_loop()to configure NC-SI before starting other network commands. This also adds an "ncsi" command to manually start NC-SI configuration.Signed-off-by Samuel Mendoza-Jonas <[email protected]>---
v2: Update ncsi command help textcmd/Kconfig | 8 ++++++++ cmd/net.c | 18 ++++++++++++++++++ include/net.h | 2 +- net/net.c | 27 ++++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-)cmd/Kconfig +0
-0
cmd/Kconfig config CMD_LINK_LOCAL · line 1341
Quoted 10 lines
cmd/Kconfig +7
-0@@ -1332,6 +1332,14 @@ config CMD_LINK_LOCAL help Acquire a network IP address using the link-local protocol +config CMD_NCSI + bool "ncsi" + depends on PHY_NCSI + help + Manually configure the attached NIC via NC-SI. + Normally this happens automatically before other network + operations.
Do we need to make it even clearer that "this command not required to use NCSI"?
I'm thinking of future me wondering if we should put this in openbmc builds or not. It would be good to have your advice on this.
Cheers,
Joel
Re: [PATCH v2 4/4] net: NC-SI setup and handling
Quoted 33 lines · Joel Stanley
Quoted 19 lines · Samuel Mendoza-Jonas
Add the handling of NC-SI ethernet frames, and add a check at the start of
net_loop()to configure NC-SI before starting other network commands. This also adds an "ncsi" command to manually start NC-SI configuration.Signed-off-by Samuel Mendoza-Jonas <[email protected]>---
v2: Update ncsi command help textcmd/Kconfig | 8 ++++++++ cmd/net.c | 18 ++++++++++++++++++ include/net.h | 2 +- net/net.c | 27 ++++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-)cmd/Kconfig +0
-0cmd/Kconfig config CMD_LINK_LOCAL · line 1341
Quoted 10 lines
cmd/Kconfig +7
-0@@ -1332,6 +1332,14 @@ config CMD_LINK_LOCAL help Acquire a network IP address using the link-local protocol +config CMD_NCSI + bool "ncsi" + depends on PHY_NCSI + help + Manually configure the attached NIC via NC-SI. + Normally this happens automatically before other network + operations.Do we need to make it even clearer that "this command not required to use NCSI"?
Quoted 6 lines
I'm thinking of future me wondering if we should put this in openbmc builds or not. It would be good to have your advice on this.
Cheers,
Joel
Either way; it's definitely not required but might be useful for sanity checking things in BMC bringup.
Re: [U-Boot] [PATCH v2 4/4] net: NC-SI setup and handling
In reply to Samuel Mendoza-JonasQuoted 86 lines · Samuel Mendoza-Jonas
Add the handling of NC-SI ethernet frames, and add a check at the start of
net_loop()to configure NC-SI before starting other network commands. This also adds an "ncsi" command to manually start NC-SI configuration.Signed-off-by Samuel Mendoza-Jonas <[email protected]>---
v2: Update ncsi command help textcmd/Kconfig | 8 ++++++++ cmd/net.c | 18 ++++++++++++++++++ include/net.h | 2 +- net/net.c | 27 ++++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-)cmd/Kconfig +8
-0@@ -1332,6 +1332,14 @@ config CMD_LINK_LOCAL help Acquire a network IP address using the link-local protocol +config CMD_NCSI + bool "ncsi" + depends on PHY_NCSI + help + Manually configure the attached NIC via NC-SI. + Normally this happens automatically before other network + operations. + endif config CMD_ETHSWcmd/net.c +18
-0@@ -457,3 +457,21 @@ U_BOOT_CMD( );#endif /* CONFIG_CMD_LINK_LOCAL */ + +#if defined(CONFIG_CMD_NCSI ) +static int do_ncsi (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) +{ +if (net_loop (NCSI ) <0 ) +return CMD_RET_FAILURE ; + +return CMD_RET_SUCCESS ; +} + +U_BOOT_CMD ( + ncsi,1 ,1 , do_ncsi, +"Configure attached NIC via NC-SI" , +"" +); + +#endif /* CONFIG_CMD_NCSI */ include/net.h +1
-1@@ -531,7 +531,7 @@ extern int net_restart_wrap; /* Tried all network devices */enum proto_t {BOOTP ,RARP ,ARP ,TFTPGET ,DHCP ,PING ,DNS ,NFS ,CDP ,NETCONS ,SNTP , -TFTPSRV ,TFTPPUT ,LINKLOCAL ,FASTBOOT ,WOL +TFTPSRV ,TFTPPUT ,LINKLOCAL ,FASTBOOT ,WOL ,NCSI };extern char net_boot_file_name[1024 ];/* Boot File name */ net/net.c +1
-0@@ -95,6 +95,7 @@#include <net.h> #include <net/fastboot.h> #include <net/tftp.h> +#include <net/ncsi.h> #if defined(CONFIG_LED_STATUS )#include <miiphy.h> #include <status_led.h>
net/net.c int net_loop(enum proto_t protocol) · line 413
Quoted 6 lines
net/net.c +3
-0@@ -407,6 +408,16 @@ int net_loop(enum proto_t protocol) net_try_count =1 ;debug_cond (DEBUG_INT_STATE ,"--- net_loop Entry\n" ); +#ifdef CONFIG_PHY_NCSI +if (protocol !=NCSI && !ncsi_active ()) { +printf ("%s: configuring NCSI first\n" , __func__);
NC-SI
Quoted 31 lines
net/net.c +13
-0+if (net_loop (NCSI ) <0 ) +return ret; +eth_init_state_only (); + goto restart; + } +#endif +bootstage_mark_name (BOOTSTAGE_ID_ETH_START ,"eth_start" );net_init ();if (eth_is_on_demand_init () || protocol !=NETCONS ) {@@ -420,6 +431,7 @@ int net_loop(enum proto_t protocol) }else {eth_init_state_only (); } + restart: #ifdef CONFIG_USB_KEYBOARD net_busy_flag =0 ;@@ -526,6 +538,11 @@ restart:case WOL :wol_start ();break ; +#endif +#if defined(CONFIG_CMD_NCSI ) +case NCSI : +ncsi_probe_packages (); +break ;#endif default :break ;
net/net.c restart: · line 657
Quoted 5 lines
net/net.c +1
-1@@ -637,7 +654,7 @@ restart:env_set_hex ("filesize" , net_boot_file_size);env_set_hex ("fileaddr" , load_addr); } -if (protocol !=NETCONS ) +if (protocol !=NETCONS && protocol !=NCSI )
Why is this using eth_halt_state_only()? It is not using the eth_init_state_only().
Quoted 32 lines
net/net.c +8
-1eth_halt (); elseeth_halt_state_only ();@@ -1318,6 +1335,11 @@ void net_process_received_packet(uchar *in_packet, int len)case PROT_WOL :wol_receive (ip, len);break ; +#endif +#ifdef CONFIG_PHY_NCSI +case PROT_NCSI : +ncsi_receive (et, ip, len); +break ;#endif } }@@ -1379,6 +1401,9 @@ common:#ifdef CONFIG_CMD_RARP case RARP : +#endif +#ifdef CONFIG_CMD_NCSI +case NCSI :#endif case BOOTP :case CDP : --2.21.0
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v2 4/4] net: NC-SI setup and handling
Quoted 135 lines · Joe Hershberger
Quoted 91 lines · Samuel Mendoza-Jonas
Add the handling of NC-SI ethernet frames, and add a check at the start
ofnet_loop()to configure NC-SI before starting other network commands.
This also adds an "ncsi" command to manually start NC-SI configuration.Signed-off-by Samuel Mendoza-Jonas <[email protected]>---
v2: Update ncsi command help textcmd/Kconfig | 8 ++++++++ cmd/net.c | 18 ++++++++++++++++++ include/net.h | 2 +- net/net.c | 27 ++++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-)cmd/Kconfig +0
-0@@ -1332,6 +1332,14 @@ config CMD_LINK_LOCAL help Acquire a network IP address using the link-localprotocol
cmd/Kconfig +8
-0+config CMD_NCSI + bool "ncsi" + depends on PHY_NCSI + help + Manually configure the attached NIC via NC-SI. + Normally this happens automatically before other network + operations. + endif config CMD_ETHSWcmd/net.c +18
-0@@ -457,3 +457,21 @@ U_BOOT_CMD( );#endif /* CONFIG_CMD_LINK_LOCAL */ + +#if defined(CONFIG_CMD_NCSI ) +static int do_ncsi (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) +{ +if (net_loop (NCSI ) <0 ) +return CMD_RET_FAILURE ; + +return CMD_RET_SUCCESS ; +} + +U_BOOT_CMD ( + ncsi,1 ,1 , do_ncsi, +"Configure attached NIC via NC-SI" , +"" +); + +#endif /* CONFIG_CMD_NCSI */ include/net.h +0
-0@@ -531,7 +531,7 @@ extern int net_restart_wrap; /*Tried all network devices */
enum
proto_t{
BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP,
NETCONS, SNTP,include/net.h +1
-1- TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL + TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, NCSI };extern char net_boot_file_name[1024 ];/* Boot File name */ net/net.c +1
-0@@ -95,6 +95,7 @@#include <net.h> #include <net/fastboot.h> #include <net/tftp.h> +#include <net/ncsi.h> #if defined(CONFIG_LED_STATUS )#include <miiphy.h> #include <status_led.h> net/net.c int net_loop(enum proto_t protocol) · line 413
Quoted 6 lines
net/net.c +3
-0@@ -407,6 +408,16 @@ int net_loop(enum proto_t protocol) net_try_count =1 ;debug_cond (DEBUG_INT_STATE ,"--- net_loop Entry\n" ); +#ifdef CONFIG_PHY_NCSI +if (protocol !=NCSI && !ncsi_active ()) { +printf ("%s: configuring NCSI first\n" , __func__);NC-SI
Quoted 33 lines
net/net.c +13
-0+if (net_loop (NCSI ) <0 ) +return ret; +eth_init_state_only (); + goto restart; + } +#endif +bootstage_mark_name (BOOTSTAGE_ID_ETH_START ,"eth_start" );net_init ();if (eth_is_on_demand_init () || protocol !=NETCONS ) {@@ -420,6 +431,7 @@ int net_loop(enum proto_t protocol) }else {eth_init_state_only (); } + restart: #ifdef CONFIG_USB_KEYBOARD net_busy_flag =0 ;@@ -526,6 +538,11 @@ restart:case WOL :wol_start ();break ; +#endif +#if defined(CONFIG_CMD_NCSI ) +case NCSI : +ncsi_probe_packages (); +break ;#endif default :break ;@@ -637,7 +654,7 @@ restart:env_set_hex ("filesize" , net_boot_file_size);
Quoted 8 lines
net/net.c restart:
Quoted 5 lines
net/net.c +1
-1env_set_hex ("fileaddr" , load_addr); } -if (protocol !=NETCONS ) +if (protocol !=NETCONS && protocol !=NCSI )Why is this using
eth_halt_state_only()? It is not using theeth_init_state_only().
The aim here was to avoid completely halting the network state because we're about to start the net_loop again with whatever protocol caused NC-SI to need to be configured. I'm new to this part of u-boot however so it's possible I've misinterpeted the actions here; the NC-SI model is an odd fit for the network loop.
Quoted 34 lines
Quoted 34 lines
net/net.c +0
-0eth_halt ();else eth_halt_state_only();net/net.c +5
-0@@ -1318,6 +1335,11 @@ void net_process_received_packet(uchar *in_packet, int len)case PROT_WOL :wol_receive (ip, len);break ; +#endif +#ifdef CONFIG_PHY_NCSI +case PROT_NCSI : +ncsi_receive (et, ip, len); +break ;#endif }}
net/net.c +3
-1@@ -1379,6 +1401,9 @@ common:#ifdef CONFIG_CMD_RARP case RARP : +#endif +#ifdef CONFIG_CMD_NCSI +case NCSI :#endif case BOOTP :case CDP : --2.21.0
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Quoted 2 lines · Samuel Mendoza-Jonas
This series introduces support for the NC-SI protocol to u-boot, functionality which so far has only been available in vendor trees.
Would it be complex to add a romulus DT and config file ?
Thanks,
C.
Quoted 59 lines
NC-SI (Network Controller Sideband Interface) is a protocol to manage a sideband connection to a proper network interface, for example a BMC (Baseboard Management Controller) sharing the NIC of the host system. Probing and configuration occurs by communicating with the "remote" NIC via NC-SI control frames (Ethernet header
0x88f8).Since the RFC[0] the changes have been split out into a few different patches to make the overall changes more obvious. Additionally a few small improvements have been added including adding a check to see if NC-SI is already configured, and marking the PHY bus "reset" as invalid since it does not define a bus.
An example of NC-SI setup before a normal network command:
=> dhcp
net_loop: configuring NCSI first
ethernet at1e660000: link up, 100 Mbps full-duplex mac:0c:c4:7a:d5:48:43
NCSI: probing channels
NCSI: configuring channel 0
NCSI: configuration done!
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 10.61.161.188 (255 ms)[0]: https://patchwork.ozlabs.org/patch/1107087/
Changes in v2:
- Fix endianess issue when setting MAC address
- Make checksum offsets easier to read
- Instantiate per-phyncsi_privstructures
- Update ncsi command help text
- Used updatencsi-pkt.hversion to include SPDX headerSamuel Mendoza-Jonas (4):
phy: Add support for the NC-SI protocol
phy: Include NC-SI in phy setup
net/ftgmac100: Add NC-SI mode support
net: NC-SI setup and handlingcmd/Kconfig | 8 + cmd/net.c | 18 + drivers/net/ftgmac100.c | 39 +- drivers/net/phy/Kconfig | 4 + drivers/net/phy/Makefile | 1 + drivers/net/phy/ncsi.c | 896 +++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 7 + include/net.h | 3 +- include/net/ncsi-pkt.h | 442 +++++++++++++++++++ include/net/ncsi.h | 14 + include/phy.h | 12 + include/phy_interface.h | 2 + net/net.c | 27 +- 13 files changed, 1461 insertions(+), 12 deletions(-) create mode 100644 drivers/net/phy/ncsi.c create mode 100644 include/net/ncsi-pkt.h create mode 100644 include/net/ncsi.h
Quoted 6 lines · Cédric Le Goater
Quoted 2 lines · Samuel Mendoza-Jonas
This series introduces support for the NC-SI protocol to u-boot, functionality which so far has only been available in vendor trees.
Would it be complex to add a romulus DT and config file ?
I think it's a great idea to follow up with that. I suggested Sam focus on the network and ftgmac100 parts of NCSI first.
We will need to add support for the NCSI clocking in addition to the device tree and config.
Cheers,
Joel