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 CF076C7EE30 for ; Fri, 3 Mar 2023 20:49:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7F95185D8C; Fri, 3 Mar 2023 21:49:12 +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="Mu/Y9yE7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3166E85C1A; Fri, 3 Mar 2023 21:49:09 +0100 (CET) Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 A6CCB85935 for ; Fri, 3 Mar 2023 21:49:06 +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-x535.google.com with SMTP id u9so15339536edd.2 for ; Fri, 03 Mar 2023 12:49:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677876546; 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=kdA3ouIMXAjVAOm9V8NrzsIop+D92s1L1s0Q1NyKym8=; b=Mu/Y9yE7I1LL4KDtMVyLHt+3V8CTS6Fi5vgIj5Q8v5dbasmxSfTp6rBxgFkZ8bv86c ADyY0ldfyV6eRjZ54B17Nxj9aAaOOQMb4QbPl5aERKZpC0GKt/12Rrf0DzA0r7RAHTyy suAvEppMqKwZIGpP3R/UI/R8CseIopCHmvlghHy7xSGGNPu4wMMJFh4LpgBdxsEsUHic JmdssPiSP1zrgx2Snp9ybiv4A7ZTyLEzeRpimJlveyMsrhTkhLkDKlYankqRTZDM8uyB GALjd9A+NY0zG08fMUegt7VgFVyXwi06PlnyYHEdOSnpaTf+Z4yL5vXUialGAUYxMtX6 415Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677876546; 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=kdA3ouIMXAjVAOm9V8NrzsIop+D92s1L1s0Q1NyKym8=; b=vC1LGs1ypSNi4DCnrLAYgrpP0fUt4U/Qx2wqerCoWilrdrAxrT3tjejS2tjRDk0ZTC u8OFyTuGrYGDCyBB0x++nMh7aZNKzyRTEX5z1aLKC1s1wSm0wn/2zWagyRE7K7v33bRq aBWdyKG+uHYWjy3HmiN6XkUhYp34PeYMlJ8FrZx3gm+v5G/0HL8dbWUu8XQeQgFvpP2n Ip3pz4O9EClqm4/7YXTwvK9tX5gdRQX+1Ee5+PGJpbiF9O8fLkykePYuUKdcMCHqOmrA wXZuh9M1ot86k/B8Ip+QxMh/KtVQiskf4Bzoc1k7T1Kqawuz/M3Gi5egALXzXtY8GDHY N8EA== X-Gm-Message-State: AO0yUKUQsh6pvolwhTOP1oD0JUrGgWcWk7jejutpYG0UBqIHurT9NBSz MpSq7JEDyzn4Xfwa2XiWYZE= X-Google-Smtp-Source: AK7set8mJEEW1NDTjX5StY7WTS5fx/JHk1KBGPmbJ8zNSdRQLWOkzQ0p8mGkH4eO3I7VTGoBWKtcQQ== X-Received: by 2002:a50:ee18:0:b0:4af:69b8:52af with SMTP id g24-20020a50ee18000000b004af69b852afmr3018777eds.24.1677876546260; Fri, 03 Mar 2023 12:49:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 12:49:05 -0800 (PST) From: Christian Gmeiner To: Joe Hershberger , Ramon Fried , u-boot@lists.denx.de (open list) Cc: Christian Gmeiner Subject: [PATCH 3/4] net: e1000: dynamically allocate rx data buffers per instance Date: Fri, 3 Mar 2023 21:48:43 +0100 Message-Id: <20230303204844.112105-3-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 Signed-off-by: Christian Gmeiner --- drivers/net/e1000.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 08c84ce3d1..ea9ca76917 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -54,14 +54,11 @@ tested on both gig copper and gig fiber boards #define E1000_BUFFER_ALIGN 128 /* - * TODO(sjg@chromium.org): Even with driver model we share these buffers. - * Concurrent receiving on multiple active Ethernet devices will not work. - * Normally U-Boot does not support this anyway. To fix it in this driver, - * move these buffers and the tx/rx pointers to struct e1000_hw. + * TODO(sjg@chromium.org): Even with driver model we share tx buffer. + * To fix it in this driver, move these buffer and the tx pointers to + * struct e1000_hw. */ 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); static int tx_tail; static int num_cards; /* Number of E1000 devices seen so far */ @@ -5442,6 +5439,12 @@ void e1000_get_bus_type(struct e1000_hw *hw) } } +static inline void * +e1000_alloc(size_t size) +{ + return memalign(E1000_BUFFER_ALIGN, size); +} + static int e1000_init_one(struct e1000_hw *hw, int cardnum, struct udevice *devno, unsigned char enetaddr[6]) { @@ -5470,8 +5473,14 @@ static int e1000_init_one(struct e1000_hw *hw, int cardnum, return -EPERM; } - hw->rx_base = rx_base; - hw->rx_packet = _packet; + hw->rx_base = e1000_alloc(NUM_RX_DESC * sizeof(struct e1000_rx_desc)); + hw->rx_packet = e1000_alloc(4096); + + if (!hw->rx_base || !hw->rx_packet) { + free(hw->rx_base); + free(hw->rx_packet); + return -ENOMEM; + } /* Are these variables needed? */ hw->fc = e1000_fc_default; -- 2.39.2