aspeed queue
The following changes since commit 44b7329de469c121555a1acf9b288f3ae71b8e61:
Merge tag 'pull-qapi-2024-07-06' of https://repo.or.cz/qemu/armbru into staging (2024-07-07 13:23:28 -0700)
are available in the Git repository at:
https://github.com/legoater/qemu/ tags/pull-aspeed-20240709
for you to fetch changes up to d847ea7cfc6321e2519f587d4077428d90557178:
machine_aspeed.py: update to test network for AST2700 (2024-07-09 08:05:44 +0200)
----------------------------------------------------------------
aspeed queue:
* support AST2700 network
----------------------------------------------------------------
Jamin Lin (8):
hw/net:ftgmac100: update memory region size to 64KB
hw/net:ftgmac100: update ring base address to 64 bits
hw/net:ftgmac100: introduce TX and RX ring base address high registers to support 64 bits hw/net:ftgmac100: update TX and RX packet buffers address to 64 bits aspeed/soc: set dma64 property for AST2700 ftgmac100
hw/block: m25p80: support quad mode for w25q01jvq
machine_aspeed.py: update to test ASPEED OpenBMC SDK v09.02 for AST2700 machine_aspeed.py: update to test network for AST2700
include/hw/net/ftgmac100.h | 17 +++-- hw/arm/aspeed_ast27x0.c | 3 + hw/block/m25p80.c | 16 +++++ hw/net/ftgmac100.c | 147 +++++++++++++++++++++++++++++++++------- tests/avocado/machine_aspeed.py | 12 ++-- 5 files changed, 162 insertions(+), 33 deletions(-)
[PULL 1/8] hw/net:ftgmac100: update memory region size to 64KB
From: Jamin Lin <[email protected]>
According to the datasheet of ASPEED SOCs,
one MAC controller owns 128KB of register space for AST2500. However, one MAC controller only owns 64KB of register space for AST2600 and AST2700. It set the memory region size 128KB and it occupied another controllers Address Spaces.
Update one MAC controller memory region size to 0x1000 because AST2500 did not use register spaces over than 64KB.
Introduce a new container region size to 0x1000 and its range is from 0 to 0xfff. This container is mapped a sub region for the current set of register.
This sub region range is from 0 to 0xff.
--- include/hw/net/ftgmac100.h | 4 ++++ hw/net/ftgmac100.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
include/hw/net/ftgmac100.h +4 -0
@@ -14,6 +14,9 @@#define TYPE_FTGMAC100 "ftgmac100" OBJECT_DECLARE_SIMPLE_TYPE(FTGMAC100State, FTGMAC100) +#define FTGMAC100_MEM_SIZE 0x1000 +#define FTGMAC100_REG_MEM_SIZE 0x100 +#include "hw/sysbus.h" #include "net/net.h"
@@ -30,6 +33,7 @@ struct FTGMAC100State {NICState *nic;NICConf conf;qemu_irq irq; +MemoryRegion iomem_container;MemoryRegion iomem;uint8_t frame[FTGMAC100_MAX_FRAME_SIZE ];
hw/net/ftgmac100.c +8 -3
@@ -1107,9 +1107,14 @@ static void ftgmac100_realize(DeviceState *dev, Error **errp) 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); +memory_region_init (&s->iomem_container,OBJECT (s), +TYPE_FTGMAC100 ".container" ,FTGMAC100_MEM_SIZE ); +sysbus_init_mmio (sbd, &s->iomem_container); + +memory_region_init_io (&s->iomem,OBJECT (s), &ftgmac100_ops, s, +TYPE_FTGMAC100 ".regs" ,FTGMAC100_REG_MEM_SIZE ); +memory_region_add_subregion (&s->iomem_container,0x0 , &s->iomem); +sysbus_init_irq (sbd, &s->irq);qemu_macaddr_default_if_unset (&s->conf.macaddr);
Signature · 1 line
2.45.2
[PULL 2/8] hw/net:ftgmac100: update ring base address to 64 bits
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
Update TX and RX ring base address data type to uint64_t for 64 bits dram address DMA support.
Both "Normal Priority Transmit Ring Base Address Register(0x20)" and "Receive Ring Base Address Register (0x24)" are used for saving the low part physical address of descriptor manager.
Therefore, changes to set TX and RX descriptor manager address bits [31:0] in ftgmac100_read and ftgmac100_write functions.
Incrementing the version of vmstate to 2.
--- include/hw/net/ftgmac100.h | 9 ++++----- hw/net/ftgmac100.c | 33 ++++++++++++++++----------------- 2 files changed, 20 insertions(+), 22 deletions(-)
include/hw/net/ftgmac100.h +4 -5
@@ -42,10 +42,6 @@ struct FTGMAC100State {uint32_t isr;uint32_t ier;uint32_t rx_enabled; -uint32_t rx_ring; -uint32_t rx_descriptor; -uint32_t tx_ring; -uint32_t tx_descriptor;uint32_t math[2 ];uint32_t rbsr;uint32_t itc;
@@ -58,7 +54,10 @@ struct FTGMAC100State {uint32_t phycr;uint32_t phydata;uint32_t fcr; - +uint64_t rx_ring; +uint64_t rx_descriptor; +uint64_t tx_ring; +uint64_t tx_descriptor;uint32_t phy_status;uint32_t phy_control;
hw/net/ftgmac100.c +16 -17
@@ -515,12 +515,12 @@ out:return frame_size; } -static void ftgmac100_do_tx (FTGMAC100State *s,uint32_t tx_ring, -uint32_t tx_descriptor) +static void ftgmac100_do_tx (FTGMAC100State *s,uint64_t tx_ring, +uint64_t tx_descriptor) {int frame_size =0 ;uint8_t *ptr = s->frame; -uint32_t addr = tx_descriptor; +uint64_t addr = tx_descriptor;uint32_t flags =0 ;while (1 ) {
@@ -726,9 +726,9 @@ static uint64_t ftgmac100_read(void *opaque, hwaddr addr, unsigned size)case FTGMAC100_MATH1 :return s->math[1 ];case FTGMAC100_RXR_BADR : -return s->rx_ring; +return extract64 (s->rx_ring,0 ,32 );case FTGMAC100_NPTXR_BADR : -return s->tx_ring; +return extract64 (s->tx_ring,0 ,32 );case FTGMAC100_ITC :return s->itc;case FTGMAC100_DBLAC :
@@ -799,9 +799,8 @@ static void ftgmac100_write(void *opaque, hwaddr addr, HWADDR_PRIx "\n", __func__, value);return ; } - - s->rx_ring = value; - s->rx_descriptor = s->rx_ring; + s->rx_ring =deposit64 (s->rx_ring,0 ,32 , value); + s->rx_descriptor =deposit64 (s->rx_descriptor,0 ,32 , value);break ;case FTGMAC100_RBSR :/* DMA buffer size */
@@ -814,8 +813,8 @@ static void ftgmac100_write(void *opaque, hwaddr addr, HWADDR_PRIx "\n", __func__, value);return ; } - s->tx_ring = value; - s->tx_descriptor = s->tx_ring; + s->tx_ring =deposit64 (s->tx_ring,0 ,32 , value); + s->tx_descriptor =deposit64 (s->tx_descriptor,0 ,32 , value);break ;case FTGMAC100_NPTXPD :/* Trigger transmit */
@@ -957,7 +956,7 @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,FTGMAC100State *s =FTGMAC100 (qemu_get_nic_opaque (nc));FTGMAC100Desc bd;uint32_t flags =0 ; -uint32_t addr; +uint64_t addr;uint32_t crc;uint32_t buf_addr;uint8_t *crc_ptr;
@@ -1126,18 +1125,14 @@ static void ftgmac100_realize(DeviceState *dev, Error **errp)static const VMStateDescription vmstate_ftgmac100 = { .name =TYPE_FTGMAC100 , - .version_id =1 , - .minimum_version_id =1 , + .version_id =2 , + .minimum_version_id =2 , .fields = (const VMStateField []) {VMSTATE_UINT32 (irq_state, FTGMAC100State),VMSTATE_UINT32 (isr, FTGMAC100State),VMSTATE_UINT32 (ier, FTGMAC100State),VMSTATE_UINT32 (rx_enabled, FTGMAC100State), -VMSTATE_UINT32 (rx_ring, FTGMAC100State),VMSTATE_UINT32 (rbsr, FTGMAC100State), -VMSTATE_UINT32 (tx_ring, FTGMAC100State), -VMSTATE_UINT32 (rx_descriptor, FTGMAC100State), -VMSTATE_UINT32 (tx_descriptor, FTGMAC100State),VMSTATE_UINT32_ARRAY (math, FTGMAC100State,2 ),VMSTATE_UINT32 (itc, FTGMAC100State),VMSTATE_UINT32 (aptcr, FTGMAC100State),
@@ -1156,6 +1151,10 @@ static const VMStateDescription vmstate_ftgmac100 = {VMSTATE_UINT32 (phy_int_mask, FTGMAC100State),VMSTATE_UINT32 (txdes0_edotr, FTGMAC100State),VMSTATE_UINT32 (rxdes0_edorr, FTGMAC100State), +VMSTATE_UINT64 (rx_ring, FTGMAC100State), +VMSTATE_UINT64 (tx_ring, FTGMAC100State), +VMSTATE_UINT64 (rx_descriptor, FTGMAC100State), +VMSTATE_UINT64 (tx_descriptor, FTGMAC100State), VMSTATE_END_OF_LIST() } };
Signature · 1 line
2.45.2
[PULL 8/8] machine_aspeed.py: update to test network for AST2700
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
Update test case to test network connection via SSH.
Test command:
``` cd build pyvenv/bin/avocado run ../qemu/tests/avocado/machine_aspeed.py:AST2x00MachineSDK.test_aarch64_ast2700_evb_sdk_v09_02 ```
--- tests/avocado/machine_aspeed.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tests/avocado/machine_aspeed.py +4 -2
@@ -313,14 +313,14 @@ def do_test_arm_aspeed_sdk_start(self, image): def do_test_aarch64_aspeed_sdk_start(self, image): self.vm.set_console() - self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw') + self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', + '-net', 'nic', '-net', 'user,hostfwd=:127.0.0.1:0-:22') self.vm.launch() self.wait_for_console_pattern('U-Boot 2023.10') self.wait_for_console_pattern('## Loading kernel from FIT Image') self.wait_for_console_pattern('Starting kernel ...') - self.wait_for_console_pattern("systemd[1]: Hostname set to") @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab')
@@ -436,4 +436,6 @@ def test_aarch64_ast2700_evb_sdk_v09_02(self): self.vm.add_args('-smp', str(num_cpu)) self.do_test_aarch64_aspeed_sdk_start(image_dir + 'image-bmc') + self.wait_for_console_pattern('nodistro.0 ast2700-default ttyS12') + self.ssh_connect('root', '0penBmc', False)
Signature · 1 line
2.45.2
[PULL 6/8] hw/block: m25p80: support quad mode for w25q01jvq
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
According to the w25q01jv datasheet at page 16,
it is required to set QE bit in "Status Register 2". Besides, users are able to utilize "Write Status Register 1(0x01)" command to set QE bit in "Status Register 2" and
utilize "Read Status Register 2(0x35)" command to get the QE bit status.
To support quad mode for w25q01jvq, update collecting data needed 2 bytes for WRSR command in decode_new_cmd function and verify QE bit at the second byte of collecting data bit 2 in complete_collecting_data.
Update RDCR_EQIO command to set bit 2 of return data if quad mode enable in decode_new_cmd.
--- hw/block/m25p80.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
hw/block/m25p80.c +16 -0
@@ -416,6 +416,7 @@ typedef enum {/* * Micron: 0x35 - enable QPI * Spansion: 0x35 - read control register +* Winbond: 0x35 - quad enable */ RDCR_EQIO =0x35 , RSTQIO = 0xf5,
@@ -798,6 +799,11 @@ static void complete_collecting_data(Flash *s) s->four_bytes_address_mode =extract32 (s->data[1 ],5 ,1 ); }break ; +case MAN_WINBOND : +if (s->len >1 ) { + s->quad_enable = !!(s->data[1 ] &0x02 ); + } +break ;default :break ; }
@@ -1254,6 +1260,10 @@ static void decode_new_cmd(Flash *s, uint32_t value) s->needed_bytes =2 ; s->state =STATE_COLLECTING_VAR_LEN_DATA ;break ; +case MAN_WINBOND : + s->needed_bytes =2 ; + s->state =STATE_COLLECTING_VAR_LEN_DATA ; +break ;default : s->needed_bytes =1 ; s->state =STATE_COLLECTING_DATA ;
@@ -1431,6 +1441,12 @@ static void decode_new_cmd(Flash *s, uint32_t value)case MAN_MACRONIX : s->quad_enable = true;break ; +case MAN_WINBOND : + s->data[0 ] = (!!s->quad_enable) <<1 ; + s->pos =0 ; + s->len =1 ; + s->state =STATE_READING_DATA ; +break ;default :break ; }
Signature · 1 line
2.45.2
[PULL 7/8] machine_aspeed.py: update to test ASPEED OpenBMC SDK v09.02 for AST2700
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
Update test case to test ASPEED OpenBMC SDK v09.02 for AST2700.
ASPEED fixed TX mask issue from linux/drivers/ftgmac100.c. It is required to use ASPEED OpenBMC SDK since v09.02 for AST2700 QEMU network testing.
A test image is downloaded from the ASPEED Forked OpenBMC GitHub release repository :
https://github.com/AspeedTech-BMC/openbmc/releases/
--- tests/avocado/machine_aspeed.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/avocado/machine_aspeed.py +3 -3
@@ -387,15 +387,15 @@ def test_arm_ast2600_evb_sdk(self): year = time.strftime("%Y") self.ssh_command_output_contains('/sbin/hwclock -f /dev/rtc1', year); - def test_aarch64_ast2700_evb_sdk_v09_01(self): + def test_aarch64_ast2700_evb_sdk_v09_02(self): """ :avocado: tags=arch:aarch64 :avocado: tags=machine:ast2700-evb """ image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/' - 'download/v09.01/ast2700-default-obmc.tar.gz') - image_hash = 'b1cc0fd73c7650d34c9c8459a243f52a91e9e27144b8608b2645ab19461d1e07' + 'download/v09.02/ast2700-default-obmc.tar.gz') + image_hash = 'ac969c2602f4e6bdb69562ff466b89ae3fe1d86e1f6797bb7969d787f82116a7' image_path = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256') archive.extract(image_path, self.workdir)
Signature · 1 line
2.45.2
[PULL 4/8] hw/net:ftgmac100: update TX and RX packet buffers address to 64 bits
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
ASPEED AST2700 SOC is a 64 bits quad core CPUs (Cortex-a35) And the base address of dram is "0x4 00000000" which is 64bits address.
It have "TXDES 2" and "RXDES 2" to save the high part physical address of packet buffer.
Ex: TX packet buffer address [34:0]
The "TXDES 2" bits [18:16] which corresponds the bits [34:32] of the 64 bits address of the TX packet buffer address and "TXDES 3" bits [31:0] which corresponds the bits [31:0] of the 64 bits address of the TX packet buffer address.
Update TX and RX packet buffers address type to
64 bits for dram 64 bits address DMA support.
--- hw/net/ftgmac100.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
hw/net/ftgmac100.c +18 -3
@@ -175,6 +175,8 @@#define FTGMAC100_TXDES1_TX2FIC (1 << 30)#define FTGMAC100_TXDES1_TXIC (1 << 31) +#define FTGMAC100_TXDES2_TXBUF_BADR_HI (x) (((x) >> 16) & 0x7) +/* * Receive descriptor */
@@ -208,13 +210,15 @@#define FTGMAC100_RXDES1_UDP_CHKSUM_ERR (1 << 26)#define FTGMAC100_RXDES1_IP_CHKSUM_ERR (1 << 27) +#define FTGMAC100_RXDES2_RXBUF_BADR_HI (x) (((x) >> 16) & 0x7) +/* * Receive and transmit Buffer Descriptor */ typedef struct {uint32_t des0;uint32_t des1; -uint32_t des2;/* not used by HW */ +uint32_t des2;/* used by HW 64 bits DMA */ uint32_t des3; }FTGMAC100Desc ;
@@ -531,6 +535,7 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint64_t tx_ring,int frame_size =0 ;uint8_t *ptr = s->frame;uint64_t addr = tx_descriptor; +uint64_t buf_addr =0 ;uint32_t flags =0 ;while (1 ) {
@@ -569,7 +574,12 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint64_t tx_ring, len =sizeof (s->frame) - frame_size; } -if (dma_memory_read (&address_space_memory, bd.des3, + buf_addr = bd.des3; +if (s->dma64) { + buf_addr =deposit64 (buf_addr,32 ,32 , +FTGMAC100_TXDES2_TXBUF_BADR_HI (bd.des2)); + } +if (dma_memory_read (&address_space_memory, buf_addr, ptr, len,MEMTXATTRS_UNSPECIFIED )) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: failed to read packet @ 0x%x\n" , __func__, bd.des3);
@@ -1022,7 +1032,7 @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,uint32_t flags =0 ;uint64_t addr;uint32_t crc; -uint32_t buf_addr; +uint64_t buf_addr =0 ;uint8_t *crc_ptr;uint32_t buf_len;size_t size = len;
@@ -1087,7 +1097,12 @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,if (size <4 ) { buf_len += size -4 ; } + buf_addr = bd.des3; +if (s->dma64) { + buf_addr =deposit64 (buf_addr,32 ,32 , +FTGMAC100_RXDES2_RXBUF_BADR_HI (bd.des2)); + }if (first && proto ==ETH_P_VLAN && buf_len >=18 ) { bd.des1 =lduw_be_p (buf +14 ) |FTGMAC100_RXDES1_VLANTAG_AVAIL ;
Signature · 1 line
2.45.2
[PULL 5/8] aspeed/soc: set dma64 property for AST2700 ftgmac100
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
ASPEED AST2700 SOC is a 64 bits quad core CPUs (Cortex-a35) And the base address of dram is "0x4 00000000" which is 64bits address.
Set dma64 property for ftgmac100 model to support 64bits dram address DMA.
--- hw/arm/aspeed_ast27x0.c | 3 +++ 1 file changed, 3 insertions(+)
hw/arm/aspeed_ast27x0.c +3 -0
@@ -552,9 +552,12 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)return ; } +/* Net */ for (i =0 ; i < sc->macs_num; i++) {object_property_set_bool (OBJECT (&s->ftgmac100[i]),"aspeed" , true, &error_abort); +object_property_set_bool (OBJECT (&s->ftgmac100[i]),"dma64" , true, + &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->ftgmac100[i]), errp)) {return ; }
Signature · 1 line
2.45.2
[PULL 3/8] hw/net:ftgmac100: introduce TX and RX ring base address high registers to support 64 bits
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
ASPEED AST2700 SOC is a 64 bits quad core CPUs (Cortex-a35) And the base address of dram is "0x4 00000000" which is 64bits address.
It have "Normal Priority Transmit Ring Base Address Register High(0x17C)", "High Priority Transmit Ring Base Address Register High(0x184)" and "Receive Ring Base Address Register High(0x18C)" to save the high part physical address of descriptor manager.
Ex: TX descriptor manager address [34:0]
The "Normal Priority Transmit Ring Base Address Register High(0x17C)" bits [2:0] which corresponds the bits [34:32] of the 64 bits address of the TX ring buffer address.
The "Normal Priority Transmit Ring Base Address Register(0x20)" bits [31:0] which corresponds the bits [31:0] of the 64 bits address
of the TX ring buffer address.
Introduce a new sub region which size is 0x100 for the set of new registers and map it at 0x100 in the container region.
This sub region range is from 0x100 to 0x1ff.
Introduce a new property and object attribute to activate the region for new registers. Introduce a new memop handlers for the new register read and write.
--- include/hw/net/ftgmac100.h | 4 ++ hw/net/ftgmac100.c | 82 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+)
include/hw/net/ftgmac100.h +4 -0
@@ -16,6 +16,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(FTGMAC100State, FTGMAC100)#define FTGMAC100_MEM_SIZE 0x1000#define FTGMAC100_REG_MEM_SIZE 0x100 +#define FTGMAC100_REG_HIGH_MEM_SIZE 0x100 +#define FTGMAC100_REG_HIGH_OFFSET 0x100#include "hw/sysbus.h" #include "net/net.h"
@@ -35,6 +37,7 @@ struct FTGMAC100State {qemu_irq irq;MemoryRegion iomem_container;MemoryRegion iomem; +MemoryRegion iomem_high;uint8_t frame[FTGMAC100_MAX_FRAME_SIZE ];
@@ -68,6 +71,7 @@ struct FTGMAC100State {bool aspeed;uint32_t txdes0_edotr;uint32_t rxdes0_edorr; +bool dma64; };#define TYPE_ASPEED_MII "aspeed-mmi"
hw/net/ftgmac100.c +82 -0
112 lines not on this page · raw message
Signature · 1 line
2.45.2
Richard Henderson
AppliedQuoted 8 lines · Cédric Le Goater
The following changes since commit
44b7329de469c121555a1acf9b288f3ae71b8e61:Merge tag 'pull-qapi-2024-07-06' ofhttps://repo.or.cz/qemu/armbru into staging (2024-07-07 13:23:28 -0700)are available in the Git repository at:
https://github.com/legoater/qemu/ tags/pull-aspeed-20240709
Quoted 8 lines
for you to fetch changes up to
d847ea7cfc6321e2519f587d4077428d90557178:machine_aspeed.py: update to test network for AST2700 (2024-07-09 08:05:44 +0200)----------------------------------------------------------------
aspeed queue:* support AST2700 network
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/9.1 as appropriate.
r~