Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5C695C64EC4 for ; Fri, 3 Mar 2023 20:49:26 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AAC0A85CD0; Fri, 3 Mar 2023 21:49:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="b9z5nI63"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E357F85D70; Fri, 3 Mar 2023 21:49:07 +0100 (CET) Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6C58685D70 for ; Fri, 3 Mar 2023 21:49:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=christian.gmeiner@gmail.com Received: by mail-ed1-x529.google.com with SMTP id i34so15227413eda.7 for ; Fri, 03 Mar 2023 12:49:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677876545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Hj4Bdes5+DRBQG1y25NATxthHBRZAro2cMUsj83Rng8=; b=b9z5nI63hyG6vELYlizzTTOZAlbrd11J+fY8NMex3tw8SIOFlnei4ZF3HfYm1dOIJS yPZTOHDp6B9MBGvOeI6GF3AZNabwFYnRuiEs/LcypOkjIK8vV8EAu0accb2FyQhRX/2W SLEeNwu3HNn5KsOZn5K6th74fj+3wFYfNpm/XkUDBaZYqGCSNXHGO5i6NQbWzUaSKL3H uwjnNyxedVnQHDESMg2hj3AkCAx3WyEYANBHxE4XcOljcpHuXG3kxU0EwrutJw5RJgR1 dgsp1DVw6af8YlET+kP8HBOUfxXfVgK4mPuQLMVDxVuc/gcl+MuAUZcklUy7bciJN8Xb Zlug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677876545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hj4Bdes5+DRBQG1y25NATxthHBRZAro2cMUsj83Rng8=; b=f/zD74hThNYDTBiSMBdMPbqzfItqIprnjBWuBLBQyd3r8lxLLDW1NchWk/H4sj5Zh+ dKDWgRdiNrN+zldik9KQPIL0FZuehsuDWVedGvALH7gCcgIRRTvEBxboG+jNpPlRAbjA 3stjEa1fgYW0HOYTo/yI3HrRMCcNBJRE7Igo5pKWIb/WszIzsXWxTahraFB5U3/J9ldd l5ZPS8TX5UEyTFGujzVxIoLQH3FQfpcxozAy2OtzidUlpSQ7fNYfanFjPZJOksI625f8 MfrCbPtt5pK3hGa6RMoOgkfU3wbChdrwJ84AnfL/Lot/1aS81Flo8y96QFicEvBusvHW 8fvg== X-Gm-Message-State: AO0yUKXP/ChQNmEuBui8ePf95nGpS9SglV0dH44s82BKxgSe3rOWSg/O 7Y0bbiGfIwsvTsbIfeWRmhY9ywX2pvM= X-Google-Smtp-Source: AK7set9eKrdGDv+0llX6po4/JCR1hi8TlnsC43uSMiQKFv6ufNQg3g7dK6ErDj/FG0J+UrEhpwtiaQ== X-Received: by 2002:aa7:d390:0:b0:4ac:bdeb:6dce with SMTP id x16-20020aa7d390000000b004acbdeb6dcemr2930576edq.39.1677876544825; Fri, 03 Mar 2023 12:49:04 -0800 (PST) Received: from localhost.localdomain (80-108-76-242.cable.dynamic.surfer.at. [80.108.76.242]) by smtp.gmail.com with ESMTPSA id v15-20020a50954f000000b004c09527d62dsm1600015eda.30.2023.03.03.12.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 12:49:04 -0800 (PST) From: Christian Gmeiner To: Joe Hershberger , Ramon Fried , u-boot@lists.denx.de (open list) Cc: Christian Gmeiner Subject: [PATCH 2/4] net: e1000: move all rx data structures to hw instance Date: Fri, 3 Mar 2023 21:48:42 +0100 Message-Id: <20230303204844.112105-2-christian.gmeiner@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303204844.112105-1-christian.gmeiner@gmail.com> References: <20230303204844.112105-1-christian.gmeiner@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Preparation for per driver instance allocated data structures. Signed-off-by: Christian Gmeiner --- drivers/net/e1000.c | 26 +++++++++++++++----------- drivers/net/e1000.h | 5 +++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 8dccf29c7e..08c84ce3d1 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -61,10 +61,9 @@ tested on both gig copper and gig fiber boards */ DEFINE_ALIGN_BUFFER(struct e1000_tx_desc, tx_base, 16, E1000_BUFFER_ALIGN); DEFINE_ALIGN_BUFFER(struct e1000_rx_desc, rx_base, NUM_RX_DESC, E1000_BUFFER_ALIGN); -DEFINE_ALIGN_BUFFER(unsigned char, packet, 4096, E1000_BUFFER_ALIGN); +DEFINE_ALIGN_BUFFER(unsigned char, _packet, 4096, E1000_BUFFER_ALIGN); static int tx_tail; -static int rx_tail, rx_last; static int num_cards; /* Number of E1000 devices seen so far */ static struct pci_device_id e1000_supported[] = { @@ -5090,12 +5089,13 @@ e1000_sw_init(struct e1000_hw *hw) void fill_rx(struct e1000_hw *hw) { + unsigned char *packet = hw->rx_packet; struct e1000_rx_desc *rd; unsigned long flush_start, flush_end; - rx_last = rx_tail; - rd = rx_base + rx_tail; - rx_tail = (rx_tail + 1) % NUM_RX_DESC; + hw->rx_last = hw->rx_tail; + rd = hw->rx_base + hw->rx_tail; + hw->rx_tail = (hw->rx_tail + 1) % NUM_RX_DESC; memset(rd, 0, 16); rd->buffer_addr = cpu_to_le64(virt_to_phys(packet)); @@ -5111,7 +5111,7 @@ fill_rx(struct e1000_hw *hw) flush_end = flush_start + roundup(sizeof(*rd), ARCH_DMA_MINALIGN); flush_dcache_range(flush_start, flush_end); - E1000_WRITE_REG(hw, RDT, rx_tail); + E1000_WRITE_REG(hw, RDT, hw->rx_tail); } /** @@ -5248,7 +5248,7 @@ static void e1000_configure_rx(struct e1000_hw *hw) { unsigned long rctl, ctrl_ext; - rx_tail = 0; + hw->rx_tail = 0; /* make sure receives are disabled while setting up the descriptors */ rctl = E1000_READ_REG(hw, RCTL); @@ -5269,8 +5269,8 @@ e1000_configure_rx(struct e1000_hw *hw) E1000_WRITE_FLUSH(hw); } /* Setup the Base and Length of the Rx Descriptor Ring */ - E1000_WRITE_REG(hw, RDBAL, lower_32_bits(virt_to_phys(rx_base))); - E1000_WRITE_REG(hw, RDBAH, upper_32_bits(virt_to_phys(rx_base))); + E1000_WRITE_REG(hw, RDBAL, lower_32_bits(virt_to_phys(hw->rx_base))); + E1000_WRITE_REG(hw, RDBAH, upper_32_bits(virt_to_phys(hw->rx_base))); E1000_WRITE_REG(hw, RDLEN, NUM_RX_DESC * sizeof(struct e1000_rx_desc)); @@ -5298,12 +5298,13 @@ POLL - Wait for a frame static int _e1000_poll(struct e1000_hw *hw) { + unsigned char *packet = hw->rx_packet; struct e1000_rx_desc *rd; unsigned long inval_start, inval_end; uint32_t len; /* return true if there's an ethernet packet ready to read */ - rd = rx_base + rx_last; + rd = hw->rx_base + hw->rx_last; /* Re-load the descriptor from RAM. */ inval_start = ((unsigned long)rd) & ~(ARCH_DMA_MINALIGN - 1); @@ -5469,6 +5470,9 @@ static int e1000_init_one(struct e1000_hw *hw, int cardnum, return -EPERM; } + hw->rx_base = rx_base; + hw->rx_packet = _packet; + /* Are these variables needed? */ hw->fc = e1000_fc_default; hw->original_fc = e1000_fc_default; @@ -5663,7 +5667,7 @@ static int e1000_eth_recv(struct udevice *dev, int flags, uchar **packetp) len = _e1000_poll(hw); if (len) - *packetp = packet; + *packetp = hw->rx_packet; return len ? len : -EAGAIN; } diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h index 69882ba66f..f83e3a0b33 100644 --- a/drivers/net/e1000.h +++ b/drivers/net/e1000.h @@ -1134,6 +1134,11 @@ struct e1000_hw { bool initialize_hw_bits_disable; e1000_smart_speed smart_speed; e1000_dsp_config dsp_config_state; + + struct e1000_rx_desc *rx_base; + unsigned char *rx_packet; + int rx_tail; + int rx_last; }; #define E1000_EEPROM_SWDPIN0 0x0001 /* SWDPIN 0 EEPROM Value */ -- 2.39.2