Commit c03f3b5b authored by Dimitris Lampridis's avatar Dimitris Lampridis

hdl: fixed couple of issues with endpoint RX filter.

  - ethertype was always checked, even when filter.ethertype was disabled
  - dst_mac was not checked when filter_udp was enabled

Also, make the filter "flat", so that the combinatorial path is shorter and we do not
duplicate code. It is up to user to enable the proper filter options.
parent 9ae07e0f
......@@ -59,7 +59,8 @@ architecture arch of mt_rmq_endpoint_rx is
constant c_addr_dst_ip : integer := 4;
constant c_addr_dst_port : integer := 5;
constant c_BROADCAST_IP : std_logic_vector(31 downto 0) := X"FFFFFFFF";
constant c_BROADCAST_IP : std_logic_vector(31 downto 0) := (others => '1');
constant c_BROADCAST_MAC : std_logic_vector(47 downto 0) := (others => '1');
signal config : t_rmq_ep_rx_config;
......@@ -143,58 +144,53 @@ begin -- arch
if rst_n_i = '0' then
match <= '0';
else
match_dst_port <= '1';
match_dst_ip <= '1';
match_ethertype <= '1';
match_dst_mac <= '1';
match_udp <= '1';
match_raw <= '1';
match_ethertype <= '1';
match_dst_mac <= '1';
match_dst_ip <= '1';
match_dst_port <= '1';
if(config.filter_udp = '1') then
if config.filter_udp = '1' then
match_udp <= header_i.is_udp;
end if;
if(header_i.ethertype /= x"0800") then
match_ethertype <= '0';
end if;
if config.filter_raw = '1' then
match_raw <= header_i.is_raw;
end if;
if (config.filter_dst_port = '1') then
if (config.dst_port /= header_i.dst_port) then
match_dst_port <= '0';
end if;
if config.filter_ethertype = '1' then
if (header_i.is_udp = '1' and header_i.ethertype /= x"0800") or
(header_i.is_raw = '1' and header_i.ethertype /= config.ethertype) then
match_ethertype <= '0';
end if;
end if;
if config.filter_dst_ip = '1' and header_i.dst_ip /= c_BROADCAST_IP then
if (config.dst_ip /= header_i.dst_ip) then
match_dst_ip <= '0';
end if;
if config.filter_dst_mac = '1' then
if header_i.dst_mac /= c_BROADCAST_MAC and header_i.dst_mac /= config.dst_mac then
match_dst_mac <= '0';
end if;
end if;
if (config.filter_raw = '1') then
match_raw <= header_i.is_raw;
if(header_i.ethertype /= config.ethertype) then
match_ethertype <= '0';
if config.filter_dst_ip = '1' then
if header_i.dst_ip /= c_BROADCAST_IP and config.dst_ip /= header_i.dst_ip then
match_dst_ip <= '0';
end if;
end if;
if config.filter_dst_mac = '1' then
if (header_i.dst_mac /= config.dst_mac) then
match_dst_mac <= '0';
end if;
if config.filter_dst_port = '1' then
if config.dst_port /= header_i.dst_port then
match_dst_port <= '0';
end if;
end if;
match <= match_dst_mac and match_dst_ip and match_ethertype and
match_dst_port and match_udp and match_raw and config.enable;
end if;
end if;
end process;
end process p_filter_packets;
drop <= header_valid_i and not match and framer_snk_i.last;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment