From patchwork Thu Sep 8 11:58:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1675564 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=vdTVcK+R; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MNd521pFrz1yhR for ; Thu, 8 Sep 2022 22:01:26 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CC9FA84B2C; Thu, 8 Sep 2022 13:59:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="vdTVcK+R"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1E20084B13; Thu, 8 Sep 2022 13:59:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 33C3684ADE for ; Thu, 8 Sep 2022 13:59:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id A69FE4709D; Thu, 8 Sep 2022 11:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1662638369; x=1664452770; bh=poEuXk2BB6TYWgwsikn8KLQZa +vuwPTxfTvB3w5x5MU=; b=vdTVcK+RyQM8daUPr2rgXk/ZiFsmS3KjZbkR2eS3h xktaW9lfbQ2+qvP7Twnga2KFiGgCxgnNI2IF3TLU/Y0i72hmzHHk47RA16+pFb1T SoB+J5kjW2XRtlz1w2ufhT9iJO8zO6wkcHSK84EajXRZP/R9yvVl++uY5ImLI6Hc uE= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JadxQ5kRuX0U; Thu, 8 Sep 2022 14:59:29 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 2E886470B1; Thu, 8 Sep 2022 14:59:26 +0300 (MSK) Received: from T-EXCH-06.corp.yadro.com (172.17.10.110) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Thu, 8 Sep 2022 14:59:26 +0300 Received: from v.yadro.com (10.199.17.194) by T-EXCH-06.corp.yadro.com (172.17.10.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Thu, 8 Sep 2022 14:59:25 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , , Subject: [PATCH 09/17] net: ipv6: Incorporate IPv6 support into u-boot net subsystem Date: Thu, 8 Sep 2022 14:58:57 +0300 Message-ID: <20220908115905.70928-10-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220908115905.70928-1-v.v.mitrofanov@yadro.com> References: <20220908115905.70928-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.199.17.194] X-ClientProxiedBy: T-EXCH-02.corp.yadro.com (172.17.10.102) To T-EXCH-06.corp.yadro.com (172.17.10.110) 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 Add net_ip6_handler (an IPv6 packet handler) into net_loop. Add neighbor discovery mechanism into network init process. That is the main step to run IPv6 in u-boot. Now u-boot is capable to use NDP and handle IPv6 packets. Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Simon Glass --- net/net.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/net/net.c b/net/net.c index 81905f6315..f818170930 100644 --- a/net/net.c +++ b/net/net.c @@ -91,6 +91,8 @@ #include #include #include +#include +#include #include #include #if defined(CONFIG_CMD_PCAP) @@ -340,8 +342,17 @@ void net_auto_load(void) static int net_init_loop(void) { - if (eth_get_dev()) + if (eth_get_dev()) { memcpy(net_ethaddr, eth_get_ethaddr(), 6); + + if (IS_ENABLED(CONFIG_IPV6)) { + ip6_make_lladdr(&net_link_local_ip6, net_ethaddr); + if (!memcmp(&net_ip6, &net_null_addr_ip6, + sizeof(struct in6_addr))) + memcpy(&net_ip6, &net_link_local_ip6, + sizeof(struct in6_addr)); + } + } else /* * Not ideal, but there's no way to get the actual error, and I @@ -382,6 +393,7 @@ int net_init(void) (i + 1) * PKTSIZE_ALIGN; } arp_init(); + ndisc_init(); net_clear_handlers(); /* Only need to setup buffer pointers once. */ @@ -563,6 +575,10 @@ restart: if (arp_timeout_check() > 0) time_start = get_timer(0); + if (IS_ENABLED(CONFIG_IPV6)) { + if (use_ip6 && (ndisc_timeout_check() > 0)) + time_start = get_timer(0); + } /* * Check the ethernet for a new packet. The ethernet * receive routine will process it. @@ -1187,6 +1203,11 @@ void net_process_received_packet(uchar *in_packet, int len) case PROT_RARP: rarp_receive(ip, len); break; +#endif +#if IS_ENABLED(CONFIG_IPV6) + case PROT_IP6: + net_ip6_handler(et, (struct ip6_hdr *)ip, len); + break; #endif case PROT_IP: debug_cond(DEBUG_NET_PKT, "Got IP\n");