From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mx.groups.io with SMTP id smtpd.web12.27703.1647272336695866379 for ; Mon, 14 Mar 2022 08:38:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@semihalf-com.20210112.gappssmtp.com header.s=20210112 header.b=2ikzEF6j; spf=none, err=SPF record not found (domain: semihalf.com, ip: 209.85.167.44, mailfrom: mw@semihalf.com) Received: by mail-lf1-f44.google.com with SMTP id g17so27904098lfh.2 for ; Mon, 14 Mar 2022 08:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6pPvvQ7LpwzStJOYjs+kBLqQSiMMxlHodhFbyCu1bhw=; b=2ikzEF6jkC19r0bwq8iKhldO0MU7uxjPxBaFqXSrwoXwO4BFJJKWTUcQZ6lzWYXhXT aU3C1F/Vi9vwPoYIVHsZIaikA1qxZX+9KoTW0FzKlwvxxhnJTj4847dy/h0otU6F+qle /yhtqgRHqmFQfejFeRrz7cEJQlr+c0sIOCXhW5UnAXuwTqes/ljctcgOhctBUNXMlTKU J3Koj5oAp1NmEvmPMeXCJ4wuguVoDjv4oilPkPZB9TB2Iv2tXOpTNQAMDyqi2PquiR/F rsoBeMvsXNbNAtBBKse7FTISMwimInRyrDxrOelJqfzUdog9Ws2hz/MRbdYRSfTJ2Om+ A/Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6pPvvQ7LpwzStJOYjs+kBLqQSiMMxlHodhFbyCu1bhw=; b=7YjVLTeoajE0w0fdDTxGQPvfpl/Vot+PqywpDQ5+8zt7KCYwcw4F4VJfVKXR8Cj3ZG cPJrMsQEv2h+iSk7cB/GtcQ5e9u986izo7YoXENXkRhqvWKUaOwmhOObjdyjj8Xr/mQ+ 2AVPAWBsGVm5uiY9TjjYRMkvi0GWvANJuf5b2Jab+bzG4MfjLisfg+c9zyff+qGUORSF DnrJowY8DrnzBlJuupBuYTyK1W7hNyvTbI2qgfxpPHFKsGpFXkA8/cDgtKF066BzqCzR rPl83wmCJrQdMj9jdsfwbWq8WVFgao2tcTOdmJO8IdyuG87Kpx92q5IgJ9UgLBKup/zi N4jw== X-Gm-Message-State: AOAM532alPJfyONCjKud/njMHmiHVOZ2wW0KhnOx+mLKm+lMtKZuoWBm /bxuz89xMLvKgvF0wZLM77AQY0b1ud+kLQ== X-Google-Smtp-Source: ABdhPJz6QCF/txB/O42ENBt3SRPW5z91Z5b0vn3QyzGC2DcPIj63sQzuDy+d1XM9dAxKkaADk7RyPA== X-Received: by 2002:a05:6512:1511:b0:448:36d9:df26 with SMTP id bq17-20020a056512151100b0044836d9df26mr13624247lfb.652.1647272334973; Mon, 14 Mar 2022 08:38:54 -0700 (PDT) Return-Path: Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id b8-20020ac25628000000b004484bd1be5esm3325401lff.256.2022.03.14.08.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 08:38:54 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, ardb+tianocore@kernel.org, mw@semihalf.com, jaz@semihalf.com, gjb@semihalf.com, upstream@semihalf.com, sunny.Wang@arm.com Subject: [edk2-platforms PATCH 4/8] Marvell/Drivers: Pp2Dxe: Implement Pp2SnpIpToMac Date: Mon, 14 Mar 2022 16:38:33 +0100 Message-Id: <20220314153837.1885852-5-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220314153837.1885852-1-mw@semihalf.com> References: <20220314153837.1885852-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable The SNP MCastIpToMac callback was unsupported in Pp2Dxe driver. Implement it. Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 81 +++++++++++++++++++- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Silicon/Marvell/= Drivers/Net/Pp2Dxe/Pp2Dxe.c index 5f487c4dc6..91cd573b87 100644 --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c @@ -889,12 +889,85 @@ EFI_STATUS EFIAPI=0D Pp2SnpIpToMac (=0D IN EFI_SIMPLE_NETWORK_PROTOCOL *This,=0D - IN BOOLEAN IPv6,=0D - IN EFI_IP_ADDRESS *IP,=0D - OUT EFI_MAC_ADDRESS *MAC=0D + IN BOOLEAN IsIpv6,=0D + IN EFI_IP_ADDRESS *Ip,=0D + OUT EFI_MAC_ADDRESS *McastMac=0D )=0D {=0D - return EFI_UNSUPPORTED;=0D + PP2DXE_CONTEXT *Pp2Context;=0D + EFI_TPL SavedTpl;=0D +=0D + /* Check Snp Instance. */=0D + if (This =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + SavedTpl =3D gBS->RaiseTPL (TPL_CALLBACK);=0D +=0D + Pp2Context =3D INSTANCE_FROM_SNP (This);=0D +=0D + /* Check that driver was started and initialised. */=0D + if (This->Mode->State !=3D EfiSimpleNetworkInitialized) {=0D + switch (This->Mode->State) {=0D + case EfiSimpleNetworkStopped:=0D + DEBUG ((DEBUG_WARN, "Pp2Dxe%d: not started\n", Pp2Context->Instance)= );=0D + ReturnUnlock (SavedTpl, EFI_NOT_STARTED);=0D + case EfiSimpleNetworkStarted:=0D + DEBUG ((DEBUG_WARN, "Pp2Dxe%d: not initialized\n", Pp2Context->Insta= nce));=0D + ReturnUnlock (SavedTpl, EFI_DEVICE_ERROR);=0D + default:=0D + DEBUG ((DEBUG_WARN,=0D + "Pp2Dxe%d: wrong state: %u\n",=0D + Pp2Context->Instance,=0D + This->Mode->State));=0D + ReturnUnlock (SavedTpl, EFI_DEVICE_ERROR);=0D + }=0D + }=0D +=0D + /* Check parameters. */=0D + if ((McastMac =3D=3D NULL) || (Ip =3D=3D NULL)) {=0D + ReturnUnlock (SavedTpl, EFI_INVALID_PARAMETER);=0D + }=0D +=0D + /* Make sure MAC address is empty. */=0D + ZeroMem (McastMac, sizeof(EFI_MAC_ADDRESS));=0D +=0D + /* If we need ipv4 address. */=0D + if (!IsIpv6) {=0D + /*=0D + * Most significant 25 bits of a multicast HW address are set.=0D + * 01-00-5E is the IPv4 Ethernet Multicast Address (see RFC 1112).=0D + */=0D + McastMac->Addr[0] =3D 0x01;=0D + McastMac->Addr[1] =3D 0x00;=0D + McastMac->Addr[2] =3D 0x5E;=0D +=0D + /*=0D + * Lower 23 bits from ipv4 address=0D + * Clear the most significant bit (25th bit of MAC must be 0).=0D + */=0D + McastMac->Addr[3] =3D Ip->v4.Addr[1] & 0x7F;=0D + McastMac->Addr[4] =3D Ip->v4.Addr[2];=0D + McastMac->Addr[5] =3D Ip->v4.Addr[3];=0D + } else {=0D + /*=0D + * Most significant 16 bits of multicast v6 HW address are set=0D + * 33-33 is the IPv6 Ethernet Multicast Address (see RFC 2464).=0D + */=0D + McastMac->Addr[0] =3D 0x33;=0D + McastMac->Addr[1] =3D 0x33;=0D +=0D + /* Lower four octets are taken from ipv6 address. */=0D + McastMac->Addr[2] =3D Ip->v6.Addr[8];=0D + McastMac->Addr[3] =3D Ip->v6.Addr[9];=0D + McastMac->Addr[4] =3D Ip->v6.Addr[10];=0D + McastMac->Addr[5] =3D Ip->v6.Addr[11];=0D + }=0D +=0D + /* Restore TPL and return. */=0D + gBS->RestoreTPL (SavedTpl);=0D +=0D + return EFI_SUCCESS;=0D }=0D =0D EFI_STATUS=0D --=20 2.29.0