Re: [Qemu-devel] [PATCH v8 1/6] Add xgmac ethernet model

2012-01-13 Thread Peter Maydell
On 11 January 2012 15:26, Mark Langsdorf mark.langsd...@calxeda.com wrote:
 This adds very basic support for XG-mac ethernet core from Synopsis and
 others.

 +typedef struct rxtx_stats {
 +    uint64_t rx_bytes;
 +    uint64_t tx_bytes;
 +
 +    uint64_t rx;
 +    uint64_t rx_bcast;
 +    uint64_t rx_mcast;
 +} rxtx_stats;

Anthony pointed out to me on IRC today the bit of CODING_STYLE that
mandates CamelCase for struct typedef names.

Sorry to bring up coding style issues at this point in the review
process, but can I get you to go through and camelcase the struct
typenames in this patch series?

thanks
-- PMM



[Qemu-devel] [PATCH v8 1/6] Add xgmac ethernet model

2012-01-11 Thread Mark Langsdorf
This adds very basic support for XG-mac ethernet core from Synopsis and
others. Missing things include:

- statistics counters
- WoL support
- rx checksum offload
- chained descriptors (only linear descriptor ring)
- broadcast and multicast handling

Signed-off-by: Rob Herring rob.herr...@calxeda.com
Signed-off-by: Mark Langsdorf mark.langsd...@calxeda.com
---
Changes from v7
None
Changes from v6
Skipped
Changes from v5
removed c_phyaddr
Changes from v4
None
Changes from v3
Added debug macro and cleaned up some debug code
Refitted all lines to fit within 80 columns
Changes from v2
None
Changes from v1
Reformated most lines to fit within 80 columns
Removed a bunch of unused variables in the state structures
Got rid of some camelcase structure names

 Makefile.target |1 +
 hw/xgmac.c  |  421 +++
 2 files changed, 422 insertions(+), 0 deletions(-)
 create mode 100644 hw/xgmac.c

diff --git a/Makefile.target b/Makefile.target
index 06d79b8..9bc0248 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -343,6 +343,7 @@ obj-arm-y += arm_l2x0.o
 obj-arm-y += arm_mptimer.o
 obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
 obj-arm-y += pl061.o
+obj-arm-y += xgmac.o
 obj-arm-y += arm-semi.o
 obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
 obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
diff --git a/hw/xgmac.c b/hw/xgmac.c
new file mode 100644
index 000..31594b5
--- /dev/null
+++ b/hw/xgmac.c
@@ -0,0 +1,421 @@
+/*
+ * QEMU model of XGMAC Ethernet.
+ *
+ * derived from the Xilinx AXI-Ethernet by Edgar E. Iglesias.
+ *
+ * Copyright (c) 2011 Calxeda, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include sysbus.h
+#include qemu-char.h
+#include qemu-log.h
+#include net.h
+#include net/checksum.h
+
+#ifdef DEBUG_XGMAC
+#define DEBUGF_BRK(message, args...) do { \
+ fprintf(stderr, (message), ## args); \
+ } while (0)
+#else
+#define DEBUGF_BRK(message, args...) do { } while (0)
+#endif
+
+#define XGMAC_CONTROL   0x   /* MAC Configuration */
+#define XGMAC_FRAME_FILTER  0x0001   /* MAC Frame Filter */
+#define XGMAC_FLOW_CTRL 0x0006   /* MAC Flow Control */
+#define XGMAC_VLAN_TAG  0x0007   /* VLAN Tags */
+#define XGMAC_VERSION   0x0008   /* Version */
+/* VLAN tag for insertion or replacement into tx frames */
+#define XGMAC_VLAN_INCL 0x0009
+#define XGMAC_LPI_CTRL  0x000a   /* LPI Control and Status */
+#define XGMAC_LPI_TIMER 0x000b   /* LPI Timers Control */
+#define XGMAC_TX_PACE   0x000c   /* Transmit Pace and Stretch */
+#define XGMAC_VLAN_HASH 0x000d   /* VLAN Hash Table */
+#define XGMAC_DEBUG 0x000e   /* Debug */
+#define XGMAC_INT_STATUS0x000f   /* Interrupt and Control */
+/* HASH table registers */
+#define XGMAC_HASH(n)   ((0x0300/4) + (n))
+#define XGMAC_NUM_HASH  16
+/* Operation Mode */
+#define XGMAC_OPMODE(0x0400/4)
+/* Remote Wake-Up Frame Filter */
+#define XGMAC_REMOTE_WAKE   (0x0700/4)
+/* PMT Control and Status */
+#define XGMAC_PMT   (0x0704/4)
+
+#define XGMAC_ADDR_HIGH(reg)(0x0010+((reg) * 2))
+#define XGMAC_ADDR_LOW(reg) (0x0011+((reg) * 2))
+
+#define DMA_BUS_MODE0x03c0   /* Bus Mode */
+#define DMA_XMT_POLL_DEMAND 0x03c1   /* Transmit Poll Demand */
+#define DMA_RCV_POLL_DEMAND 0x03c2   /* Received Poll Demand */
+#define DMA_RCV_BASE_ADDR   0x03c3   /* Receive List Base */
+#define DMA_TX_BASE_ADDR0x03c4   /* Transmit List Base */
+#define DMA_STATUS  0x03c5   /* Status 

Re: [Qemu-devel] [PATCH v8 1/6] Add xgmac ethernet model

2012-01-11 Thread Peter Maydell
On 11 January 2012 15:26, Mark Langsdorf mark.langsd...@calxeda.com wrote:
 This adds very basic support for XG-mac ethernet core from Synopsis and
 others. Missing things include:

 - statistics counters
 - WoL support
 - rx checksum offload
 - chained descriptors (only linear descriptor ring)
 - broadcast and multicast handling

 Signed-off-by: Rob Herring rob.herr...@calxeda.com
 Signed-off-by: Mark Langsdorf mark.langsd...@calxeda.com

Reviewed-by: Peter Maydell peter.mayd...@linaro.org