MII Crossover for ethernet_server_full_two_port

Technical questions regarding the XTC tools and programming with XMOS.
Jack
Member++
Posts: 24
Joined: Fri Sep 05, 2014 4:41 pm

MII Crossover for ethernet_server_full_two_port

Post by Jack »

Hello,
I am wondering if there is a chance to do a simple MII Crossover when using the ethernet_server_full_two_port. Below is the code of the ethernet_server_full_two_port function. If I just want to connect the mii_rx pins of MII1 with the mii_tx pins of MII2 and vice versa, what do I have to modify? I do not need to handle frames, therefor the ethernet server functions are commented out. Thanks for the help!

void ethernet_server_full_two_port(mii_interface_full_t &mii1,
mii_interface_full_t &mii2,
smi_interface_t &?smi1,
smi_interface_t &?smi2,
char mac_address[],
chanend rx[],
int num_rx,
chanend tx[],
int num_tx,
)
{
streaming chan c[2];
mii_init_full(mii1);
mii_init_full(mii2);
init_mii_mem();
par {
mii_rx_pins(mii1.p_mii_rxdv, mii1.p_mii_rxd, 0, c[0]);
mii_tx_pins(mii1.p_mii_txd, 0);
mii_rx_pins(mii2.p_mii_rxdv, mii2.p_mii_rxd, 1, c[1]);
mii_tx_pins(mii2.p_mii_txd, 1);
// ethernet_tx_server(mac_address, tx, 2, num_tx, smi1, null);
// ethernet_rx_server(rx, num_rx);
// ethernet_filter(mac_address, c);
}
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Hi Jack. Will you be using an external Ethernet PHY ? Please review the details of the Ethernet PHY that you will be using. Pretty sure that this feature is present on most current designs of the Ethernet PHY (auto mdi/mdx). From some past review, recall the use of the AR8035 Atheros Gigabit PHY for the XCORE-200 Explorer board. The AR8035 has this mdi/mdx support.

https://www.google.ca/search?q=ar8035&i ... jgTmhrCQCQ

Is this what you are trying to do ?

https://en.wikipedia.org/wiki/Medium-de ... _interface
Jack
Member++
Posts: 24
Joined: Fri Sep 05, 2014 4:41 pm

Post by Jack »

Hi mon2,

actually I am using 2 Ethernet Phys in the design. I do not want to have a loopback function within 1 port, I intend to forward traffic from Port 1 to Port 2 and from Port 2 to Port 1.

I already did this by using the ethernet server and forwarding each ingress frame from Port 1 to Port 2 and vice versa via by mac_rx/max_tx. -> Disadvantage: not really a fast throughput
I could just crossover connect the MII of the 2 Phys by wires and run one Phy in MAC mode (Reverse MII) without using the XMOS.

My question is, if there is a chance to just connect TX of MII (Port 1) with RX of MII (Port 2) and TX of MII (Port 2) with RX of MII (Port 1) using XMOS and e.g. building streaming channels between functions mii_rx_pins and mii_tx_pins? How should the code look like to connect these pins directly with function mii_rx_pins and mii_tx_pins?

Thanks again for the support.
srinie
XCore Addict
Posts: 158
Joined: Thu Mar 20, 2014 8:04 am

Post by srinie »

Hi,
You would 've to fiddle with and tweak the MII assembly part of the libraries.
Not sure to understand the throughput needs - AVB DC implementation utilizes this way, with respectable ingress and egress latencies. ds?
Direct wire connect (kind of snooper config) seems a reasonable way if that's the case.
Jack
Member++
Posts: 24
Joined: Fri Sep 05, 2014 4:41 pm

Post by Jack »

Hi mon2,

you are right, I think the AVB Daisy Chain utilizes that way but I still suffer in figuring out how.
I already investigated the module_ethernet files but I do not see any differences to the "standard" 2-port ethernet implementation. Any hint how the modification was done in the AVB DC to have this quick traffic forwarding?

Thanks a lot!
peter
XCore Addict
Posts: 230
Joined: Wed Mar 10, 2010 12:46 pm

Post by peter »

The way that the low-level ethernet components are are designed is that they work on a packet that is stored in memory. They examine packet buffers in memory to determine whether a packet is ready to be processed, so it is not possible to simply plug them together with channels. The channel in the interface is used by the receiver to notify the filter process that there is a new packet that needs filtering.

The AVB DC code base is probably the closest there is to an existing solution for what you want to do. An overview of the DC platform is here:

https://www.xmos.com/download/private/A ... f(3.3).pdf

It uses the MAC address to decide which packets to pass to the local application and which ones to forward to the other ethernet port. You should be able to get a simple forwarder by using the main from sw_avb_dc/app_daisy_chain/src/main.xc and not having any rx or tx channels to applications (https://github.com/xcore/sw_avb_dc/blob ... rc/main.xc)

The filtering will need to be tweaked to ensure that all valid ports are forwarded. That can be done in the mii_filter.xc file (sc_ethernet/module_ethernet/src/full/) by modifying the line 164 to set the filter result to 0xffffffff so that the packet will be forwarded to all ports (https://github.com/xcore/sc_ethernet/bl ... _filter.xc).
Jack
Member++
Posts: 24
Joined: Fri Sep 05, 2014 4:41 pm

Post by Jack »

Thanks Peter, this was exactly the information that I was looking for and it works fine.

Just another question to the update of the Ethernet MAC library (3.1.2). In version 3.1.2, there is no 2-port ethernet server version. Is there any chance to built up the daisy chain functionality (fast forwarding to the other port) by using 2 single ports? How can I do a fast forwarding in this case?
peter
XCore Addict
Posts: 230
Joined: Wed Mar 10, 2010 12:46 pm

Post by peter »

Unfortunately the dual-port version of the ethernet MAC was removed in the port to the version 3. There is no reason that you cannot implement your own version in a similar manner to the way it was done in the the 2.3.1 version of sc_ethernet - create two mii_ethernet_mac instances and a process to consume from both and forward the packets directly.