From patchwork Fri Apr 24 20:28:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 464410 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8DF3C1402DE for ; Sat, 25 Apr 2015 06:34:04 +1000 (AEST) Received: from localhost ([::1]:46412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlkIU-0007A4-J7 for incoming@patchwork.ozlabs.org; Fri, 24 Apr 2015 16:34:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlkDW-0006e0-JR for qemu-devel@nongnu.org; Fri, 24 Apr 2015 16:28:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YlkDR-0004YX-Id for qemu-devel@nongnu.org; Fri, 24 Apr 2015 16:28:54 -0400 Received: from mail-bn1bon0067.outbound.protection.outlook.com ([157.56.111.67]:49159 helo=na01-bn1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlkDR-0004XZ-DZ for qemu-devel@nongnu.org; Fri, 24 Apr 2015 16:28:49 -0400 Received: from BL2FFO11FD045.protection.gbl (10.173.160.34) by BL2FFO11HUB009.protection.gbl (10.173.161.111) with Microsoft SMTP Server (TLS) id 15.1.154.14; Fri, 24 Apr 2015 20:28:48 +0000 Authentication-Results: spf=fail (sender IP is 149.199.60.96) smtp.mailfrom=xilinx.com; gmail.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of xilinx.com does not designate 149.199.60.96 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.96; helo=xsj-tvapsmtpgw01; Received: from xsj-tvapsmtpgw01 (149.199.60.96) by BL2FFO11FD045.mail.protection.outlook.com (10.173.161.207) with Microsoft SMTP Server (TLS) id 15.1.154.14 via Frontend Transport; Fri, 24 Apr 2015 20:28:47 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:52979 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1Ylk8f-0001nm-UD; Fri, 24 Apr 2015 13:23:53 -0700 Received: from [127.0.0.1] (port=34599 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1YlkDO-0002Je-So; Fri, 24 Apr 2015 13:28:46 -0700 Received: from xsj-tvapsmtp02 (xsj-tvapsmtp02.xilinx.com [172.16.1.203]) by tsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id t3OKOhIX015657; Fri, 24 Apr 2015 13:24:43 -0700 Received: from [172.19.74.49] (port=38351 helo=xsjsorenbubuntu.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1YlkDN-0002JP-Hr; Fri, 24 Apr 2015 13:28:45 -0700 From: Peter Crosthwaite To: Date: Fri, 24 Apr 2015 13:28:45 -0700 Message-ID: X-Mailer: git-send-email 2.3.6.3.g2cc70ee In-Reply-To: References: X-RCIS-Action: ALLOW X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-7.5.0.1018-21500.005 X-TM-AS-Result: No--1.910-7.0-31-10 X-imss-scan-details: No--1.910-7.0-31-10 X-TMASE-MatchedRID: GSbFsiI/QlTj3O4G38MrjQNJ3EDwuUClXs5nqGvDCfN+YesuCgkiXFjY c2qXbCu1E/inge20YcFBBPlf51IMVeNl6Cpfbsn2VnQT6gDml1W+1Vx7rDn4r5/paSZmLhGjNuY EC38PioG2XO6LyR+n36AY5nebYtjnXsXCkRP5gegCg1rav4R3DZnaxzJFBx6v61a6N6nKnfOBAV U596mb9vuBAQFQ9xUB8LtItXUH11YoZZgCxeSxyL2xWbKjBfWP5YswxsjURa5R8uWm1euoCTK2i eu8M5yxf227lWDvLKvFLqTgoGRsKzBTj9KDVuZ7S8S2F9lkvO+E6lq+K7jthyF4YnLQT6Kr+lmN ZCKoGWEbewkoHF7w8SgCdpiHl8ufHodpx3o6GrswiJTf3kjwfcC5Zx1NKJANStZtgyGdXLNLQFz PUld8mYPpGT9EK5RDjX0T1/ZvXm2sONf85gU4NCVypP66BP0QXru95hSuhjSdI/DikZ1UPAIrb2 7BZoHyPhDitbkdGIKAMuqetGVetnyef22ep6XYro1URZJFbJuLl8w/5aQodnQWL7B6HvqrLUPQQ jvbzzLnXaP1MariDBMoPaTy0p5M1B7wHEKMfe1uSF9Tjv3mZoIbUs+iESS9sI1q8rr2z+7+v9v5 2ZIoWjoAf389xF3XFSk9HhUZnw7OGIWnws4Lo/Wdclq8lU1q X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.96; CTRY:US; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10009020)(6009001)(339900001)(189002)(199003)(118296001)(229853001)(110136001)(77096005)(64026002)(50466002)(33646002)(2950100001)(77156002)(36756003)(2351001)(50226001)(105606002)(92566002)(46102003)(62966003)(106466001)(47776003)(71366001)(76176999)(86362001)(87936001)(85426001)(6806004)(19580395003)(19580405001)(50986999)(48376002)(107986001)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2FFO11HUB009; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2FFO11HUB009; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002010)(5005006)(3002001); SRVR:BL2FFO11HUB009; BCL:0; PCL:0; RULEID:; SRVR:BL2FFO11HUB009; X-Forefront-PRVS: 05568D1FF7 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2015 20:28:47.9122 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.96]; Helo=[xsj-tvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2FFO11HUB009 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 157.56.111.67 Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, zach.pfeffer@xilinx.com, jues@xilinx.com, ozaki.ryota@gmail.com, alistair.francis@xilinx.com, michals@xilinx.com Subject: [Qemu-devel] [PATCH target-arm v6 07/14] net: cadence_gem: Split state struct and type into header X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Create a new header for Cadence GEM to allow using the device with modern SoC programming conventions. The state struct needs to be visible to embed the device in SoC containers. Reviewed-by: Alistair Francis Reviewed-by: Peter Maydell Tested-by: Alistair Francis Signed-off-by: Peter Crosthwaite Reviewed-by: Edgar E. Iglesias --- changed since v4: Added (c) information Make commit msg body self contained changed since v1: Fix /* Public */ comment spacing (Alistair review) hw/net/cadence_gem.c | 43 +------------------------- include/hw/net/cadence_gem.h | 73 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 42 deletions(-) create mode 100644 include/hw/net/cadence_gem.h diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index 5994306..dafe914 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -24,8 +24,7 @@ #include /* For crc32 */ -#include "hw/sysbus.h" -#include "net/net.h" +#include "hw/net/cadence_gem.h" #include "net/checksum.h" #ifdef CADENCE_GEM_ERR_DEBUG @@ -141,8 +140,6 @@ #define GEM_DESCONF6 (0x00000294/4) #define GEM_DESCONF7 (0x00000298/4) -#define CADENCE_GEM_MAXREG (0x00000640/4) /* Last valid GEM address */ - /*****************************************/ #define GEM_NWCTRL_TXSTART 0x00000200 /* Transmit Enable */ #define GEM_NWCTRL_TXENA 0x00000008 /* Transmit Enable */ @@ -349,44 +346,6 @@ static inline void rx_desc_set_sar(unsigned *desc, int sar_idx) desc[1] |= R_DESC_1_RX_SAR_MATCH; } -#define TYPE_CADENCE_GEM "cadence_gem" -#define CADENCE_GEM(obj) OBJECT_CHECK(CadenceGEMState, (obj), TYPE_CADENCE_GEM) - -typedef struct CadenceGEMState { - SysBusDevice parent_obj; - - MemoryRegion iomem; - NICState *nic; - NICConf conf; - qemu_irq irq; - - /* GEM registers backing store */ - uint32_t regs[CADENCE_GEM_MAXREG]; - /* Mask of register bits which are write only */ - uint32_t regs_wo[CADENCE_GEM_MAXREG]; - /* Mask of register bits which are read only */ - uint32_t regs_ro[CADENCE_GEM_MAXREG]; - /* Mask of register bits which are clear on read */ - uint32_t regs_rtc[CADENCE_GEM_MAXREG]; - /* Mask of register bits which are write 1 to clear */ - uint32_t regs_w1c[CADENCE_GEM_MAXREG]; - - /* PHY registers backing store */ - uint16_t phy_regs[32]; - - uint8_t phy_loop; /* Are we in phy loopback? */ - - /* The current DMA descriptor pointers */ - uint32_t rx_desc_addr; - uint32_t tx_desc_addr; - - uint8_t can_rx_state; /* Debug only */ - - unsigned rx_desc[2]; - - bool sar_active[4]; -} CadenceGEMState; - /* The broadcast MAC address: 0xFFFFFFFFFFFF */ static const uint8_t broadcast_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; diff --git a/include/hw/net/cadence_gem.h b/include/hw/net/cadence_gem.h new file mode 100644 index 0000000..f2e08e3 --- /dev/null +++ b/include/hw/net/cadence_gem.h @@ -0,0 +1,73 @@ +/* + * QEMU Cadence GEM emulation + * + * Copyright (c) 2011 Xilinx, 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. + */ + +#ifndef CADENCE_GEM_H + +#define TYPE_CADENCE_GEM "cadence_gem" +#define CADENCE_GEM(obj) OBJECT_CHECK(CadenceGEMState, (obj), TYPE_CADENCE_GEM) + +#include "net/net.h" +#include "hw/sysbus.h" + +#define CADENCE_GEM_MAXREG (0x00000640/4) /* Last valid GEM address */ + +typedef struct CadenceGEMState { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + MemoryRegion iomem; + NICState *nic; + NICConf conf; + qemu_irq irq; + + /* GEM registers backing store */ + uint32_t regs[CADENCE_GEM_MAXREG]; + /* Mask of register bits which are write only */ + uint32_t regs_wo[CADENCE_GEM_MAXREG]; + /* Mask of register bits which are read only */ + uint32_t regs_ro[CADENCE_GEM_MAXREG]; + /* Mask of register bits which are clear on read */ + uint32_t regs_rtc[CADENCE_GEM_MAXREG]; + /* Mask of register bits which are write 1 to clear */ + uint32_t regs_w1c[CADENCE_GEM_MAXREG]; + + /* PHY registers backing store */ + uint16_t phy_regs[32]; + + uint8_t phy_loop; /* Are we in phy loopback? */ + + /* The current DMA descriptor pointers */ + uint32_t rx_desc_addr; + uint32_t tx_desc_addr; + + uint8_t can_rx_state; /* Debug only */ + + unsigned rx_desc[2]; + + bool sar_active[4]; +} CadenceGEMState; + +#define CADENCE_GEM_H +#endif