From patchwork Fri May 8 11:00:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Pavan Boddu X-Patchwork-Id: 11536329 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D1A92159A for ; Fri, 8 May 2020 11:09:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A88F1208CA for ; Fri, 8 May 2020 11:09:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="Zo6LaDud" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A88F1208CA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX0tC-00016q-SE for patchwork-qemu-devel@patchwork.kernel.org; Fri, 08 May 2020 07:09:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX0s9-0007Yx-HZ; Fri, 08 May 2020 07:08:53 -0400 Received: from mail-dm6nam10on2051.outbound.protection.outlook.com ([40.107.93.51]:6160 helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX0s8-00022Y-5L; Fri, 08 May 2020 07:08:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ec6PYUS8OHr8MJVtIoc76arxdwhvx9xeKptzrktDkPDGQSa2E/X6bISg+Ts3nuo7NltbHMTQJzZKq8nl1Gj2efWajNPZy+f5UFDOBGfWhWk+LodyGFM6RgkLUBZwbngg+dfBCxhke7nPvuuzV6AYZSqxvBw2mxliBhsUZjfrjWZ7uNIqwx1jAl0nrULJJI8nsB+I4GJCFsehh0258SxwU7NyGyKtPdFvJJl5D504YnIKAK3kxpHrX+S7BoP9MxsH8gkd0KR/18CXeukii5gbwVnTd+Z1eYy7mSrWgAks6TK7aFjgJCtsJ2RZiVvqhNr+dNdMHY8xa0WbO/Cixe1QtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y+XSDsSZ2+OyxjAeEFWTid5pcvRi8gI/0wNI0pPOCPs=; b=bzklcU6bDhN0ZEEqTJipxzMLry3FhmoGKXhWk66+tlK3hH5iJfwDOVMXr0DlVbYyJzSv4vuzbjqjpBumePGkgfE2LqVwFP4Kkj54AE0VudN/muDXWQ5LLWXMKvMw5nKHHR/18lS5ONdghUPTDo8QjN62eKE6c2j60Aw6y2JluLzbemaVOOu9DqeqZiRPK0ojvJnnFGo1K/MG45r3LGfJpo1+zSlD7GF/rgM3NVbdfyag/wbqmsI7uHdBrf6JwE5tIKLMnTHkYt1tuvRkWy2cMizlEsrxC4/a3IowD8V8dsF7YsDojcZCrzPH5UYJB0O17Kl710xe2vpFzPd2O+gy8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=wdc.com smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y+XSDsSZ2+OyxjAeEFWTid5pcvRi8gI/0wNI0pPOCPs=; b=Zo6LaDudYiRwAVwOjZnVDzIpgcs6/3TvbJVo/6KFp3b70zfgSo0AUPzyxvE7PGlUQoHtkfczqJ1Gh0xwIUj5rmV3j3vqoC8EVKPnnSQn2GCFzYsjyB7/RqrBXyhBgcmEun3CZISVEj0vqK7+cmvoogrHwdKFLXRatILP/eZm5U4= Received: from CY4PR16CA0012.namprd16.prod.outlook.com (2603:10b6:903:102::22) by BN6PR02MB3283.namprd02.prod.outlook.com (2603:10b6:405:64::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.29; Fri, 8 May 2020 11:08:48 +0000 Received: from CY1NAM02FT009.eop-nam02.prod.protection.outlook.com (2603:10b6:903:102:cafe::f6) by CY4PR16CA0012.outlook.office365.com (2603:10b6:903:102::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.28 via Frontend Transport; Fri, 8 May 2020 11:08:47 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by CY1NAM02FT009.mail.protection.outlook.com (10.152.75.12) with Microsoft SMTP Server id 15.20.2979.29 via Frontend Transport; Fri, 8 May 2020 11:08:47 +0000 Received: from [149.199.38.66] (port=35743 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.90) (envelope-from ) id 1jX0rs-0002Ti-C8; Fri, 08 May 2020 04:08:36 -0700 Received: from [127.0.0.1] (helo=xsj-smtp-dlp2.xlnx.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1jX0s3-0005aF-5D; Fri, 08 May 2020 04:08:47 -0700 Received: from xsj-pvapsmtp01 (smtp3.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 048B8kOH021152; Fri, 8 May 2020 04:08:46 -0700 Received: from [10.140.6.35] (helo=xhdsaipava40.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1jX0s1-0005Z7-NE; Fri, 08 May 2020 04:08:45 -0700 Received: by xhdsaipava40.xilinx.com (Postfix, from userid 14131) id A0F2E13C042F; Fri, 8 May 2020 16:30:53 +0530 (IST) From: Sai Pavan Boddu To: "Edgar E. Iglesias" , Alistair Francis , Peter Maydell , Jason Wang , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Tong Ho , Ramon Fried Subject: [PATCH v3 02/11] net: cadence_gem: Fix the queue address update during wrap around Date: Fri, 8 May 2020 16:30:36 +0530 Message-Id: <1588935645-20351-3-git-send-email-sai.pavan.boddu@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1588935645-20351-1-git-send-email-sai.pavan.boddu@xilinx.com> References: <1588935645-20351-1-git-send-email-sai.pavan.boddu@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapsmtpgw01; PTR:unknown-60-83.xilinx.com; CAT:NONE; SFTY:; SFS:(396003)(136003)(39860400002)(346002)(376002)(46966005)(33430700001)(36756003)(82740400003)(47076004)(82310400002)(426003)(356005)(33440700001)(81166007)(2906002)(5660300002)(110136005)(42186006)(4326008)(8936002)(316002)(6266002)(336012)(6666004)(478600001)(2616005)(186003)(70206006)(8676002)(26005)(70586007); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fa474392-9bf8-4a8f-fe9e-08d7f3402e2e X-MS-TrafficTypeDiagnostic: BN6PR02MB3283: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:483; X-Forefront-PRVS: 039735BC4E X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HxKG3wX6j+riLFcWu58oYPjR2L81cs7Lirqgad9GxsVcVC9MHHyOgSNPR7A65YkCpUxKFOZPy9LNPjWOCTG3fbSsNE2uQD4xlAvF7vc984vfkgtLPge+jm38n3Ze5VVEafjo6YgdExFYfrkVODGwa8utEvs4O6hceYyLE3iDE+2AJDlj4XnMxoFeFY2LSTlwRQhuf7bZ6LOdyWBO0ySxT/A5GHQPYGQv6ix8hdjLRxsFv3XT9nueaakoUrr8ggbKdk8mIakQs6x0pA4bOcy0hjhac8gYbDta3fOnWVUmntm7nzX0bC+CYu5wBKH5Ms2dP0x4idor/rucybpwVdohKDte5IiTR87RxlAWdIVev0WAx4R1cGt7PPM1Y7UGcRtQl6yqgsjXbNP9dd6xEeO1sL3l5V4hKl2Uwg68eu4iE4tuebIxournaLNanC5/t4qqDGGl/hH5B+L9S9mjW/Zg66fBzqxkewya3fRsv8WDcXR4MsAZLISzoXXhnpUR8u/NtICONmqgOQjOPosGOlk8Bj/4ayDo9dqZKU3jWu/KITxPYfhSdwNBCoUL6gWUQ1bDmVyWa8cYRlzrtnY3mtrq4g== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2020 11:08:47.4372 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa474392-9bf8-4a8f-fe9e-08d7f3402e2e 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.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR02MB3283 Received-SPF: pass client-ip=40.107.93.51; envelope-from=saipava@xilinx.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 07:08:51 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" During wrap around and reset, queues are pointing to initial base address of queue 0, irrespective of what queue we are dealing with. Fix it by assigning proper base address every time. Signed-off-by: Sai Pavan Boddu Reviewed-by: Edgar E. Iglesias --- hw/net/cadence_gem.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index 5476c62..e6dc436 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -845,6 +845,35 @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, return 0; } +static uint32_t gem_get_queue_base_addr(CadenceGEMState *s, bool tx, int q) +{ + uint32_t base_addr = 0; + + switch (q) { + case 0: + base_addr = s->regs[tx ? GEM_TXQBASE : GEM_RXQBASE]; + break; + case 1 ... (MAX_PRIORITY_QUEUES - 1): + base_addr = s->regs[(tx ? GEM_TRANSMIT_Q1_PTR : + GEM_RECEIVE_Q1_PTR) + q - 1]; + break; + default: + g_assert_not_reached(); + }; + + return base_addr; +} + +static uint32_t gem_get_tx_queue_base_addr(CadenceGEMState *s, int q) +{ + return gem_get_queue_base_addr(s, true, q); +} + +static uint32_t gem_get_rx_queue_base_addr(CadenceGEMState *s, int q) +{ + return gem_get_queue_base_addr(s, false, q); +} + static hwaddr gem_get_desc_addr(CadenceGEMState *s, bool tx, int q) { hwaddr desc_addr = 0; @@ -1043,7 +1072,7 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) /* Next descriptor */ if (rx_desc_get_wrap(s->rx_desc[q])) { DB_PRINT("wrapping RX descriptor list\n"); - s->rx_desc_addr[q] = s->regs[GEM_RXQBASE]; + s->rx_desc_addr[q] = gem_get_rx_queue_base_addr(s, q); } else { DB_PRINT("incrementing RX descriptor list\n"); s->rx_desc_addr[q] += 4 * gem_get_desc_len(s, true); @@ -1199,7 +1228,7 @@ static void gem_transmit(CadenceGEMState *s) sizeof(desc_first)); /* Advance the hardware current descriptor past this packet */ if (tx_desc_get_wrap(desc)) { - s->tx_desc_addr[q] = s->regs[GEM_TXQBASE]; + s->tx_desc_addr[q] = gem_get_tx_queue_base_addr(s, q); } else { s->tx_desc_addr[q] = packet_desc_addr + 4 * gem_get_desc_len(s, false); @@ -1251,7 +1280,7 @@ static void gem_transmit(CadenceGEMState *s) } else { packet_desc_addr = 0; } - packet_desc_addr |= s->regs[GEM_TXQBASE]; + packet_desc_addr |= gem_get_tx_queue_base_addr(s, q); } else { packet_desc_addr += 4 * gem_get_desc_len(s, false); } @@ -1457,7 +1486,7 @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val, if (!(val & GEM_NWCTRL_TXENA)) { /* Reset to start of Q when transmit disabled. */ for (i = 0; i < s->num_priority_queues; i++) { - s->tx_desc_addr[i] = s->regs[GEM_TXQBASE]; + s->tx_desc_addr[i] = gem_get_tx_queue_base_addr(s, i); } } if (gem_can_receive(qemu_get_queue(s->nic))) {