Ethernet Products
Determine ramifications of Intel® Ethernet products and technologies
4811 Discussions

How to use two Ethernet ports on DE2-115

Altera_Forum
Honored Contributor II
1,476 Views

I have DE2-115. There are two Ethernet ports with PHYs. 

I want to use both in one project. I want to assign MAC and IP address for each port. 

 

I build a multi-port MAC system on DE2-115. 

I create sopc with TSE and NiosII. I turn off “internal FIFO” and set 4 ports in TSE setup. Add new SGDMA_RX/_TX for second port of TSE. 

I use uC/OS and NicheStack TCP/IP.  

 

What should I add or modify in NiosII project to run something like simple_socket_server, but with two IP addresses. 

 

I am newbie in Ethernet. May be I wrong and multi-port MAC is just a hub, and there is no way to assign own MAC and IP address for each port.  

If so what sopc I should build to use ports independently, but control them by one NiosII. May be I should run linux instead of uC/OS?
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
510 Views

i figured out about this staff. i share my experience in this problem. 

 

First of all I’ve add two TSE(+ dma and descriptor) in sopc for each PHY. 

https://www.alteraforum.com/forum/attachment.php?attachmentid=9111  

The second thing I’ve done was setting dhcp off in BSP editor. 

https://www.alteraforum.com/forum/attachment.php?attachmentid=9112  

Then I’ve made several modifications in software project (based on “Simple Socket Server RGMII”) 

 

1)In simple_socket_server.h define ip+mask+gw for every Ethernet port: 

2)In simple_socket_server.h add global variable int macn; 

#define IPADDR0 192# define IPADDR1 168# define IPADDR2 0# define IPADDR3 10 # define GWADDR0 192# define GWADDR1 168# define GWADDR2 0# define GWADDR3 1 # define MSKADDR0 255# define MSKADDR1 255# define MSKADDR2 255# define MSKADDR3 0 int macN; # define IPADDR0_1 192# define IPADDR1_1 168# define IPADDR2_1 1# define IPADDR3_1 11 # define GWADDR0_1 192# define GWADDR1_1 168# define GWADDR2_1 1# define GWADDR3_1 1 # define MSKADDR0_1 255# define MSKADDR1_1 255# define MSKADDR2_1 254# define MSKADDR3_1 0  

 

3) In network_utilities.c rewrite get_board_mac_addr() function 

error_t get_board_mac_addr(unsigned char mac_addr) { //mac: 00:07:ED:FF:8F:11; serial number: 040800017 //mac: 00:07:ED:FF:6B:C7; serial number: 111111111 mac_addr = 0x00; mac_addr = 0x07; mac_addr = 0xed; mac_addr = 0xff; mac_addr = macN? 0x6b : 0x8f; mac_addr = macN? 0xc7 : 0x11; printf(" Your Ethernet %d MAC address is %02x:%02x:%02x:%02x:%02x:%02x\n", macN, mac_addr, mac_addr, mac_addr, mac_addr, mac_addr, mac_addr); macN++; return 0; } 

 

 

4) In network_utilities.c in function get_ip_addr() add: 

printf(" for iface %d\n",p_dev->if_num); if(p_dev->if_num == 0){ IP4_ADDR(*ipaddr, IPADDR0, IPADDR1, IPADDR2, IPADDR3); IP4_ADDR(*gw, GWADDR0, GWADDR1, GWADDR2, GWADDR3); IP4_ADDR(*netmask, MSKADDR0, MSKADDR1, MSKADDR2, MSKADDR3); } else { IP4_ADDR(*ipaddr, IPADDR0_1, IPADDR1_1, IPADDR2_1, IPADDR3_1); IP4_ADDR(*gw, GWADDR0_1, GWADDR1_1, GWADDR2_1, GWADDR3_1); IP4_ADDR(*netmask, MSKADDR0_1, MSKADDR1_1, MSKADDR2_1, MSKADDR3_1); } 

 

5) In iniche_init.c in main add a default value for int macn

int main (int argc, char* argv, char* envp) { macN = 0; ***  

 

6) Add tse_my_system.h in project 

# ifdef ALT_INICHE # include "ipport.h"# endif # include "system.h"# include "altera_avalon_tse.h"# include "altera_avalon_tse_system_info.h" # define TSE_MY_SYSTEM 1 alt_tse_system_info tse_mac_device = {{ TSE_MAC_BASE, TSE_MAC_TRANSMIT_FIFO_DEPTH, TSE_MAC_RECEIVE_FIFO_DEPTH, TSE_MAC_USE_MDIO, TSE_MAC_ENABLE_MACLITE, TSE_MAC_MACLITE_GIGE, TSE_MAC_IS_MULTICHANNEL_MAC, TSE_MAC_NUMBER_OF_CHANNEL, TSE_MAC_MDIO_SHARED, TSE_MAC_NUMBER_OF_MAC_MDIO_SHARED, TSE_MAC_PCS, TSE_MAC_PCS_SGMII, SGDMA_TX_NAME, SGDMA_RX_NAME, SGDMA_RX_IRQ, TSE_EXT_DESC_MEM, DESCRIPTOR_MEMORY_BASE, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_PHY_AUTO_ADDRESS, &marvell_cfg_rgmii//0 },{ TSE_MAC_1_BASE, TSE_MAC_1_TRANSMIT_FIFO_DEPTH, TSE_MAC_1_RECEIVE_FIFO_DEPTH, TSE_MAC_1_USE_MDIO, TSE_MAC_1_ENABLE_MACLITE, TSE_MAC_1_MACLITE_GIGE, TSE_MAC_1_IS_MULTICHANNEL_MAC, TSE_MAC_1_NUMBER_OF_CHANNEL, TSE_MAC_1_MDIO_SHARED, TSE_MAC_1_NUMBER_OF_MAC_MDIO_SHARED, TSE_MAC_1_PCS, TSE_MAC_1_PCS_SGMII, SGDMA_TX_1_NAME, SGDMA_RX_1_NAME, SGDMA_RX_1_IRQ, TSE_EXT_DESC_MEM, DESCRIPTOR_MEMORY_1_BASE, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_NO_SHARED_FIFO, TSE_PHY_AUTO_ADDRESS, &marvell_cfg_rgmii//0 },{},{} };  

 

7) And that’s all!! 

InterNiche Portable TCP/IP, v3.1 Copyright 1996-2008 by InterNiche Technologies. All rights reserved. prep_tse_mac 0 Your Ethernet MAC 0 address is 00:07:ed:ff:8f:11 for iface 0 Static IP Address is 192.168.0.10 prep_tse_mac 1 Your Ethernet MAC 1 address is 00:07:ed:ff:6b:c7 for iface 1 Static IP Address is 192.168.1.11 prepped 2 interfaces, initializing...
0 Kudos
Altera_Forum
Honored Contributor II
510 Views

The one thing I can’t get how to determine what MAC we assign address in get_mac_addr().  

I use a flag variable int macn for determining. Do you know how do it better? 

For example I use p_dev->if_num to determine what iface I assign ip address. 

how do the same for mac address?
0 Kudos
Altera_Forum
Honored Contributor II
510 Views

A huge Thanks for your Feedback !!! 

I was also wondering how to do it ! 

 

can u still give any feedback to yout question ?  

Thanks a lot 

 

Jalayan
0 Kudos
Reply