From: Michael Boehmer Date: Sun, 6 Nov 2022 20:18:58 +0000 (+0100) Subject: frame reception deadlock solved. X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=aad61eb7478fbe4cba921078d95e1dbebcaa3f61;p=trbnet.git frame reception deadlock solved. --- diff --git a/gbe_trb/base/gbe_frame_receiver.vhd b/gbe_trb/base/gbe_frame_receiver.vhd index 73b5b73..c212058 100644 --- a/gbe_trb/base/gbe_frame_receiver.vhd +++ b/gbe_trb/base/gbe_frame_receiver.vhd @@ -1,22 +1,11 @@ -LIBRARY IEEE; -USE IEEE.std_logic_1164.ALL; -USE IEEE.numeric_std.ALL; -USE IEEE.std_logic_UNSIGNED.ALL; +library IEEE; + use IEEE.std_logic_1164.all; + use IEEE.numeric_std.all; + use IEEE.std_logic_UNSIGNED.all; library work; -use work.trb_net_std.all; ---use work.trb_net_components.all; -use work.gbe_protocols.all; - ---******** --- here all frame checking has to be done, if the frame fits into protocol standards --- if so FR_FRAME_VALID_OUT is asserted after having received all bytes of a frame --- otherwise, after receiving all bytes, FR_FRAME_VALID_OUT keeps low and the fifo is cleared --- also a part of addresses assignment has to be done here - --- This entity receives an Ethernet frame, disassembles it and checks if the frame has to be processed. --- In case, decoded information from header is stored in FIFOs and next stage is informed about available --- data by FR_FRAME_VALID_OUT. + use work.trb_net_std.all; + use work.gbe_protocols.all; entity gbe_frame_receiver is port( @@ -60,571 +49,441 @@ entity gbe_frame_receiver is ); end gbe_frame_receiver; --- This entity receives frames from the MAC. The MAC will send the frames once they are received --- from SGMII core. Start of frame is marked by 'new_frame' signal. The incoming frame will be --- reviewed, and checked if it should be forwarded to the next level. --- First check is MAC address: only broadcast frames and frames with the board's MAC address are accepted. --- VLAN tagged frames are handled, but will be checked later. --- Second check is done inside gbe_type_validator: IPV4 UDP with correct port number are accepted, --- as well as ICMP inside IPv4. In addition, in gbe_protocols more accepted combinations can be defined. --- VLAN tagged frames are accepted, in case of tag == 0x0000, or if the VLAN tag is identical to one of the --- two stored ones. - --- BUG: MAC_RX_ERROR is not really used. Broken frames will not be discarded! - --- BUG: no protection against overflow of FIFOs! - architecture gbe_frame_receiver_arch of gbe_frame_receiver is - attribute syn_encoding : string; - type filter_states is (IDLE, REMOVE_DEST, REMOVE_SRC, REMOVE_TYPE, SAVE_FRAME, DROP_FRAME, - REMOVE_IP, REMOVE_UDP, DELAY, CLEANUP); - signal FILTER_CS, FILTER_NS : filter_states; - attribute syn_encoding of FILTER_CS : signal is "onehot"; - - signal fifo_wr_en : std_logic; - signal rx_bytes_ctr : std_logic_vector(15 downto 0); - signal frame_valid_q : std_logic; - signal delayed_frame_valid : std_logic; - signal delayed_frame_valid_q : std_logic; - - signal rec_fifo_empty : std_logic; - signal rec_fifo_full : std_logic; - - signal remove_ctr : unsigned(7 downto 0); - signal new_frame : std_logic; - signal new_frame_lock : std_logic := '0'; - signal saved_frame_type : std_logic_vector(15 downto 0); - signal saved_src_mac : std_logic_vector(47 downto 0); - signal saved_dest_mac : std_logic_vector(47 downto 0); - signal frame_type_valid : std_logic; - signal saved_proto : std_logic_vector(7 downto 0); - signal saved_src_ip : std_logic_vector(31 downto 0); - signal saved_dest_ip : std_logic_vector(31 downto 0); - signal saved_src_udp : std_logic_vector(15 downto 0); - signal saved_dest_udp : std_logic_vector(15 downto 0); - - signal error_frames_ctr : unsigned(15 downto 0); - signal dbg_rec_frames : unsigned(31 downto 0); - signal dbg_drp_frames : unsigned(31 downto 0); - signal mon_rec_bytes : unsigned(31 downto 0); - - signal state : std_logic_vector(3 downto 0); - - signal rx_data : std_logic_vector(8 downto 0); - signal fr_q : std_logic_vector(8 downto 0); - - signal fr_src_ip : std_logic_vector(31 downto 0); - signal fr_dest_ip : std_logic_vector(31 downto 0); - signal fr_dest_udp : std_logic_vector(15 downto 0); - signal fr_src_udp : std_logic_vector(15 downto 0); - signal fr_frame_size : std_logic_vector(15 downto 0); - signal fr_dest_mac : std_logic_vector(47 downto 0); - signal fr_src_mac : std_logic_vector(47 downto 0); - signal fr_ps : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); - - signal oob_register_0_int : std_logic_vector(31 downto 0); - signal oob_register_1_int : std_logic_vector(31 downto 0); - signal oob_register_2_int : std_logic_vector(31 downto 0); - signal oob_register_3_int : std_logic_vector(31 downto 0); - signal oob_write : std_logic; - - signal oob_select_x : std_logic; - signal oob_select : std_logic; - - signal proto_select : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); - - signal set_proto_x : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); - - signal fucking_vhdl : std_logic_vector(1 downto 0); + signal mac_rxd_q : std_logic_vector(7 downto 0); + signal mac_rx_en_q : std_logic; + signal mac_rx_er_q : std_logic; + signal mac_rx_eof_q : std_logic; + signal mac_rx_eof_qq : std_logic; + + type DECODE_STATES is (IDLE, STORE_HEADER, STORE_FRAME, IGNORE_FRAME, LAST_BYTE, WRITE_HDR, DELAY); + signal DECODE_CS, DECODE_NS: DECODE_STATES; + + signal decode_fsm : std_logic_vector(3 downto 0); + signal decode_ctr : unsigned(7 downto 0); + + signal is_my_mac_x : std_logic; + signal is_broadcast_x : std_logic; + signal is_arp_x : std_logic; + signal is_ipv4_x : std_logic; + signal is_version_x : std_logic; + signal is_udp_x : std_logic; + signal is_icmp_x : std_logic; + signal is_dhcp_x : std_logic; + signal is_sctrl_x : std_logic; + + signal stored_src_mac : std_logic_vector(47 downto 0); + signal stored_dst_mac : std_logic_vector(47 downto 0); + signal stored_ethertype : std_logic_vector(15 downto 0); + signal stored_version : std_logic_vector(7 downto 0); + signal stored_protocol : std_logic_vector(7 downto 0); + signal stored_src_ip : std_logic_vector(31 downto 0); + signal stored_dst_ip : std_logic_vector(31 downto 0); + signal stored_src_port : std_logic_vector(15 downto 0); + signal stored_dst_port : std_logic_vector(15 downto 0); + + signal fifo_pl_wr_x : std_logic; + signal fifo_pl_wr : std_logic; + signal fifo_hd_wr_x : std_logic; + signal fifo_hd_wr : std_logic; + signal fifo_hd_wr_q : std_logic; + signal fifo_hd_wr_qq : std_logic; + signal rst_bytes_x : std_logic; + signal rst_bytes : std_logic; + + signal protocol_select : std_logic_vector(7 downto 0); + + signal rx_bytes_ctr : unsigned(15 downto 0); + signal dbg_rec_frames : unsigned(31 downto 0); + signal dbg_drp_frames : unsigned(31 downto 0); + signal mon_rec_bytes : unsigned(31 downto 0); + + signal fr_src_ip : std_logic_vector(31 downto 0); + signal fr_dest_ip : std_logic_vector(31 downto 0); + signal fr_dest_udp : std_logic_vector(15 downto 0); + signal fr_src_udp : std_logic_vector(15 downto 0); + signal fr_frame_size : std_logic_vector(15 downto 0); + signal fr_dest_mac : std_logic_vector(47 downto 0); + signal fr_src_mac : std_logic_vector(47 downto 0); + signal fr_ps : std_logic_vector(7 downto 0); + signal fr_q : std_logic_vector(8 downto 0); + + signal oob_register_0_int : std_logic_vector(31 downto 0); + signal oob_register_1_int : std_logic_vector(31 downto 0); + signal oob_register_2_int : std_logic_vector(31 downto 0); + signal oob_register_3_int : std_logic_vector(31 downto 0); + signal oob_write : std_logic; + signal drop_frame_x : std_logic; + signal drop_frame : std_logic; begin - -- Debug lines - DEBUG_OUT(31 downto 28) <= state; - DEBUG_OUT(27 downto 16) <= (others => '0'); - - DEBUG_OUT(15) <= frame_valid_q; - DEBUG_OUT(14) <= fifo_wr_en; - DEBUG_OUT(13) <= frame_type_valid; - DEBUG_OUT(12) <= new_frame_lock; - DEBUG_OUT(11) <= new_frame; - DEBUG_OUT(10) <= MAC_RX_ER_IN; - DEBUG_OUT(9) <= MAC_RX_EOF_IN; - DEBUG_OUT(8) <= MAC_RX_EN_IN; - DEBUG_OUT(7 downto 0) <= MAC_RXD_IN; - - -- new_frame is asserted when first byte of the frame arrives - PROC_NEW_FRAME: process( CLK ) - begin - if( rising_edge(CLK) )then - if ( (LINK_OK_IN = '0') or (MAC_RX_EOF_IN = '1') ) then - new_frame <= '0'; - new_frame_lock <= '0'; - elsif( (new_frame_lock = '0') and (MAC_RX_EN_IN = '1') ) then - new_frame <= '1'; - new_frame_lock <= '1'; - else - new_frame <= '0'; - end if; - end if; - end process PROC_NEW_FRAME; + -- buffer incoming signals + mac_rxd_q <= MAC_RXD_IN when rising_edge(CLK); + mac_rx_en_q <= MAC_RX_EN_IN when rising_edge(CLK); + mac_rx_eof_q <= MAC_RX_EOF_IN when rising_edge(CLK); + mac_rx_er_q <= MAC_RX_ER_IN when rising_edge(CLK); + -- generate a "emergency stop" signal + mac_rx_eof_qq <= mac_rx_eof_q when rising_edge(CLK); - PROC_FILTER_FSM: process( CLK, RESET ) + -- FSM to decode the incoming stream + PROC_DECODE_FSM: process( CLK, RESET ) begin if ( RESET = '1' ) then - FILTER_CS <= IDLE; - oob_select <= '0'; + DECODE_CS <= IDLE; + fifo_pl_wr <= '0'; + fifo_hd_wr <= '0'; + drop_frame <= '0'; + rst_bytes <= '1'; elsif( rising_edge(CLK) ) then - FILTER_CS <= FILTER_NS; - oob_select <= oob_select_x; + DECODE_CS <= DECODE_NS; + fifo_pl_wr <= fifo_pl_wr_x; + fifo_hd_wr <= fifo_hd_wr_x; + drop_frame <= drop_frame_x; + rst_bytes <= rst_bytes_x; end if; - end process PROC_FILTER_FSM; + end process PROC_DECODE_FSM; - PROC_FILTER_TRANSITIONS : process( FILTER_CS, saved_frame_type, LINK_OK_IN, saved_proto, MY_MAC_IN, - saved_dest_mac, remove_ctr, new_frame, MAC_RX_EOF_IN, frame_type_valid, ALLOW_RX_IN) + PROC_DECODE_TRANSITIONS : process( DECODE_CS, MAC_RX_EN_IN, MAC_RX_EOF_IN, decode_ctr, mac_rx_eof_q, + is_my_mac_x, is_broadcast_x, is_arp_x, is_ipv4_x, is_udp_x, + is_version_x, is_sctrl_x, is_icmp_x ) begin - set_proto_x <= (others => '0'); - oob_select_x <= '0'; + fifo_pl_wr_x <= '0'; + fifo_hd_wr_x <= '0'; + drop_frame_x <= '0'; + rst_bytes_x <= '0'; - case FILTER_CS is + case DECODE_CS is when IDLE => - state <= x"1"; - if( (new_frame = '1') and (ALLOW_RX_IN = '1') and (LINK_OK_IN = '1') ) then - FILTER_NS <= REMOVE_DEST; - else - FILTER_NS <= IDLE; - end if; - - -- frames arrive without preamble! - when REMOVE_DEST => - state <= x"3"; - if( remove_ctr = x"03" ) then -- counter starts with a delay that's why only 3 - -- destination MAC address filtering here - if( (saved_dest_mac = MY_MAC_IN) or (saved_dest_mac = x"ffffffffffff") ) then -- must accept broadcasts for ARP - FILTER_NS <= REMOVE_SRC; + decode_fsm <= x"0"; + if( MAC_RX_EN_IN = '1' ) then + DECODE_NS <= STORE_HEADER; else - FILTER_NS <= DROP_FRAME; -- wrong MAC, were are done - -- could be done in REMOVE_SRC to gain some clock cycles + DECODE_NS <= IDLE; end if; - else - FILTER_NS <= REMOVE_DEST; - end if; - when REMOVE_SRC => - state <= x"4"; - if( remove_ctr = x"09" ) then - FILTER_NS <= REMOVE_TYPE; - else - FILTER_NS <= REMOVE_SRC; - end if; - - when REMOVE_TYPE => - state <= x"5"; - if( remove_ctr = x"0b" ) then - case saved_frame_type is - when x"0800" => - -- IPv4 frame, to be investigated - FILTER_NS <= REMOVE_IP; - when x"0806" => - -- ARP frame, to be stored - FILTER_NS <= DELAY; - set_proto_x(0) <= '1'; - -- NB: first two bytes of ARP frame are dropped silently - when others => - FILTER_NS <= DROP_FRAME; - end case; - else - FILTER_NS <= REMOVE_TYPE; - end if; - - when REMOVE_IP => - state <= x"c"; - if( remove_ctr = x"11" ) then - -- BUG: add check for 0x45 (IP version, header length) here. - -- Drop frames which do not comply with this! - case saved_proto is - when x"11" => - -- UDP, to be investigated - FILTER_NS <= REMOVE_UDP; - when x"01" => - -- ICMP, to be stored - FILTER_NS <= DELAY; - set_proto_x(4) <= '1'; - when others => - FILTER_NS <= DROP_FRAME; - end case; - else - FILTER_NS <= REMOVE_IP; - end if; + when STORE_HEADER => + decode_fsm <= x"1"; + DECODE_NS <= STORE_HEADER; + case decode_ctr is + + when x"05" => + -- drop frames which are not intended for us, and also not broadcast + if( (is_my_mac_x = '0') and (is_broadcast_x = '0') ) then + DECODE_NS <= IGNORE_FRAME; + end if; + + when x"0d" => + -- ARP frames are always accepted + if( (is_arp_x = '1') ) then + if( (mac_rx_eof_q = '0') ) then + -- payload available, store it + DECODE_NS <= STORE_FRAME; + fifo_pl_wr_x <= '1'; + else + -- empty payload, must never happen with ARP, so we drop it + DECODE_NS <= LAST_BYTE; + end if; + end if; + + when x"21" => + if( (is_ipv4_x = '1') and (is_version_x = '1') ) then + -- correct IPv4 header + if( (is_icmp_x = '1' ) ) then + -- ICMP + if( (mac_rx_eof_q = '0') ) then + -- payload available + DECODE_NS <= STORE_FRAME; + fifo_pl_wr_x <= '1'; + else + -- empty payload, must never happen with ICMP, so we drop it + DECODE_NS <= LAST_BYTE; + end if; + end if; + end if; + + when x"29" => + if( (is_ipv4_x = '1') and (is_version_x = '1') ) then + -- correct IPv4 header + if( (is_udp_x = '1') ) then + -- UDP header + if ( (is_dhcp_x = '1') or (is_sctrl_x = '1') ) then + -- DHCP, SCTRL + if( (mac_rx_eof_q = '0') ) then + -- payload available + DECODE_NS <= STORE_FRAME; + fifo_pl_wr_x <= '1'; + else + -- empty payload, store raw frame, check that later? + DECODE_NS <= LAST_BYTE; + fifo_hd_wr_x <= '1'; + end if; + end if; + end if; + end if; + + when x"2a" => + -- emergency output - frame could not be decoded + if( (mac_rx_eof_q = '0') ) then + -- frame reception still ongoing + DECODE_NS <= IGNORE_FRAME; + drop_frame_x <= '1'; + else + -- already last byte + DECODE_NS <= LAST_BYTE; + drop_frame_x <= '1'; + end if; + + when others => + null; + end case; - when REMOVE_UDP => - state <= x"d"; - if( remove_ctr = x"19" ) then - case saved_dest_udp is - when x"0044" => - -- DHCP frame, to be stored - FILTER_NS <= DELAY; - set_proto_x(1) <= '1'; - when x"6590" => - -- SCTRL frame, to be stored - FILTER_NS <= DELAY; - set_proto_x(2) <= '1'; - when others => - FILTER_NS <= DROP_FRAME; - oob_select_x <= '1'; - end case; - else - FILTER_NS <= REMOVE_UDP; + -- we need an emergency exit in case frame is "strange"! + if( (mac_rx_eof_qq = '1') ) then + DECODE_NS <= WRITE_HDR; end if; - when DELAY => - state <= x"6"; - FILTER_NS <= SAVE_FRAME; - - when SAVE_FRAME => - state <= x"7"; + when IGNORE_FRAME => + decode_fsm <= x"2"; if( MAC_RX_EOF_IN = '1' ) then - FILTER_NS <= CLEANUP; + DECODE_NS <= WRITE_HDR; else - FILTER_NS <= SAVE_FRAME; + DECODE_NS <= IGNORE_FRAME; end if; - when DROP_FRAME => - state <= x"8"; + when STORE_FRAME => + decode_fsm <= x"3"; + fifo_pl_wr_x <= '1'; if( MAC_RX_EOF_IN = '1' ) then - FILTER_NS <= CLEANUP; + DECODE_NS <= LAST_BYTE; + fifo_hd_wr_x <= '1'; else - FILTER_NS <= DROP_FRAME; + DECODE_NS <= STORE_FRAME; end if; - when CLEANUP => - state <= x"9"; - FILTER_NS <= IDLE; + -- deassert FIFO write signal, in case it is active + when LAST_BYTE => + decode_fsm <= x"4"; + DECODE_NS <= WRITE_HDR; + rst_bytes_x <= '1'; + + when WRITE_HDR => + decode_fsm <= x"5"; + DECODE_NS <= DELAY; + + when DELAY => + decode_fsm <= x"6"; + -- NEEDED for secret registers! + DECODE_NS <= IDLE; - when others => null; + when others => + decode_fsm <= x"f"; + DECODE_NS <= IDLE; end case; - end process PROC_FILTER_TRANSITIONS; + end process PROC_DECODE_TRANSITIONS; - -- protocol selection - PROC_PROTO_SEL: process( CLK, RESET ) + -- counter for decoding the byte stream + PROC_DECODE_CTR: process( CLK, RESET ) begin if ( RESET = '1' ) then - proto_select <= (others => '0'); + decode_ctr <= (others => '0'); elsif( rising_edge(CLK) ) then - for I in c_MAX_PROTOCOLS - 1 downto 0 loop - if ( set_proto_x(I) = '1' ) then - proto_select(I) <= '1'; - elsif( FILTER_CS = CLEANUP ) then - proto_select(I) <= '0'; - end if; - end loop; - end if; - end process PROC_PROTO_SEL; - - -- counts the bytes to be removed from the ethernet headers fields - PROC_REMOVE_CTR: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( (FILTER_CS = IDLE) or - ((FILTER_CS = REMOVE_TYPE) and (remove_ctr = x"0b")) ) then - remove_ctr <= (others => '1'); - elsif( (MAC_RX_EN_IN = '1') and (FILTER_CS /= IDLE) ) then - remove_ctr <= remove_ctr + 1; - end if; - end if; - end process PROC_REMOVE_CTR; - - -- saves the IP protocol - PROC_SAVED_PROTO: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( FILTER_CS = CLEANUP ) then - saved_proto <= (others => '0'); - elsif( (FILTER_CS = REMOVE_IP) and (remove_ctr = x"07") ) then - saved_proto <= MAC_RXD_IN; - end if; - end if; - end process PROC_SAVED_PROTO; - - -- saves the destination mac address of the incoming frame - PROC_SAVED_DEST_MAC: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( FILTER_CS = CLEANUP ) then - saved_dest_mac <= (others => '0'); - elsif( (FILTER_CS = IDLE) and (MAC_RX_EN_IN = '1') and (new_frame = '0') ) then - saved_dest_mac(7 downto 0) <= MAC_RXD_IN; - elsif( (FILTER_CS = IDLE) and (new_frame = '1') and (ALLOW_RX_IN = '1') ) then - saved_dest_mac(15 downto 8) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_DEST) and (remove_ctr = x"FF") ) then - saved_dest_mac(23 downto 16) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_DEST) and (remove_ctr = x"00") ) then - saved_dest_mac(31 downto 24) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_DEST) and (remove_ctr = x"01") ) then - saved_dest_mac(39 downto 32) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_DEST) and (remove_ctr = x"02") ) then - saved_dest_mac(47 downto 40) <= MAC_RXD_IN; - end if; - end if; - end process PROC_SAVED_DEST_MAC; - - -- saves the source mac address of the incoming frame - PROC_SAVED_SRC_MAC: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( FILTER_CS = CLEANUP ) then - saved_src_mac <= (others => '0'); - elsif( (FILTER_CS = REMOVE_DEST) and (remove_ctr = x"03") )then - saved_src_mac(7 downto 0) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_SRC) and (remove_ctr = x"04") ) then - saved_src_mac(15 downto 8) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_SRC) and (remove_ctr = x"05") ) then - saved_src_mac(23 downto 16) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_SRC) and (remove_ctr = x"06") ) then - saved_src_mac(31 downto 24) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_SRC) and (remove_ctr = x"07") ) then - saved_src_mac(39 downto 32) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_SRC) and (remove_ctr = x"08") ) then - saved_src_mac(47 downto 40) <= MAC_RXD_IN; - end if; - end if; - end process PROC_SAVED_SRC_MAC; - - -- saves the frame type of the incoming frame for futher check - PROC_SAVED_FRAME_TYPE: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( FILTER_CS = CLEANUP ) then - saved_frame_type <= (others => '0'); - elsif( (FILTER_CS = REMOVE_SRC) and (remove_ctr = x"09") ) then - saved_frame_type(15 downto 8) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_TYPE) and (remove_ctr = x"0a") ) then - saved_frame_type(7 downto 0) <= MAC_RXD_IN; + if( (DECODE_CS = STORE_HEADER) or (DECODE_CS = STORE_FRAME) ) then + decode_ctr <= decode_ctr + 1; + else + decode_ctr <= (others => '0'); end if; end if; - end process PROC_SAVED_FRAME_TYPE; + end process PROC_DECODE_CTR; - PROC_SAVED_SRC_IP: process( CLK ) + -- storing the relevant parts of headers for decision and further usage + PROC_STORE_INFO: process( CLK, RESET ) begin - if( rising_edge(CLK) ) then - if ( FILTER_CS = CLEANUP ) then - saved_src_ip <= (others => '0'); - elsif( (FILTER_CS = REMOVE_IP) and (remove_ctr = x"0a") ) then - saved_src_ip(7 downto 0) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_IP) and (remove_ctr = x"0b") ) then - saved_src_ip(15 downto 8) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_IP) and (remove_ctr = x"0c") ) then - saved_src_ip(23 downto 16) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_IP) and (remove_ctr = x"0d") ) then - saved_src_ip(31 downto 24) <= MAC_RXD_IN; + if ( RESET = '1' ) then + stored_src_mac <= (others => '0'); + stored_dst_mac <= (others => '0'); + stored_ethertype <= (others => '0'); + stored_version <= (others => '0'); + stored_protocol <= (others => '0'); + stored_src_ip <= (others => '0'); + stored_dst_ip <= (others => '0'); + stored_src_port <= (others => '0'); + stored_dst_port <= (others => '0'); + elsif( rising_edge(CLK) ) then + if( (MAC_RX_EN_IN = '1') and (mac_rx_en_q = '0') ) then + -- early bird + stored_dst_mac(7 downto 0) <= MAC_RXD_IN; end if; - end if; - end process PROC_SAVED_SRC_IP; - - PROC_SAVED_DEST_IP: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( FILTER_CS = CLEANUP ) then - saved_dest_ip <= (others => '0'); - elsif( (FILTER_CS = REMOVE_IP) and (remove_ctr = x"0e") ) then - saved_dest_ip(7 downto 0) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_IP) and (remove_ctr = x"0f") ) then - saved_dest_ip(15 downto 8) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_IP) and (remove_ctr = x"10") ) then - saved_dest_ip(23 downto 16) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_IP) and (remove_ctr = x"11") ) then - saved_dest_ip(31 downto 24) <= MAC_RXD_IN; + if( (mac_rx_en_q = '1') and (DECODE_CS = STORE_HEADER) ) then + case decode_ctr is + when x"00" => stored_dst_mac(15 downto 8) <= MAC_RXD_IN; + when x"01" => stored_dst_mac(23 downto 16) <= MAC_RXD_IN; + when x"02" => stored_dst_mac(31 downto 24) <= MAC_RXD_IN; + when x"03" => stored_dst_mac(39 downto 32) <= MAC_RXD_IN; + when x"04" => stored_dst_mac(47 downto 40) <= MAC_RXD_IN; + when x"05" => stored_src_mac(7 downto 0) <= MAC_RXD_IN; + when x"06" => stored_src_mac(15 downto 8) <= MAC_RXD_IN; + when x"07" => stored_src_mac(23 downto 16) <= MAC_RXD_IN; + when x"08" => stored_src_mac(31 downto 24) <= MAC_RXD_IN; + when x"09" => stored_src_mac(39 downto 32) <= MAC_RXD_IN; + when x"0a" => stored_src_mac(47 downto 40) <= MAC_RXD_IN; + when x"0b" => stored_ethertype(15 downto 8) <= MAC_RXD_IN; + when x"0c" => stored_ethertype(7 downto 0) <= MAC_RXD_IN; + when x"0d" => stored_version <= MAC_RXD_IN; + when x"16" => stored_protocol <= MAC_RXD_IN; + when x"19" => stored_src_ip(7 downto 0) <= MAC_RXD_IN; + when x"1a" => stored_src_ip(15 downto 8) <= MAC_RXD_IN; + when x"1b" => stored_src_ip(23 downto 16) <= MAC_RXD_IN; + when x"1c" => stored_src_ip(31 downto 24) <= MAC_RXD_IN; + when x"1d" => stored_dst_ip(7 downto 0) <= MAC_RXD_IN; + when x"1e" => stored_dst_ip(15 downto 8) <= MAC_RXD_IN; + when x"1f" => stored_dst_ip(23 downto 16) <= MAC_RXD_IN; + when x"20" => stored_dst_ip(31 downto 24) <= MAC_RXD_IN; + when x"21" => stored_src_port(15 downto 8) <= MAC_RXD_IN; + when x"22" => stored_src_port(7 downto 0) <= MAC_RXD_IN; + when x"23" => stored_dst_port(15 downto 8) <= MAC_RXD_IN; + when x"24" => stored_dst_port(7 downto 0) <= MAC_RXD_IN; + when others => null; + end case; end if; - end if; - end process PROC_SAVED_DEST_IP; - - PROC_SAVED_SRC_UDP: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( FILTER_CS = CLEANUP ) then - saved_src_udp <= (others => '0'); - elsif( (FILTER_CS = REMOVE_UDP) and (remove_ctr = x"12") ) then - saved_src_udp(15 downto 8) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_UDP) and (remove_ctr = x"13") ) then - saved_src_udp(7 downto 0) <= MAC_RXD_IN; +-- if( (DECODE_CS = WRITE_HDR) ) then + if( (DECODE_CS = DELAY) ) then + stored_src_mac <= (others => '0'); + stored_dst_mac <= (others => '0'); + stored_ethertype <= (others => '0'); + stored_version <= (others => '0'); + stored_protocol <= (others => '0'); + stored_src_ip <= (others => '0'); + stored_dst_ip <= (others => '0'); + stored_src_port <= (others => '0'); + stored_dst_port <= (others => '0'); end if; end if; - end process PROC_SAVED_SRC_UDP; - - PROC_SAVED_DEST_UDP: process( CLK ) + end process PROC_STORE_INFO; + + -- checks to filter frames, and distribute them to the correct handlers + is_my_mac_x <= '1' when (stored_dst_mac = MY_MAC_IN) else '0'; + is_broadcast_x <= '1' when (stored_dst_mac = x"ffffffffffff") else '0'; + is_arp_x <= '1' when (stored_ethertype = x"0806") else '0'; + is_ipv4_x <= '1' when (stored_ethertype = x"0800") else '0'; + is_version_x <= '1' when (stored_version = x"45") else '0'; + is_udp_x <= '1' when (stored_protocol = x"11") else '0'; + is_icmp_x <= '1' when (stored_protocol = x"01") else '0'; + is_dhcp_x <= '1' when (stored_dst_port = x"0044") else '0'; + is_sctrl_x <= '1' when (stored_dst_port = x"6590") else '0'; + + -- syncing signals + PROC_SYNC_SIGNALS: process( CLK ) begin if( rising_edge(CLK) ) then - if ( FILTER_CS = CLEANUP ) then - saved_dest_udp <= (others => '0'); - elsif( (FILTER_CS = REMOVE_UDP) and (remove_ctr = x"14") ) then - saved_dest_udp(15 downto 8) <= MAC_RXD_IN; - elsif( (FILTER_CS = REMOVE_UDP) and (remove_ctr = x"15") ) then - saved_dest_udp(7 downto 0) <= MAC_RXD_IN; - end if; + protocol_select(7) <= '0'; + protocol_select(6) <= '0'; + protocol_select(5) <= '0'; + protocol_select(4) <= is_icmp_x; + protocol_select(3) <= '0'; + protocol_select(2) <= is_sctrl_x; + protocol_select(1) <= is_dhcp_x; + protocol_select(0) <= is_arp_x; + fifo_hd_wr_q <= fifo_hd_wr; + fifo_hd_wr_qq <= fifo_hd_wr_q; end if; - end process PROC_SAVED_DEST_UDP; + end process PROC_SYNC_SIGNALS; - PROC_FRAME_TYPE_VALID: process( CLK, RESET ) + PROC_RX_BYTES_CTR: process( CLK, RESET ) begin if ( RESET = '1' ) then - frame_type_valid <= '0'; + rx_bytes_ctr <= (others => '0'); elsif( rising_edge(CLK) ) then - if ( FILTER_CS = SAVE_FRAME ) then - frame_type_valid <= '1'; - elsif( FILTER_CS = CLEANUP ) then - frame_type_valid <= '0'; + if( rst_bytes = '1' ) then + rx_bytes_ctr <= (others => '0'); + elsif( fifo_pl_wr = '1' ) then + rx_bytes_ctr <= rx_bytes_ctr + 1; end if; end if; - end process PROC_FRAME_TYPE_VALID; + end process PROC_RX_BYTES_CTR; + -- BUG: should be replaced by ring buffer + -- FIFO for payload storage THE_RECEIVE_FIFO: entity work.fifo_4096x9 port map( - Data => rx_data, + Data(8) => mac_rx_eof_q, + Data(7 downto 0) => mac_rxd_q, WrClock => CLK, RdClock => CLK, - WrEn => fifo_wr_en, + WrEn => fifo_pl_wr, RdEn => FR_RD_EN_IN, Reset => RESET, RPReset => RESET, Q => fr_q, - Empty => rec_fifo_empty, - Full => rec_fifo_full + Empty => open, -- BUG + Full => open -- BUG ); - -- killer ping - PROC_KILLER_PING: process( CLK ) - begin - if( rising_edge(CLK) ) then - if( (FILTER_CS = SAVE_FRAME) and - (saved_proto = x"01") and - (saved_frame_type = x"0800") and - (rx_bytes_ctr = x"001A") and - (rx_data(7 downto 0) = MY_TRBNET_ADDRESS_IN(7 downto 0)) and - (MAC_RXD_IN = MY_TRBNET_ADDRESS_IN(15 downto 8)) ) then - ISSUE_REBOOT_OUT <= '1'; - else - ISSUE_REBOOT_OUT <= '0'; - end if; - end if; - end process PROC_KILLER_PING; - - -- secret register - PROC_SECRET_FRAME: process( CLK ) - begin - if( rising_edge(CLK) ) then - if( (oob_select = '1') and - (saved_proto = x"11") and - (saved_frame_type = x"0800") and - (saved_dest_udp = x"d903") and - (saved_src_udp = x"2b67") ) then - oob_write <= '1'; - else - oob_write <= '0'; - end if; - end if; - end process PROC_SECRET_FRAME; - - PROC_SECRET_REGISTERS: process( CLK ) - begin - if( rising_edge(CLK) ) then - if( oob_write = '1' ) then - case saved_src_ip(1 downto 0) is - when b"00" => oob_register_0_int <= saved_dest_ip; - when b"01" => oob_register_1_int <= saved_dest_ip; - when b"10" => oob_register_2_int <= saved_dest_ip; - when others => oob_register_3_int <= saved_dest_ip; - end case; - end if; - end if; - end process PROC_SECRET_REGISTERS; - - OOB_REGISTER_0_OUT <= oob_register_0_int; - OOB_REGISTER_1_OUT <= oob_register_1_int; - OOB_REGISTER_2_OUT <= oob_register_2_int; - OOB_REGISTER_3_OUT <= oob_register_3_int; - - PROC_RX_FIFO_SYNC: process( CLK ) - begin - if rising_edge(CLK) then - - rx_data(8) <= MAC_RX_EOF_IN; - rx_data(7 downto 0) <= MAC_RXD_IN; - - if( MAC_RX_EN_IN = '1' ) then - if ( FILTER_CS = SAVE_FRAME ) then - fifo_wr_en <= '1'; - elsif( (FILTER_CS = DELAY) ) then - fifo_wr_en <= '1'; - else - fifo_wr_en <= '0'; - end if; - else - fifo_wr_en <= '0'; - end if; - - end if; - end process PROC_RX_FIFO_SYNC; - - THE_MACS_FIFO: entity work.fifo_512x72 + -- CAVEAT: writing to FIFO and reading needs some clock cycles? + -- Three is fine, two fails - data arrives late. + -- Happens when main control tries to read a frame directly when it was written. + + -- FIFO for header information + THE_FIRST_FIFO: entity work.fifo_512x72 port map( - Data(47 downto 0) => saved_src_mac, - Data(63 downto 48) => saved_src_udp, - Data(71 downto 64) => rx_bytes_ctr(7 downto 0), --(others => '0'), + Data(47 downto 0) => stored_src_mac, + Data(63 downto 48) => stored_src_port, + Data(71 downto 64) => std_logic_vector(rx_bytes_ctr(7 downto 0)), WrClock => CLK, RdClock => CLK, - WrEn => frame_valid_q, + WrEn => fifo_hd_wr_q, RdEn => FR_GET_FRAME_IN, Reset => RESET, RPReset => RESET, Q(47 downto 0) => fr_src_mac, Q(63 downto 48) => fr_src_udp, - Q(71 downto 64) => fr_frame_size(7 downto 0), --open, - Empty => open, - Full => open + Q(71 downto 64) => fr_frame_size(7 downto 0), + Empty => open, -- BUG + Full => open -- BUG ); - THE_MACD_FIFO: entity work.fifo_512x72 + -- FIFO for header information + THE_SECOND_FIFO: entity work.fifo_512x72 port map( - Data(47 downto 0) => saved_dest_mac, - Data(63 downto 48) => saved_dest_udp, - Data(69 downto 64) => proto_select, - Data(71 downto 70) => (others => '0'), + Data(47 downto 0) => stored_dst_mac, + Data(63 downto 48) => stored_dst_port, + Data(71 downto 64) => protocol_select, WrClock => CLK, RdClock => CLK, - WrEn => frame_valid_q, + WrEn => fifo_hd_wr_q, RdEn => FR_GET_FRAME_IN, Reset => RESET, RPReset => RESET, Q(47 downto 0) => fr_dest_mac, Q(63 downto 48) => fr_dest_udp, - Q(69 downto 64) => fr_ps, - Q(71 downto 70) => fucking_vhdl, --open, - Empty => open, - Full => open + Q(71 downto 64) => fr_ps, + Empty => open, -- BUG + Full => open -- BUG ); - THE_IP_FIFO: entity work.fifo_512x72 + -- FIFO for header information + THE_THIRD_FIFO: entity work.fifo_512x72 port map( - Data(31 downto 0) => saved_src_ip, - Data(63 downto 32) => saved_dest_ip, - Data(71 downto 64) => rx_bytes_ctr(15 downto 8), --saved_proto, + Data(31 downto 0) => stored_src_ip, + Data(63 downto 32) => stored_dst_ip, + Data(71 downto 64) => std_logic_vector(rx_bytes_ctr(15 downto 8)), WrClock => CLK, RdClock => CLK, - WrEn => frame_valid_q, + WrEn => fifo_hd_wr_q, RdEn => FR_GET_FRAME_IN, Reset => RESET, RPReset => RESET, Q(31 downto 0) => fr_src_ip, Q(63 downto 32) => fr_dest_ip, - Q(71 downto 64) => fr_frame_size(15 downto 8), --open, - Empty => open, - Full => open + Q(71 downto 64) => fr_frame_size(15 downto 8), + Empty => open, -- BUG + Full => open -- BUG ); - PROC_SYNC: process( CLK ) + PROC_OUT_SYNC: process( CLK ) begin if( rising_edge(CLK) ) then FR_SRC_IP_ADDRESS_OUT <= fr_src_ip; @@ -635,57 +494,89 @@ begin FR_SRC_UDP_PORT_OUT <= fr_src_udp; FR_FRAME_SIZE_OUT <= fr_frame_size; FR_Q_OUT <= fr_q; - FR_PS_OUT <= fr_ps; - -- - delayed_frame_valid <= MAC_RX_EOF_IN; - delayed_frame_valid_q <= delayed_frame_valid; + FR_PS_OUT <= fr_ps(c_MAX_PROTOCOLS - 1 downto 0); end if; - end process PROC_SYNC; + end process PROC_OUT_SYNC; + + -- signal for next stage: count up the "waiting frame" counter + FR_FRAME_VALID_OUT <= fifo_hd_wr_qq; + + -- Debug lines + DEBUG_OUT(31 downto 0) <= (others => '0'); - -- Signal used to store auxiliary FIFO data at the end of frame - PROC_FRAME_VALID: process( CLK ) + -- secret register + PROC_SECRET_FRAME: process( CLK ) begin if( rising_edge(CLK) ) then - if( (MAC_RX_EOF_IN = '1') and (ALLOW_RX_IN = '1') and (frame_type_valid = '1') ) then - frame_valid_q <= '1'; + if( (drop_frame = '1') and + (stored_protocol = x"11") and + (stored_ethertype = x"0800") and + (stored_dst_port = x"d903") and + (stored_src_port = x"2b67") ) then + oob_write <= '1'; else - frame_valid_q <= '0'; + oob_write <= '0'; end if; end if; - end process PROC_FRAME_VALID; + end process PROC_SECRET_FRAME; - PROC_RX_BYTES_CTR: process( CLK, RESET ) + PROC_SECRET_REGISTERS: process( CLK ) begin - if ( RESET = '1' ) then - rx_bytes_ctr <= x"0001"; - elsif( rising_edge(CLK) ) then - if( delayed_frame_valid_q = '1' ) then - rx_bytes_ctr <= x"0001"; - elsif( fifo_wr_en = '1' ) then - rx_bytes_ctr <= rx_bytes_ctr + 1; + if( rising_edge(CLK) ) then + if( oob_write = '1' ) then + case stored_src_ip(1 downto 0) is + when b"00" => oob_register_0_int <= stored_dst_ip; + when b"01" => oob_register_1_int <= stored_dst_ip; + when b"10" => oob_register_2_int <= stored_dst_ip; + when others => oob_register_3_int <= stored_dst_ip; + end case; end if; end if; - end process PROC_RX_BYTES_CTR; + end process PROC_SECRET_REGISTERS; + + OOB_REGISTER_0_OUT <= oob_register_0_int; + OOB_REGISTER_1_OUT <= oob_register_1_int; + OOB_REGISTER_2_OUT <= oob_register_2_int; + OOB_REGISTER_3_OUT <= oob_register_3_int; - -- Bullshit counter. Count condition is missing. - PROC_ERROR_FRAMES_CTR: process( CLK, RESET ) + -- killer ping +-- PROC_KILLER_PING: process( CLK ) +-- begin +-- if( rising_edge(CLK) ) then +-- if( (FILTER_CS = STORE_FRAME) and +-- (stored_protocol = x"01") and +-- (stored_ethertype = x"0800") and +-- (rx_bytes_ctr = x"001A") and +-- (rx_data(7 downto 0) = MY_TRBNET_ADDRESS_IN(7 downto 0)) and +-- (MAC_RXD_IN = MY_TRBNET_ADDRESS_IN(15 downto 8)) ) then +-- ISSUE_REBOOT_OUT <= '1'; +-- else +-- ISSUE_REBOOT_OUT <= '0'; +-- end if; +-- end if; +-- end process PROC_KILLER_PING; + + -- Counts received bytes as payload. + PROC_MON_REC_BYTES: process( CLK, RESET ) begin if ( RESET = '1' ) then - error_frames_ctr <= (others => '0'); + mon_rec_bytes <= (others => '0'); elsif( rising_edge(CLK) ) then - error_frames_ctr <= error_frames_ctr + 1; + if( fifo_pl_wr = '1' ) then + mon_rec_bytes <= mon_rec_bytes + 1; + end if; end if; - end process PROC_ERROR_FRAMES_CTR; - - FR_FRAME_VALID_OUT <= frame_valid_q when rising_edge(CLK); + end process PROC_MON_REC_BYTES; - -- Bullshit counter. Count condition is missing. + -- Counts accepted frames. PROC_RECEIVED_FRAMES_CTR: process( CLK, RESET ) begin if ( RESET = '1' ) then dbg_rec_frames <= (others => '0'); elsif( rising_edge(CLK) ) then - dbg_rec_frames <= dbg_rec_frames + 1; + if( (fifo_hd_wr = '1') ) then + dbg_rec_frames <= dbg_rec_frames + 1; + end if; end if; end process PROC_RECEIVED_FRAMES_CTR; @@ -695,7 +586,7 @@ begin if ( RESET = '1' ) then dbg_drp_frames <= (others => '0'); elsif( rising_edge(CLK) ) then - if( (FILTER_CS = DELAY) and (frame_type_valid = '0') ) then + if( (drop_frame = '1') ) then dbg_drp_frames <= dbg_drp_frames + 1; end if; end if; @@ -705,16 +596,4 @@ begin MONITOR_RX_FRAMES_OUT <= std_logic_vector(dbg_rec_frames); MONITOR_RX_BYTES_OUT <= std_logic_vector(mon_rec_bytes); - -- Counts received bytes as payload. - PROC_MON_REC_BYTES: process( CLK, RESET ) - begin - if ( RESET = '1' ) then - mon_rec_bytes <= (others => '0'); - elsif( rising_edge(CLK) ) then - if( fifo_wr_en = '1' ) then - mon_rec_bytes <= mon_rec_bytes + x"1"; - end if; - end if; - end process PROC_MON_REC_BYTES; - end gbe_frame_receiver_arch; diff --git a/gbe_trb/base/gbe_logic_wrapper.vhd b/gbe_trb/base/gbe_logic_wrapper.vhd index 8d8e075..deab0cf 100644 --- a/gbe_trb/base/gbe_logic_wrapper.vhd +++ b/gbe_trb/base/gbe_logic_wrapper.vhd @@ -148,8 +148,6 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is signal link_ok : std_logic; signal dhcp_done : std_logic; - - signal debug_fr : std_logic_vector(31 downto 0); signal make_reset : std_logic; signal frame_pause : std_logic_vector(31 downto 0); @@ -157,35 +155,31 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is signal fr_ps_int : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); signal debug_main : std_logic_vector(63 downto 0); + signal debug_fr : std_logic_vector(31 downto 0); + signal debug_rc : std_logic_vector(31 downto 0); begin --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- ----- DEBUG_OUT(31 downto 0) <= (others => '0'); --- -- TX --- DEBUG_OUT(31 downto 28) <= dbg_main(7 downto 4); --- DEBUG_OUT(27) <= '0'; --- DEBUG_OUT(26) <= mc_transmit_done; --- DEBUG_OUT(25) <= mc_transmit_ctrl; --- DEBUG_OUT(24) <= mc_wr_en; --- DEBUG_OUT(23 downto 20) <= dbg_main(15 downto 12); --- DEBUG_OUT(19 downto 16) <= dbg_main(11 downto 8); ----- DEBUG_OUT(23 downto 16) <= mc_data(7 downto 0); --- -- RX --- DEBUG_OUT(15) <= rc_loading_done; --- DEBUG_OUT(14) <= rc_frame_ready; --- DEBUG_OUT(13) <= rc_frame_proto(4); -- ICMP --- DEBUG_OUT(12) <= rc_frame_proto(1); -- DHCP --- DEBUG_OUT(11) <= rc_frame_proto(0); -- ARP --- DEBUG_OUT(10) <= fr_get_frame; --- DEBUG_OUT(9) <= fr_frame_valid; --- DEBUG_OUT(8) <= fr_rd_en; --- DEBUG_OUT(7 downto 0) <= rc_q(7 downto 0); +-- DEBUG_OUT(31 downto 0) <= (others => '0'); + DEBUG_OUT(31 downto 28) <= debug_fr(31 downto 28); -- frame receiver state + DEBUG_OUT(27 downto 24) <= debug_rc(3 downto 0); -- receive control state + DEBUG_OUT(23 downto 20) <= debug_main(23 downto 20); -- redirect state + DEBUG_OUT(19 downto 16) <= fr_ps_int(3 downto 0); --debug_main(27 downto 24); -- link state + DEBUG_OUT(15) <= rc_loading_done; + DEBUG_OUT(14) <= rc_frame_ready; + DEBUG_OUT(13) <= fr_ps_int(4); --rc_frame_proto(4); -- ICMP + DEBUG_OUT(12) <= fr_ps_int(1); --rc_frame_proto(1); -- DHCP + DEBUG_OUT(11) <= fr_ps_int(0); --rc_frame_proto(0); -- ARP + DEBUG_OUT(10) <= fr_get_frame; + DEBUG_OUT(9) <= fr_frame_valid; + DEBUG_OUT(8) <= fr_rd_en; + DEBUG_OUT(7 downto 0) <= rc_q(7 downto 0); --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- - DEBUG_OUT(31 downto 28) <= debug_fr(31 downto 28); - DEBUG_OUT(27 downto 0) <= debug_main(27 downto 0); +-- DEBUG_OUT(31 downto 28) <= debug_fr(31 downto 28); +-- DEBUG_OUT(27 downto 0) <= debug_main(27 downto 0); --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- @@ -318,7 +312,7 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is port map( RESET => RESET, CLK => CLK_125_IN, - LINK_OK_IN => LINK_ACTIVE_IN, --'1', -- BUG + LINK_OK_IN => LINK_ACTIVE_IN, WR_EN_IN => fc_wr_en, DATA_IN => fc_data, START_OF_DATA_IN => fc_sod, @@ -334,11 +328,11 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is SRC_IP_ADDRESS_IN => fc_src_ip, SRC_UDP_PORT_IN => fc_src_udp, FRAME_TYPE_IN => fc_type, - IHL_VERSION_IN => x"45", --fc_ihl_version, - TOS_IN => x"10", --fc_tos, + IHL_VERSION_IN => x"45", + TOS_IN => x"10", IDENTIFICATION_IN => fc_ident, FLAGS_OFFSET_IN => fc_flags_offset, - TTL_IN => x"ff", --fc_ttl, + TTL_IN => x"ff", PROTOCOL_IN => fc_protocol, FRAME_DELAY_IN => frame_pause, FT_TX_DATA_OUT => FT_TX_DATA_OUT, @@ -383,7 +377,7 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is -- statistics FRAMES_RECEIVED_OUT => rc_frames_rec_ctr, BYTES_RECEIVED_OUT => rc_bytes_rec, - DEBUG_OUT => open + DEBUG_OUT => debug_rc ); THE_FRAME_RECEIVER: entity work.gbe_frame_receiver @@ -425,7 +419,7 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is MONITOR_RX_FRAMES_OUT => MONITOR_RX_FRAMES_OUT, MONITOR_DROPPED_OUT => MONITOR_DROPPED_OUT, -- - DEBUG_OUT => debug_fr --open + DEBUG_OUT => debug_fr ); end architecture gbe_logic_wrapper_arch; diff --git a/gbe_trb/base/gbe_receive_control.vhd b/gbe_trb/base/gbe_receive_control.vhd index f364d75..1282b74 100644 --- a/gbe_trb/base/gbe_receive_control.vhd +++ b/gbe_trb/base/gbe_receive_control.vhd @@ -41,7 +41,7 @@ entity gbe_receive_control is FRAMES_RECEIVED_OUT : out std_logic_vector(31 downto 0); BYTES_RECEIVED_OUT : out std_logic_vector(31 downto 0); -- - DEBUG_OUT : out std_logic_vector(63 downto 0) + DEBUG_OUT : out std_logic_vector(31 downto 0) ); end gbe_receive_control; @@ -64,6 +64,9 @@ architecture gbe_receive_control_arch of gbe_receive_control is begin + DEBUG_OUT(31 downto 4) <= (others => '0'); + DEBUG_OUT(3 downto 0) <= state; + FR_RD_EN_OUT <= RC_RD_EN_IN; RC_Q_OUT <= RC_DATA_IN; RC_FRAME_SIZE_OUT <= FR_FRAME_SIZE_IN; @@ -101,6 +104,7 @@ begin load_next_state <= WAIT_ONE; when WAIT_ONE => + state <= x"4"; load_next_state <= READY; when READY => -- wait for reading out the whole frame diff --git a/gbe_trb/protocols/gbe_response_constructor_ARP.vhd b/gbe_trb/protocols/gbe_response_constructor_ARP.vhd index 1384dd3..5533b64 100644 --- a/gbe_trb/protocols/gbe_response_constructor_ARP.vhd +++ b/gbe_trb/protocols/gbe_response_constructor_ARP.vhd @@ -5,11 +5,16 @@ library ieee; library work; use work.gbe_protocols.all; +-- BUG: doesnt use FRAME_SIZE, but fixed length. + +-- BUG: check (length == 28) for correct request. + +-- BUG: check request type at all. + entity gbe_response_constructor_ARP is port ( CLK : in std_logic; -- system clock RESET : in std_logic; --- INTERFACE MY_MAC_IN : in std_logic_vector(47 downto 0); MY_IP_IN : in std_logic_vector(31 downto 0); PS_DATA_IN : in std_logic_vector(8 downto 0); @@ -24,7 +29,6 @@ entity gbe_response_constructor_ARP is PS_DEST_IP_ADDRESS_IN : in std_logic_vector(31 downto 0); PS_SRC_UDP_PORT_IN : in std_logic_vector(15 downto 0); PS_DEST_UDP_PORT_IN : in std_logic_vector(15 downto 0); --- TC_RD_EN_IN : in std_logic; TC_DATA_OUT : out std_logic_vector(8 downto 0); TC_FRAME_SIZE_OUT : out std_logic_vector(15 downto 0); @@ -37,8 +41,6 @@ entity gbe_response_constructor_ARP is TC_SRC_MAC_OUT : out std_logic_vector(47 downto 0); TC_SRC_IP_OUT : out std_logic_vector(31 downto 0); TC_SRC_UDP_OUT : out std_logic_vector(15 downto 0); --- END OF INTERFACE --- debug DEBUG_OUT : out std_logic_vector(63 downto 0) ); end gbe_response_constructor_ARP;