Skip to content

Commit

Permalink
depreciating VLAN support in ethernet/IpV4Engine because never tested…
Browse files Browse the repository at this point in the history
… and never used
  • Loading branch information
ruck314 committed Jul 11, 2024
1 parent 9c6aee9 commit 7395517
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 560 deletions.
4 changes: 1 addition & 3 deletions ethernet/EthMacCore/rtl/EthMacPkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;


library surf;
use surf.StdRtlPkg.all;
use surf.AxiStreamPkg.all;
Expand All @@ -30,7 +29,6 @@ package EthMacPkg is
-- EtherTypes
constant ARP_TYPE_C : slv(15 downto 0) := x"0608"; -- EtherType = ARP = 0x0806
constant IPV4_TYPE_C : slv(15 downto 0) := x"0008"; -- EtherType = IPV4 = 0x0800
constant VLAN_TYPE_C : slv(15 downto 0) := x"0081"; -- EtherType = VLAN = 0x8100

-- IPV4 Protocol Constants
constant UDP_C : slv(7 downto 0) := x"11"; -- Protocol = UDP = 0x11
Expand Down Expand Up @@ -68,7 +66,7 @@ package EthMacPkg is
-- TDEST_INTERLEAVE_C => EMAC_AXIS_CONFIG_C.TDEST_INTERLEAVE_C,
TSTRB_EN_C => EMAC_AXIS_CONFIG_C.TSTRB_EN_C,
TDATA_BYTES_C => EMAC_AXIS_CONFIG_C.TDATA_BYTES_C,
TDEST_BITS_C => 0, -- TDEST not used internally of EthMacTop.vhd
TDEST_BITS_C => 0, -- TDEST not used internally of EthMacTop.vhd
TID_BITS_C => EMAC_AXIS_CONFIG_C.TID_BITS_C,
TKEEP_MODE_C => EMAC_AXIS_CONFIG_C.TKEEP_MODE_C,
TUSER_BITS_C => EMAC_AXIS_CONFIG_C.TUSER_BITS_C,
Expand Down
198 changes: 58 additions & 140 deletions ethernet/IpV4Engine/rtl/ArpEngine.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;


library surf;
use surf.StdRtlPkg.all;
use surf.AxiStreamPkg.all;
Expand All @@ -28,8 +27,7 @@ entity ArpEngine is
generic (
TPD_G : time := 1 ns;
CLIENT_SIZE_G : positive := 1;
CLK_FREQ_G : real := 156.25E+06; -- In units of Hz
VLAN_G : boolean := false);
CLK_FREQ_G : real := 156.25E+06); -- In units of Hz
port (
-- Local Configuration
localMac : in slv(47 downto 0);
Expand All @@ -55,8 +53,8 @@ architecture rtl of ArpEngine is
constant BROADCAST_MAC_C : slv(47 downto 0) := (others => '1');
constant HARDWWARE_TYPE_C : slv(15 downto 0) := x"0100"; -- HardwareType = ETH = 0x0001
constant PROTOCOL_TYPE_C : slv(15 downto 0) := x"0008"; -- ProtocolType = IP = 0x0800
constant HARDWWARE_LEN_C : slv(7 downto 0) := x"06"; -- HardwareLength = 6 (6 Bytes/MAC)
constant PROTOCOL_LEN_C : slv(7 downto 0) := x"04"; -- ProtocolLength = 4 (6 Bytes/IP)
constant HARDWWARE_LEN_C : slv(7 downto 0) := x"06"; -- HardwareLength = 6 (6 Bytes/MAC)
constant PROTOCOL_LEN_C : slv(7 downto 0) := x"04"; -- ProtocolLength = 4 (6 Bytes/IP)
constant ARP_REQ_C : slv(15 downto 0) := x"0100"; -- OpCode = ARP Request = 0x0001
constant ARP_REPLY_C : slv(15 downto 0) := x"0200"; -- OpCode = ARP Reply = 0x0002
constant TIMER_1_SEC_C : natural := getTimeRatio(CLK_FREQ_G, 1.0);
Expand Down Expand Up @@ -100,7 +98,8 @@ architecture rtl of ArpEngine is

begin

comb : process (arpAckSlaves, arpReqMasters, ibArpMaster, localIp, localMac, obArpSlave, r, rst) is
comb : process (arpAckSlaves, arpReqMasters, ibArpMaster, localIp, localMac,
obArpSlave, r, rst) is
variable v : RegType;
variable i : natural;
begin
Expand Down Expand Up @@ -155,45 +154,21 @@ begin
v.arpAckMasters(r.ackCnt).tValid := '1';
v.arpAckMasters(r.ackCnt).tData(47 downto 0) := localMac;
else
------------------------
-- Checking for non-VLAN
------------------------
if (VLAN_G = false) then
v.tData(0)(47 downto 0) := BROADCAST_MAC_C;
v.tData(0)(95 downto 48) := localMac;
v.tData(0)(111 downto 96) := ARP_TYPE_C;
v.tData(0)(127 downto 112) := HARDWWARE_TYPE_C;
v.tData(1)(15 downto 0) := PROTOCOL_TYPE_C;
v.tData(1)(23 downto 16) := HARDWWARE_LEN_C;
v.tData(1)(31 downto 24) := PROTOCOL_LEN_C;
v.tData(1)(47 downto 32) := ARP_REQ_C;
v.tData(1)(95 downto 48) := localMac;
v.tData(1)(127 downto 96) := localIp;
v.tData(2)(47 downto 0) := BROADCAST_MAC_C;
v.tData(2)(79 downto 48) := arpReqMasters(r.reqCnt).tData(31 downto 0); -- Known IP address
v.tData(2)(127 downto 80) := (others => '0');
--------------------
-- Checking for VLAN
--------------------
else
v.tData(0)(47 downto 0) := BROADCAST_MAC_C;
v.tData(0)(95 downto 48) := localMac;
v.tData(0)(111 downto 96) := VLAN_TYPE_C;
v.tData(0)(127 downto 122) := (others => '0');
v.tData(1)(15 downto 0) := ARP_TYPE_C;
v.tData(1)(31 downto 16) := HARDWWARE_TYPE_C;
v.tData(1)(47 downto 32) := PROTOCOL_TYPE_C;
v.tData(1)(55 downto 48) := HARDWWARE_LEN_C;
v.tData(1)(63 downto 56) := PROTOCOL_LEN_C;
v.tData(1)(79 downto 64) := ARP_REQ_C;
v.tData(1)(127 downto 80) := localMac;
v.tData(2)(31 downto 0) := localIp;
v.tData(2)(79 downto 32) := BROADCAST_MAC_C;
v.tData(2)(111 downto 80) := arpReqMasters(r.reqCnt).tData(31 downto 0); -- Known IP address
v.tData(2)(127 downto 112) := (others => '0');
end if;
v.tData(0)(47 downto 0) := BROADCAST_MAC_C;
v.tData(0)(95 downto 48) := localMac;
v.tData(0)(111 downto 96) := ARP_TYPE_C;
v.tData(0)(127 downto 112) := HARDWWARE_TYPE_C;
v.tData(1)(15 downto 0) := PROTOCOL_TYPE_C;
v.tData(1)(23 downto 16) := HARDWWARE_LEN_C;
v.tData(1)(31 downto 24) := PROTOCOL_LEN_C;
v.tData(1)(47 downto 32) := ARP_REQ_C;
v.tData(1)(95 downto 48) := localMac;
v.tData(1)(127 downto 96) := localIp;
v.tData(2)(47 downto 0) := BROADCAST_MAC_C;
v.tData(2)(79 downto 48) := arpReqMasters(r.reqCnt).tData(31 downto 0); -- Known IP address
v.tData(2)(127 downto 80) := (others => '0');
-- Next state
v.state := TX_S;
v.state := TX_S;
end if;
end if;
end if;
Expand Down Expand Up @@ -259,100 +234,47 @@ begin
v.state := IDLE_S;
-- Reset the counter
v.cnt := 0;
------------------------
-- Checking for non-VLAN
------------------------
if (VLAN_G = false) then
if (r.tData(0)(127 downto 112) = HARDWWARE_TYPE_C) -- Check for valid Hardware type
and (r.tData(1)(15 downto 0) = PROTOCOL_TYPE_C) -- Check for valid Protocol type
and (r.tData(1)(23 downto 16) = HARDWWARE_LEN_C) -- Check for valid Hardware Length
and (r.tData(1)(31 downto 24) = PROTOCOL_LEN_C) then -- Check for valid Protocol Length
-- Check OP-CODE = ARP Request
if (r.tData(1)(47 downto 32) = ARP_REQ_C) then
-- Check if the target IP address matches local address
if r.tData(2)(79 downto 48) = localIp then
-- Modified the local buffer to become a reply packet
v.tData(0)(47 downto 0) := r.tData(0)(95 downto 48);
v.tData(0)(95 downto 48) := localMac;
v.tData(1)(47 downto 32) := ARP_REPLY_C;
v.tData(1)(95 downto 48) := localMac;
v.tData(1)(127 downto 96) := localIp;
v.tData(2)(47 downto 0) := r.tData(1)(95 downto 48);
v.tData(2)(79 downto 48) := r.tData(1)(127 downto 96);
v.tData(2)(127 downto 80) := (others => '0');
-- Next state
v.state := TX_S;
end if;
-- Check OP-CODE = ARP Reply
elsif (r.tData(1)(47 downto 32) = ARP_REPLY_C) then
-- Check if the target IP + MAC address matches local address
if (r.tData(2)(47 downto 0) = localMac) and (r.tData(2)(79 downto 48) = localIp) then
-- Next state
v.state := SCAN_S;
end if;
if (r.tData(0)(127 downto 112) = HARDWWARE_TYPE_C) -- Check for valid Hardware type
and (r.tData(1)(15 downto 0) = PROTOCOL_TYPE_C) -- Check for valid Protocol type
and (r.tData(1)(23 downto 16) = HARDWWARE_LEN_C) -- Check for valid Hardware Length
and (r.tData(1)(31 downto 24) = PROTOCOL_LEN_C) then -- Check for valid Protocol Length
-- Check OP-CODE = ARP Request
if (r.tData(1)(47 downto 32) = ARP_REQ_C) then
-- Check if the target IP address matches local address
if r.tData(2)(79 downto 48) = localIp then
-- Modified the local buffer to become a reply packet
v.tData(0)(47 downto 0) := r.tData(0)(95 downto 48);
v.tData(0)(95 downto 48) := localMac;
v.tData(1)(47 downto 32) := ARP_REPLY_C;
v.tData(1)(95 downto 48) := localMac;
v.tData(1)(127 downto 96) := localIp;
v.tData(2)(47 downto 0) := r.tData(1)(95 downto 48);
v.tData(2)(79 downto 48) := r.tData(1)(127 downto 96);
v.tData(2)(127 downto 80) := (others => '0');
-- Next state
v.state := TX_S;
end if;
end if;
--------------------
-- Checking for VLAN
--------------------
else
if (r.tData(1)(31 downto 16) = HARDWWARE_TYPE_C) -- Check for valid Hardware type
and (r.tData(1)(47 downto 32) = PROTOCOL_TYPE_C) -- Check for valid Protocol type
and (r.tData(1)(55 downto 48) = HARDWWARE_LEN_C) -- Check for valid Hardware Length
and (r.tData(1)(63 downto 56) = PROTOCOL_LEN_C) then -- Check for valid Protocol Length
-- Check OP-CODE = ARP Request
if (r.tData(1)(79 downto 64) = ARP_REQ_C) then
-- Check if the target IP address matches local address
if r.tData(2)(111 downto 80) = localIp then
-- Modified the local buffer to become a reply packet
v.tData(0)(47 downto 0) := r.tData(0)(95 downto 48);
v.tData(0)(95 downto 48) := localMac;
v.tData(1)(79 downto 64) := ARP_REPLY_C;
v.tData(1)(127 downto 80) := localMac;
v.tData(2)(31 downto 0) := localIp;
v.tData(2)(79 downto 32) := r.tData(1)(127 downto 80);
v.tData(2)(111 downto 80) := r.tData(2)(31 downto 0);
v.tData(2)(127 downto 112) := (others => '0');
-- Next state
v.state := TX_S;
end if;
-- Check OP-CODE = ARP Reply
elsif (r.tData(1)(79 downto 64) = ARP_REPLY_C) then
-- Check if the target IP + MAC address matches local address
if (r.tData(2)(79 downto 32) = localMac) and (r.tData(2)(111 downto 80) = localIp) then
-- Next state
v.state := SCAN_S;
end if;
-- Check OP-CODE = ARP Reply
elsif (r.tData(1)(47 downto 32) = ARP_REPLY_C) then
-- Check if the target IP + MAC address matches local address
if (r.tData(2)(47 downto 0) = localMac) and (r.tData(2)(79 downto 48) = localIp) then
-- Next state
v.state := SCAN_S;
end if;
end if;
end if;
----------------------------------------------------------------------
when SCAN_S =>
-- Check the tValid
if (arpReqMasters(r.ackCnt).tValid = '1') and (v.arpAckMasters(r.ackCnt).tValid = '0') then
------------------------
-- Checking for non-VLAN
------------------------
if (VLAN_G = false) then
-- Check if Source's IP address match request IP address
if arpReqMasters(r.ackCnt).tData(31 downto 0) = r.tData(1)(127 downto 96) then
-- ACK the request
v.arpReqSlaves(r.ackCnt).tReady := '1';
v.arpAckMasters(r.ackCnt).tValid := '1';
v.arpAckMasters(r.ackCnt).tData(47 downto 0) := r.tData(1)(95 downto 48); -- Source's MAC address
-- Reset the timer
v.arpTimers(r.ackCnt) := 0;
end if;
else
-- Check if Source's IP address match request IP address
if arpReqMasters(r.ackCnt).tData(31 downto 0) = r.tData(2)(31 downto 0) then
-- ACK the request
v.arpReqSlaves(r.ackCnt).tReady := '1';
v.arpAckMasters(r.ackCnt).tValid := '1';
v.arpAckMasters(r.ackCnt).tData(47 downto 0) := r.tData(1)(127 downto 80); -- Source's MAC address
-- Reset the timer
v.arpTimers(r.ackCnt) := 0;
end if;
-- Check if Source's IP address match request IP address
if arpReqMasters(r.ackCnt).tData(31 downto 0) = r.tData(1)(127 downto 96) then
-- ACK the request
v.arpReqSlaves(r.ackCnt).tReady := '1';
v.arpAckMasters(r.ackCnt).tValid := '1';
v.arpAckMasters(r.ackCnt).tData(47 downto 0) := r.tData(1)(95 downto 48); -- Source's MAC address
-- Reset the timer
v.arpTimers(r.ackCnt) := 0;
end if;
end if;
-- Check the counter
Expand All @@ -369,23 +291,19 @@ begin
-- Check if ready to move data
if v.txArpMaster.tValid = '0' then
-- Move data
v.txArpMaster.tValid := '1';
v.txArpMaster.tData(127 downto 0) := r.tData(r.cnt);
v.txArpMaster.tValid := '1';
v.txArpMaster.tData(127 downto 0) := r.tData(r.cnt);
-- Increment the counter
v.cnt := r.cnt + 1;
v.cnt := r.cnt + 1;
if r.cnt = 0 then
ssiSetUserSof(EMAC_AXIS_CONFIG_C, v.txArpMaster, '1');
elsif r.cnt = 2 then
-- Set the EOF flag
v.txArpMaster.tLast := '1';
v.txArpMaster.tLast := '1';
-- Set the tKeep
if (VLAN_G = false) then
v.txArpMaster.tKeep(15 downto 0) := x"03FF";
else
v.txArpMaster.tKeep(15 downto 0) := x"3FFF";
end if;
v.txArpMaster.tKeep(15 downto 0) := x"03FF";
-- Next state
v.state := IDLE_S;
v.state := IDLE_S;
end if;
end if;
----------------------------------------------------------------------
Expand Down
15 changes: 5 additions & 10 deletions ethernet/IpV4Engine/rtl/IpV4Engine.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ entity IpV4Engine is
CLK_FREQ_G : real := 156.25E+06; -- In units of Hz
TTL_G : slv(7 downto 0) := x"20";
IGMP_G : boolean := false;
IGMP_GRP_SIZE : positive := 1;
VLAN_G : boolean := false); -- true = VLAN support
IGMP_GRP_SIZE : positive := 1);
port (
-- Local Configurations
localMac : in slv(47 downto 0); -- big-Endian configuration
Expand Down Expand Up @@ -97,8 +96,7 @@ begin

U_EthFrameDeMux : entity surf.IpV4EngineDeMux
generic map (
TPD_G => TPD_G,
VLAN_G => VLAN_G)
TPD_G => TPD_G)
port map (
-- Local Configurations
localMac => localMac,
Expand Down Expand Up @@ -135,8 +133,7 @@ begin
generic map (
TPD_G => TPD_G,
CLIENT_SIZE_G => CLIENT_SIZE_G,
CLK_FREQ_G => CLK_FREQ_G,
VLAN_G => VLAN_G)
CLK_FREQ_G => CLK_FREQ_G)
port map (
-- Local Configurations
localMac => localMac,
Expand All @@ -159,8 +156,7 @@ begin
generic map (
TPD_G => TPD_G,
PROTOCOL_SIZE_G => PROTOCOL_SIZE_C,
PROTOCOL_G => PROTOCOL_C,
VLAN_G => VLAN_G)
PROTOCOL_G => PROTOCOL_C)
port map (
-- Interface to Ethernet Frame MUX/DEMUX
ibIpv4Master => ibIpv4Master,
Expand All @@ -179,8 +175,7 @@ begin
TPD_G => TPD_G,
PROTOCOL_SIZE_G => PROTOCOL_SIZE_C,
PROTOCOL_G => PROTOCOL_C,
TTL_G => TTL_G,
VLAN_G => VLAN_G)
TTL_G => TTL_G)
port map (
-- Local Configurations
localMac => localMac,
Expand Down
Loading

0 comments on commit 7395517

Please sign in to comment.