Skip to contentSkip to conversation

FTGMAC100 nic model for the Aspeed SoCs

PATCH In review Cédric Le Goater 2 participants 7 messages Apr 14, 2017 – Apr 18, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover FTGMAC100 nic model for the Aspeed SoCs

Hi,

The Aspeed SoCs AST2400 and AST2500 have two FTGMAC100 ethernet controllers. This series proposes a model for this device and a way to customize the bit definitions which are slightly different from the Faraday definitions.

The last patch adds a fake NC-SI (Network Controller Sideband Interface) backend to pretend a NIC is being managed. This is only usable with the slirp stack for the moment.

The model has been tested on the 'palmetto', 'romulus' and 'ast2500-evb' machines using different implementations of the Linux driver and with U-Boot. It has been stressed with iperf.

The full patchset is available here, based on QEMU v2.9.0-rc4 :

https://github.com/legoater/qemu/commits/aspeed

To test, grab a palmetto or a romulus BMC firmware image :

https://openpower.xyz/job/openbmc-build/distro=ubuntu,target=palmetto/lastSuccessfulBuild/artifact/images/palmetto/flash-palmetto
https://openpower.xyz/job/openbmc-build/distro=ubuntu,target=romulus/lastSuccessfulBuild/artifact/images/romulus/flash-romulus

and start the machines with :

qemu-system-arm -m 512 -M romulus-bmc -drive file=flash-romulus,format=raw,if=mtd -nographic qemu-system-arm -m 512 -M palmetto-bmc -drive file=flash-palmetto,format=raw,if=mtd -nographic

the fake NC-SI NIC should come up :

ftgmac100 1e660000.ethernet eth0: NCSI interface up

and to log, use credentials root/0penBmc

Thanks,

C.

Changes since v2:
- rebased on QEMU v2.9.0-rc4
- modified the 'ncsi-pkt.h' file to add its location under the Linux tree
- removed useless zeroing of the 'reserved' fields
- introduced a ncsi_rsp_handlers array to hold the payload size and a specific handler routine for each command
- fixed the output size of the frame to match the command payload size

Changes since v1:
- removed TODO comments and used LOG_UNIMP in the read/write ops
- used camelcase for struct names and typedefs.
- removed the useless struct definitions for ring descriptors and the alignment pragma
- introduced a frame buffer at the machine level to reduce stack usage in the tx path.
- introduced symbolic constants for PHY values.
- introduced rtl8211e PHY chip specific registers
- removed qemu_set_irq() in reset path
- checked for dma_memory_read() errors. Also for write but that was less important as the descriptor is first read so it should be valid for the write.
- removed the irq state
- removed the weird hack to catch a first valid descriptor.
- fixed the read of the mac address

Cédric Le Goater (5):
hw/net: add MII definitions
net: add FTGMAC100 support
net/ftgmac100: add a 'aspeed' property
aspeed: add a FTGMAC100 nic
slirp: add a fake NC-SI backend

 default-configs/arm-softmmu.mak |    1 +
 hw/arm/aspeed_soc.c             |   21 +
 hw/net/Makefile.objs            |    1 +
 hw/net/ftgmac100.c              | 1016 +++++++++++++++++++++++++++++++++++++++
 include/hw/arm/aspeed_soc.h     |    2 +
 include/hw/net/ftgmac100.h      |   64 +++
 include/hw/net/mii.h            |   71 ++-
 include/net/eth.h               |    1 +
 slirp/Makefile.objs             |    2 +-
 slirp/ncsi-pkt.h                |  419 ++++++++++++++++
 slirp/ncsi.c                    |  130 +++++
 slirp/slirp.c                   |    4 +
 slirp/slirp.h                   |    3 +
 13 files changed, 1716 insertions(+), 19 deletions(-)
 create mode 100644 hw/net/ftgmac100.c
 create mode 100644 include/hw/net/ftgmac100.h
 create mode 100644 slirp/ncsi-pkt.h
 create mode 100644 slirp/ncsi.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/5 hw/net: add MII definitions

This adds comments on the Basic mode control and status registers bit definitions. It also adds a couple of bits for 1000BASE-T and the RealTek 8211E PHY for the FTGMAC100 model to use.

---
 include/hw/net/mii.h | 71 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 53 insertions(+), 18 deletions(-)
include/hw/net/mii.h +53 -18
index 9fdd7bbe75f1..6ce48a6d7802 100644
@@ -22,13 +22,20 @@
 #define MII_H
 
 /* PHY registers */
-#define MII_BMCR            0
-#define MII_BMSR            1
-#define MII_PHYID1          2
-#define MII_PHYID2          3
-#define MII_ANAR            4
-#define MII_ANLPAR          5
-#define MII_ANER            6
+#define MII_BMCR            0  /* Basic mode control register */
+#define MII_BMSR            1  /* Basic mode status register */
+#define MII_PHYID1          2  /* ID register 1 */
+#define MII_PHYID2          3  /* ID register 2 */
+#define MII_ANAR            4  /* Autonegotiation advertisement */
+#define MII_ANLPAR          5  /* Autonegotiation lnk partner abilities */
+#define MII_ANER            6  /* Autonegotiation expansion */
+#define MII_ANNP            7  /* Autonegotiation next page */
+#define MII_ANLPRNP         8  /* Autonegotiation link partner rx next page */
+#define MII_CTRL1000        9  /* 1000BASE-T control */
+#define MII_STAT1000        10 /* 1000BASE-T status */
+#define MII_MDDACR          13 /* MMD access control */
+#define MII_MDDAADR         14 /* MMD access address data */
+#define MII_EXTSTAT         15 /* Extended Status */
 #define MII_NSR             16
 #define MII_LBREMR          17
 #define MII_REC             18
@@ -38,19 +45,33 @@
 /* PHY registers fields */
 #define MII_BMCR_RESET      (1 << 15)
 #define MII_BMCR_LOOPBACK   (1 << 14)
-#define MII_BMCR_SPEED      (1 << 13)
-#define MII_BMCR_AUTOEN     (1 << 12)
-#define MII_BMCR_FD         (1 << 8)
+#define MII_BMCR_SPEED100   (1 << 13)  /* LSB of Speed (100) */
+#define MII_BMCR_SPEED      MII_BMCR_SPEED100
+#define MII_BMCR_AUTOEN     (1 << 12) /* Autonegotiation enable */
+#define MII_BMCR_PDOWN      (1 << 11) /* Enable low power state */
+#define MII_BMCR_ISOLATE    (1 << 10) /* Isolate data paths from MII */
+#define MII_BMCR_ANRESTART  (1 << 9)  /* Auto negotiation restart */
+#define MII_BMCR_FD         (1 << 8)  /* Set duplex mode */
+#define MII_BMCR_CTST       (1 << 7)  /* Collision test */
+#define MII_BMCR_SPEED1000  (1 << 6)  /* MSB of Speed (1000) */
 
-#define MII_BMSR_100TX_FD   (1 << 14)
-#define MII_BMSR_100TX_HD   (1 << 13)
-#define MII_BMSR_10T_FD     (1 << 12)
-#define MII_BMSR_10T_HD     (1 << 11)
-#define MII_BMSR_MFPS       (1 << 6)
-#define MII_BMSR_AN_COMP    (1 << 5)
-#define MII_BMSR_AUTONEG    (1 << 3)
-#define MII_BMSR_LINK_ST    (1 << 2)
+#define MII_BMSR_100TX_FD   (1 << 14) /* Can do 100mbps, full-duplex */
+#define MII_BMSR_100TX_HD   (1 << 13) /* Can do 100mbps, half-duplex */
+#define MII_BMSR_10T_FD     (1 << 12) /* Can do 10mbps, full-duplex */
+#define MII_BMSR_10T_HD     (1 << 11) /* Can do 10mbps, half-duplex */
+#define MII_BMSR_100T2_FD   (1 << 10) /* Can do 100mbps T2, full-duplex */
+#define MII_BMSR_100T2_HD   (1 << 9)  /* Can do 100mbps T2, half-duplex */
+#define MII_BMSR_EXTSTAT    (1 << 8)  /* Extended status in register 15 */
+#define MII_BMSR_MFPS       (1 << 6)  /* MII Frame Preamble Suppression */
+#define MII_BMSR_AN_COMP    (1 << 5)  /* Auto-negotiation complete */
+#define MII_BMSR_RFAULT     (1 << 4)  /* Remote fault */
+#define MII_BMSR_AUTONEG    (1 << 3)  /* Able to do auto-negotiation */
+#define MII_BMSR_LINK_ST    (1 << 2)  /* Link status */
+#define MII_BMSR_JABBER     (1 << 1)  /* Jabber detected */
+#define MII_BMSR_EXTCAP     (1 << 0)  /* Ext-reg capability */
 
+#define MII_ANAR_PAUSE_ASYM (1 << 11) /* Try for asymetric pause */
+#define MII_ANAR_PAUSE      (1 << 10) /* Try for pause */
 #define MII_ANAR_TXFD       (1 << 8)
 #define MII_ANAR_TX         (1 << 7)
 #define MII_ANAR_10FD       (1 << 6)
@@ -58,17 +79,31 @@
 #define MII_ANAR_CSMACD     (1 << 0)
 
 #define MII_ANLPAR_ACK      (1 << 14)
+#define MII_ANLPAR_PAUSEASY (1 << 11) /* can pause asymmetrically */
+#define MII_ANLPAR_PAUSE    (1 << 10) /* can pause */
 #define MII_ANLPAR_TXFD     (1 << 8)
 #define MII_ANLPAR_TX       (1 << 7)
 #define MII_ANLPAR_10FD     (1 << 6)
 #define MII_ANLPAR_10       (1 << 5)
 #define MII_ANLPAR_CSMACD   (1 << 0)
 
+#define MII_ANER_NWAY       (1 << 0) /* Can do N-way auto-nego */
+
+#define MII_CTRL1000_FULL   (1 << 9)  /* 1000BASE-T full duplex */
+#define MII_CTRL1000_HALF   (1 << 8)  /* 1000BASE-T half duplex */
+
+#define MII_STAT1000_FULL   (1 << 11) /* 1000BASE-T full duplex */
+#define MII_STAT1000_HALF   (1 << 10) /* 1000BASE-T half duplex */
+
 /* List of vendor identifiers */
 /* RealTek 8201 */
 #define RTL8201CP_PHYID1    0x0000
 #define RTL8201CP_PHYID2    0x8201
 
+/* RealTek 8211E */
+#define RTL8211E_PHYID1     0x001c
+#define RTL8211E_PHYID2     0xc915
+
 /* National Semiconductor DP83848 */
 #define DP83848_PHYID1      0x2000
 #define DP83848_PHYID2      0x5c90
Signature · 1 line
2.7.4
#2 lore raw

PATCH v3 2/5 net: add FTGMAC100 support

In reply to Cédric Le Goater

The FTGMAC100 device is an Ethernet controller with DMA function that can be found on Aspeed SoCs (which include NCSI).

It is fully compliant with IEEE 802.3 specification for 10/100 Mbps Ethernet and IEEE 802.3z specification for 1000 Mbps Ethernet and includes Reduced Media Independent Interface (RMII) and Reduced Gigabit Media Independent Interface (RGMII) interfaces. It adopts an AHB bus interface and integrates a link list DMA engine with direct M-Bus accesses for transmitting and receiving packets. It has independent TX/RX fifos, supports half and full duplex (1000 Mbps mode only supports full duplex), flow control for full duplex and backpressure for half duplex.

The FTGMAC100 also implements IP, TCP, UDP checksum offloads and supports IEEE 802.1Q VLAN tag insertion and removal. It offers high-priority transmit queue for QoS and CoS applications

This model is backed with a RealTek 8211E PHY which is the chip found on the AST2500 EVB. It is complete enough to satisfy two different Linux drivers and a U-Boot driver. Not supported features are :

- IEEE 802.1Q VLAN
- High Priority Transmit Queue
- Wake-On-LAN functions

The code is based on the Coldfire Fast Ethernet Controller model.

---
Tested on the palmetto, romulus, ast2500 evb machines.

Changes since v1:
- removed TODO comments and used LOG_UNIMP in the read/write ops
- used camelcase for struct names and typedefs.
- removed the useless struct definitions for ring descriptors and the alignment pragma
- introduced a frame buffer at the machine level to reduce stack usage in the tx path.
- introduced symbolic constants for PHY values.
- introduced rtl8211e PHY chip specific registers
- removed qemu_set_irq() in reset path
- checked for dma_memory_read() errors. Also for write but that was less important as the descriptor is first read so it should be valid for the write.
- removed the irq state
- removed the weird hack to catch a first valid descriptor.
- fixed the read of the mac address

 default-configs/arm-softmmu.mak |    1 +
 hw/net/Makefile.objs            |    1 +
 hw/net/ftgmac100.c              | 1003 +++++++++++++++++++++++++++++++++++++++
 include/hw/net/ftgmac100.h      |   60 +++
 4 files changed, 1065 insertions(+)
 create mode 100644 hw/net/ftgmac100.c
 create mode 100644 include/hw/net/ftgmac100.h
default-configs/arm-softmmu.mak +1 -0
index 1e3bd2b8ca23..78d7af03a2e8 100644
@@ -29,6 +29,7 @@ CONFIG_LAN9118=y
 CONFIG_SMC91C111=y
 CONFIG_ALLWINNER_EMAC=y
 CONFIG_IMX_FEC=y
+CONFIG_FTGMAC100=y
 CONFIG_DS1338=y
 CONFIG_PFLASH_CFI01=y
 CONFIG_PFLASH_CFI02=y
hw/net/Makefile.objs +1 -0
index 6a95d92d37f8..5ddaffe63a46 100644
@@ -26,6 +26,7 @@ common-obj-$(CONFIG_IMX_FEC) += imx_fec.o
 common-obj-$(CONFIG_CADENCE) += cadence_gem.o
 common-obj-$(CONFIG_STELLARIS_ENET) += stellaris_enet.o
 common-obj-$(CONFIG_LANCE) += lance.o
+common-obj-$(CONFIG_FTGMAC100) += ftgmac100.o
 
 obj-$(CONFIG_ETRAXFS) += etraxfs_eth.o
 obj-$(CONFIG_COLDFIRE) += mcf_fec.o
hw/net/ftgmac100.c new file +1003 -0

1,003 lines not on this page · raw message

include/hw/net/ftgmac100.h new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

PATCH v3 3/5 net/ftgmac100: add a 'aspeed' property

In reply to Cédric Le Goater

The Aspeed SoCs have a different definition of the end of the ring buffer bit. Add a property to specify which set of bits should be used by the NIC.

---
 hw/net/ftgmac100.c         | 17 +++++++++++++++--
 include/hw/net/ftgmac100.h |  4 ++++
 2 files changed, 19 insertions(+), 2 deletions(-)
hw/net/ftgmac100.c +15 -2
index fc309b3629fd..4c218bd79c64 100644
@@ -126,6 +126,7 @@
 #define FTGMAC100_TXDES0_CRC_ERR         (1 << 19)
 #define FTGMAC100_TXDES0_LTS             (1 << 28)
 #define FTGMAC100_TXDES0_FTS             (1 << 29)
+#define FTGMAC100_TXDES0_EDOTR_ASPEED    (1 << 30)
 #define FTGMAC100_TXDES0_TXDMA_OWN       (1 << 31)
 
 #define FTGMAC100_TXDES1_VLANTAG_CI(x)   ((x) & 0xffff)
@@ -154,6 +155,7 @@
 #define FTGMAC100_RXDES0_PAUSE_FRAME     (1 << 25)
 #define FTGMAC100_RXDES0_LRS             (1 << 28)
 #define FTGMAC100_RXDES0_FRS             (1 << 29)
+#define FTGMAC100_RXDES0_EDORR_ASPEED    (1 << 30)
 #define FTGMAC100_RXDES0_RXPKT_RDY       (1 << 31)
 
 #define FTGMAC100_RXDES1_VLANTAG_CI      0xffff
@@ -462,7 +464,7 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t tx_ring,
         /* Write back the modified descriptor.  */
         ftgmac100_write_bd(&bd, addr);
         /* Advance to the next descriptor.  */
-        if (bd.des0 & FTGMAC100_TXDES0_EDOTR) {
+        if (bd.des0 & s->txdes0_edotr) {
             addr = tx_ring;
         } else {
             addr += sizeof(FTGMAC100Desc);
@@ -880,7 +882,7 @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,
             s->isr |= FTGMAC100_INT_RPKT_FIFO;
         }
         ftgmac100_write_bd(&bd, addr);
-        if (bd.des0 & FTGMAC100_RXDES0_EDORR) {
+        if (bd.des0 & s->rxdes0_edorr) {
             addr = s->rx_ring;
         } else {
             addr += sizeof(FTGMAC100Desc);
@@ -921,6 +923,14 @@ static void ftgmac100_realize(DeviceState *dev, Error **errp)
     FTGMAC100State *s = FTGMAC100(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
 
+    if (s->aspeed) {
+        s->txdes0_edotr = FTGMAC100_TXDES0_EDOTR_ASPEED;
+        s->rxdes0_edorr = FTGMAC100_RXDES0_EDORR_ASPEED;
+    } else {
+        s->txdes0_edotr = FTGMAC100_TXDES0_EDOTR;
+        s->rxdes0_edorr = FTGMAC100_RXDES0_EDORR;
+    }
+
     memory_region_init_io(&s->iomem, OBJECT(dev), &ftgmac100_ops, s,
                           TYPE_FTGMAC100, 0x2000);
     sysbus_init_mmio(sbd, &s->iomem);
@@ -967,11 +977,14 @@ static const VMStateDescription vmstate_ftgmac100 = {
         VMSTATE_UINT32(phy_advertise, FTGMAC100State),
         VMSTATE_UINT32(phy_int, FTGMAC100State),
         VMSTATE_UINT32(phy_int_mask, FTGMAC100State),
+        VMSTATE_UINT32(txdes0_edotr, FTGMAC100State),
+        VMSTATE_UINT32(rxdes0_edorr, FTGMAC100State),
         VMSTATE_END_OF_LIST()
     }
 };
 
 static Property ftgmac100_properties[] = {
+    DEFINE_PROP_BOOL("aspeed", FTGMAC100State, aspeed, false),
     DEFINE_NIC_PROPERTIES(FTGMAC100State, conf),
     DEFINE_PROP_END_OF_LIST(),
 };
include/hw/net/ftgmac100.h +4 -0
index 962a718f43b8..d9bc589fbf72 100644
@@ -55,6 +55,10 @@ typedef struct FTGMAC100State {
     uint32_t phy_advertise;
     uint32_t phy_int;
     uint32_t phy_int_mask;
+
+    bool aspeed;
+    uint32_t txdes0_edotr;
+    uint32_t rxdes0_edorr;
 } FTGMAC100State;
 
 #endif
Signature · 1 line
2.7.4
#4 lore raw

PATCH v3 4/5 aspeed: add a FTGMAC100 nic

In reply to Cédric Le Goater

There is a second NIC but we do not use it for the moment. We use the 'aspeed' property to tune the definition of the end of ring buffer bit for the Aspeed SoCs.

---
 hw/arm/aspeed_soc.c         | 21 +++++++++++++++++++++
 include/hw/arm/aspeed_soc.h |  2 ++
 2 files changed, 23 insertions(+)
hw/arm/aspeed_soc.c +21 -0
index 571e4f097b02..4937e2bc8323 100644
@@ -19,6 +19,7 @@
 #include "hw/char/serial.h"
 #include "qemu/log.h"
 #include "hw/i2c/aspeed_i2c.h"
+#include "net/net.h"
 
 #define ASPEED_SOC_UART_5_BASE      0x00184000
 #define ASPEED_SOC_IOMEM_SIZE       0x00200000
@@ -33,6 +34,8 @@
 #define ASPEED_SOC_TIMER_BASE       0x1E782000
 #define ASPEED_SOC_WDT_BASE         0x1E785000
 #define ASPEED_SOC_I2C_BASE         0x1E78A000
+#define ASPEED_SOC_ETH1_BASE        0x1E660000
+#define ASPEED_SOC_ETH2_BASE        0x1E680000
 
 static const int uart_irqs[] = { 9, 32, 33, 34, 10 };
 static const int timer_irqs[] = { 16, 17, 18, 35, 36, 37, 38, 39, };
@@ -175,6 +178,10 @@ static void aspeed_soc_init(Object *obj)
     object_initialize(&s->wdt, sizeof(s->wdt), TYPE_ASPEED_WDT);
     object_property_add_child(obj, "wdt", OBJECT(&s->wdt), NULL);
     qdev_set_parent_bus(DEVICE(&s->wdt), sysbus_get_default());
+
+    object_initialize(&s->ftgmac100, sizeof(s->ftgmac100), TYPE_FTGMAC100);
+    object_property_add_child(obj, "ftgmac100", OBJECT(&s->ftgmac100), NULL);
+    qdev_set_parent_bus(DEVICE(&s->ftgmac100), sysbus_get_default());
 }
 
 static void aspeed_soc_realize(DeviceState *dev, Error **errp)
@@ -299,6 +306,20 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt), 0, ASPEED_SOC_WDT_BASE);
+
+    /* Net */
+    qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]);
+    object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err);
+    object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized",
+                             &local_err);
+    error_propagate(&err, local_err);
+    if (err) {
+        error_propagate(errp, err);
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0,
+                       qdev_get_gpio_in(DEVICE(&s->vic), 2));
 }
 
 static void aspeed_soc_class_init(ObjectClass *oc, void *data)
include/hw/arm/aspeed_soc.h +2 -0
index dbec0c159885..4c5fc66a1ee0 100644
@@ -20,6 +20,7 @@
 #include "hw/i2c/aspeed_i2c.h"
 #include "hw/ssi/aspeed_smc.h"
 #include "hw/watchdog/wdt_aspeed.h"
+#include "hw/net/ftgmac100.h"
 
 #define ASPEED_SPIS_NUM  2
 
@@ -39,6 +40,7 @@ typedef struct AspeedSoCState {
     AspeedSMCState spi[ASPEED_SPIS_NUM];
     AspeedSDMCState sdmc;
     AspeedWDTState wdt;
+    FTGMAC100State ftgmac100;
 } AspeedSoCState;
 
 #define TYPE_ASPEED_SOC "aspeed-soc"
Signature · 1 line
2.7.4
#5 lore raw

PATCH v3 5/5 slirp: add a fake NC-SI backend

In reply to Cédric Le Goater

NC-SI (Network Controller Sideband Interface) enables a BMC to manage a set of NICs on a system. This model takes the simplest approach and reverses the NC-SI packets to pretend a NIC is present and exercise the Linux driver.

The NCSI header file <ncsi-pkt.h> comes from mainline Linux and was untabified.

---

Changes since v2:
- modified the 'ncsi-pkt.h' file to add its location under the Linux tree
- removed useless zeroing of the 'reserved' fields
- introduced a ncsi_rsp_handlers array to hold the payload size and a specific handler routine for each command
- fixed the output size of the frame to match the command payload size

 include/net/eth.h   |   1 +
 include/net/eth.h   |   1 +
 slirp/Makefile.objs |   2 +-
 slirp/ncsi-pkt.h    | 419 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 slirp/ncsi.c        | 130 ++++++++++++++++
 slirp/slirp.c       |   4 +
 slirp/slirp.h       |   3 +
 6 files changed, 558 insertions(+), 1 deletion(-)
 create mode 100644 slirp/ncsi-pkt.h
 create mode 100644 slirp/ncsi.c
include/net/eth.h +1 -0
index afeb45be34e1..09054a506d6e 100644
@@ -209,6 +209,7 @@ struct tcp_hdr {
 #define ETH_P_IPV6                (0x86dd)
 #define ETH_P_VLAN                (0x8100)
 #define ETH_P_DVLAN               (0x88a8)
+#define ETH_P_NCSI                (0x88f8)
 #define ETH_P_UNKNOWN             (0xffff)
 #define VLAN_VID_MASK             0x0fff
 #define IP_HEADER_VERSION_4       (4)
slirp/Makefile.objs +1 -1
index 1baa1f1c7cfb..28049b03cddc 100644
@@ -2,4 +2,4 @@ common-obj-y = cksum.o if.o ip_icmp.o ip6_icmp.o ip6_input.o ip6_output.o \
                ip_input.o ip_output.o dnssearch.o dhcpv6.o
 common-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o
 common-obj-y += tcp_subr.o tcp_timer.o udp.o udp6.o bootp.o tftp.o arp_table.o \
-                ndp_table.o
+                ndp_table.o ncsi.o
slirp/ncsi-pkt.h new file +419 -0

419 lines not on this page · raw message

slirp/ncsi.c new file +130 -0

130 lines not on this page · raw message

slirp/slirp.c +4 -0
index 5a94b06f5eb4..9a50918346b1 100644
@@ -870,6 +870,10 @@ void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
         }
         break;
 
+    case ETH_P_NCSI:
+        ncsi_input(slirp, pkt, pkt_len);
+        break;
+
     default:
         break;
     }
slirp/slirp.h +3 -0
index 3877f667f027..5af4f482b55f 100644
@@ -231,6 +231,9 @@ extern Slirp *slirp_instance;
 
 void if_start(Slirp *);
 
+/* ncsi.c */
+void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len);
+
 #ifndef _WIN32
 #include <netdb.h>
 #endif
Signature · 1 line
2.7.4
#6 lore raw
In reply to Cédric Le Goater
Quoted 87 lines · Cédric Le Goater

Hi,

The Aspeed SoCs AST2400 and AST2500 have two FTGMAC100 ethernet controllers. This series proposes a model for this device and a way to customize the bit definitions which are slightly different from the Faraday definitions.

The last patch adds a fake NC-SI (Network Controller Sideband Interface) backend to pretend a NIC is being managed. This is only usable with the slirp stack for the moment.

The model has been tested on the 'palmetto', 'romulus' and 'ast2500-evb' machines using different implementations of the Linux driver and with U-Boot. It has been stressed with iperf.

The full patchset is available here, based on QEMU v2.9.0-rc4 :

https://github.com/legoater/qemu/commits/aspeed

To test, grab a palmetto or a romulus BMC firmware image :

https://openpower.xyz/job/openbmc-build/distro=ubuntu,target=palmetto/lastSuccessfulBuild/artifact/images/palmetto/flash-palmetto
https://openpower.xyz/job/openbmc-build/distro=ubuntu,target=romulus/lastSuccessfulBuild/artifact/images/romulus/flash-romulus

and start the machines with :

qemu-system-arm -m 512 -M romulus-bmc -drive file=flash-romulus,format=raw,if=mtd -nographic qemu-system-arm -m 512 -M palmetto-bmc -drive file=flash-palmetto,format=raw,if=mtd -nographic

the fake NC-SI NIC should come up :

   ftgmac100 1e660000.ethernet eth0: NCSI interface up

and to log, use credentials root/0penBmc

Thanks,

C.

Changes since v2:
- rebased on QEMU v2.9.0-rc4
- modified the 'ncsi-pkt.h' file to add its location under the Linux tree
- removed useless zeroing of the 'reserved' fields
- introduced a ncsi_rsp_handlers array to hold the payload size and a specific handler routine for each command
- fixed the output size of the frame to match the command payload size

Changes since v1:
- removed TODO comments and used LOG_UNIMP in the read/write ops
- used camelcase for struct names and typedefs.
- removed the useless struct definitions for ring descriptors and the alignment pragma
- introduced a frame buffer at the machine level to reduce stack usage in the tx path.
- introduced symbolic constants for PHY values.
- introduced rtl8211e PHY chip specific registers
- removed qemu_set_irq() in reset path
- checked for dma_memory_read() errors. Also for write but that was less important as the descriptor is first read so it should be valid for the write.
- removed the irq state
- removed the weird hack to catch a first valid descriptor.
- fixed the read of the mac address

Cédric Le Goater (5):
hw/net: add MII definitions
net: add FTGMAC100 support
net/ftgmac100: add a 'aspeed' property
aspeed: add a FTGMAC100 nic
slirp: add a fake NC-SI backend

  default-configs/arm-softmmu.mak |    1 +
  hw/arm/aspeed_soc.c             |   21 +
  hw/net/Makefile.objs            |    1 +
  hw/net/ftgmac100.c              | 1016 +++++++++++++++++++++++++++++++++++++++
  include/hw/arm/aspeed_soc.h     |    2 +
  include/hw/net/ftgmac100.h      |   64 +++
  include/hw/net/mii.h            |   71 ++-
  include/net/eth.h               |    1 +
  slirp/Makefile.objs             |    2 +-
  slirp/ncsi-pkt.h                |  419 ++++++++++++++++
  slirp/ncsi.c                    |  130 +++++
  slirp/slirp.c                   |    4 +
  slirp/slirp.h                   |    3 +
  13 files changed, 1716 insertions(+), 19 deletions(-)
Quoted 5 lines

create mode 100644 hw/net/ftgmac100.c
create mode 100644 include/hw/net/ftgmac100.h
create mode 100644 slirp/ncsi-pkt.h
create mode 100644 slirp/ncsi.c

Queued for 2.10.

Thanks