Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
845 Views

TSE and UDP packet offload

Hello, 

 

I'm using hardawre Nios II UDP Offload System with nios2-uClinux 

 

here is the soft configuration : 

 

 

--- Quote Start ---  

 

 

..... 

 

 

const char *addr[] = {  

"192.168.10.170",  

"192.168.10.16" 

};  

 

unsigned char the_dest_mac[6]={0x00,0x1A,0xa0,0x0d,0x09,0x19}; 

 

unsigned char my_src_mac[6]={0x00,0x07,0xED,0x0D,0x09,0x19}; 

 

 

 

 

void connectSocketUDP() 

 

...... 

 

if(( id_socket = socket(AF_INET, SOCK_DGRAM, 0)) == -1 ) 

{perror("----------------------------Server-socket() id_socket error lol!"); 

disConnectSocketUDP(); 

 

 

..... 

 

if(bind(id_socket, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == -1) /*! associate the id_socket to adress server*/ 

{ perror("----------------------------Server-bind() error lol!"); 

disConnectSocketUDP(); 

 

addr_len = sizeof(struct sockaddr); /*! get the length of struct sockaddr*/ 

 

isconnectedUDP=1; 

 

 

 

 

 

 

 

 

 

int main(int argc, char *argv[]) 

 

.... 

 

while(exit==0) 

 

if(isconnectedUDP == 0) 

{ connectSocketUDP(); 

else 

 

if(start == 0) 

{my_src_ip = inet_addr(addr[0]); 

the_dest_ip = inet_addr(addr[1]); 

 

insert_stat.udp_dst = MYPORT;  

// we fill out this insert_stat struct to pass into the  

insert_stat.udp_src = MYPORT;  

// payload inserter utility function 

insert_stat.ip_dst = the_dest_ip; 

insert_stat.ip_src = my_src_ip; 

insert_stat.mac_dst_hi = (the_dest_mac[0] << 24) | (the_dest_mac[1] << 16) | (the_dest_mac[2] << 8) | (the_dest_mac[3]); 

insert_stat.mac_dst_lo = (the_dest_mac[4] << 8) | (the_dest_mac[5]); 

insert_stat.mac_src_hi = (my_src_mac[0] << 24) | (my_src_mac[1] << 16) | (my_src_mac[2] << 8) | (my_src_mac[3]); 

insert_stat.mac_src_lo = (my_src_mac[4] << 8) | (my_src_mac[5]); 

 

if(start_udp_payload_inserter(inserter_bases[0], &insert_stat))  

{ continue; 

[/INDENT] if(start_packet_generator(generator_bases[0],(unsigned short)requested_packet_length, 0x33557799))  

{ continue; 

 

start = 1; 

[/INDENT]} sleep(10); 

stop_packet_generator(generator_bases[0]); 

stop_udp_payload_inserter(inserter_bases[0]); 

.... 

 

return 0; 

 

 

--- Quote End ---  

using a packet sniffer on a PC, i receive frames but not UDP (protocol 0x0919) !! 

 

--- Quote Start ---  

 

SOURCE : 09:19:00:07:ed:0d  

DESTINATION : 00:00:00_1a:a0:0d:09:19 (2 bytes inserts from API component) 

Protocol (Unknow) : 0x0919  

info : Ethernet II (data 800 bytes) 

 

 

--- Quote End ---  

the only difference with the example in altera wiki is the clock signal (60MHz for the GEN et INS component)  

 

 

Thanks for help
0 Kudos
5 Replies
Altera_Forum
Honored Contributor I
36 Views

the problem come from alignment_pad_inserter component, it inserts two pad bytes at the beginning 

is it necessary to use it?
Altera_Forum
Honored Contributor I
36 Views

It is necessary if you enable the pad option in the TSE settings in Sopc builder/QSys. This option makes life easier for some drivers. You can disable the option in the TSE and not use the alignment_pad_inserter component, but then you might run into trouble if you use the TSE with software.

Altera_Forum
Honored Contributor I
36 Views

the SOPC option to enable the pad is it : Align packet headers to 32bits? 

When i Enable the pad option using API component i have this frame  

 

 

--- Quote Start ---  

 

00:00:00:1a:a0:0d:09:19:08:00:45:00:03:3c:00:00:40:00:ff: 

11:6d:1b:aa:0a:a8:c0:10:0a:a8:c0:1f:f5:1f:f5:03:28:00:00: 

fd:31:03:24:1c:ba:97:d9:0e:d9:2e:77:52:cb:02:3f:d0:fe:7b: 

4f:97:59:9d:48:62:c8:dc:61:d0:ac:bf:8f:8d:34:25:47:1e:30: 

dc:39:3d:9d:ba:7d:2b:54:82:fa:e2:30:92:b1:bd:a9:89:8d:2c: 

 

--- Quote End ---  

 

 

if i keep this option enable and i remove API component i have the correct UDP frame  

 

 

--- Quote Start ---  

 

00:1a:a0:0d:09:19:08:00:45:00:03:3c:00:00:40:00:ff: 

11:6d:1b:aa:0a:a8:c0:10:0a:a8:c0:1f:f5:1f:f5:03:28:00:00: 

fd:31:03:24:1c:ba:97:d9:0e:d9:2e:77:52:cb:02:3f:d0:fe:7b: 

4f:97:59:9d:48:62:c8:dc:61:d0:ac:bf:8f:8d:34:25:47:1e:30: 

dc:39:3d:9d:ba:7d:2b:54:82:fa:e2:30:92:b1:bd:a9:89:8d:2c: 

 

--- Quote End ---  

Altera_Forum
Honored Contributor I
36 Views

Yes this is the right option. What you report is strange, it's almost as if you had two pad insertions. 

Could you put a Signaltap probe on the Avalon Stream going to the TSE, to check what's going in and how much pagding you have in front of the packet?
Altera_Forum
Honored Contributor I
36 Views

Hi, 

I have similar problem. I observe UDP data in wireshark with additional 2 byte data (00 00) at the beginning of payload inserted by Alignment pad inserter component. But when I remove this alignment pad inserter component, It's no more recognized as a UDP data. 

 

Is there any solution to this problem?