Dual MII port MAC/ethernet server Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
aritec
Member
Posts: 14
Joined: Thu Sep 15, 2011 7:19 pm

Dual MII port MAC/ethernet server

Post by aritec »

Hi
a long time ago there was a function ethernet_server_two_port() provided by module_ethernet, to have 2 ethernet ports interacting as a kind of hub/switch.

Code: Select all

/** Dual MII port MAC/ethernet server.
 *
 *  This function provides both MII layer and MAC layer functionality.
 *  It runs in 7 threads and communicates to clients over the channel array
 *  parameters.
 *
 *  \param mii1                 The first mii interface resources that the
 *                              server will connect to
 *  \param mii2                 The second mii interface resources that the
 *                              server will connect to
 *  \param mac_address          The mac_address the server will use.
 *                              This should be a two-word array that stores the
 *                              6-byte macaddr in a little endian manner (so
 *                              reinterpreting the array as a char array is as
 *                              one would expect)
 *  \param rx                   An array of chanends to connect to clients of
 *                              the server who wish to receive packets.
 *  \param num_rx               The number of clients connected to the rx array
 *  \param tx                   An array of chanends to connect to clients of
 *                              the server who wish to transmit packets.
 *  \param num_tx               The number of clients connected to the txx array
 *  \param smi1                 An optional parameter of resources to connect
 *                              to the first PHY (via SMI) to check when the link
 *                              is up.
 *  \param smi2                 An optional parameter of resources to connect
 *                              to a second PHY (via SMI) to check when the link
 *                              is up.
 *  \param connect_status       An optional parameter of a channel that is
 *                              signalled when the link goes up or down
 *                              (requires the smi parameter to be supplied).
 *
 * The clients connected via the rx/tx channels can communicate with the
 * server using the APIs found in ethernet_rx_client.h and ethernet_tx_client.h
 *
 * If the smi and connect_status parameters are supplied then the
 * connect_status channel will output when the link goes up or down.
 * The channel will output a zero byte, followed by the status (1 for up,
 * 0 for down), followed by a zero byte, followed by an END control token.,
 *
 * The following code snippet is an example of how to receive this update:
 *
 * \verbatim
 *    (void) inuchar(connect_status);
 *    new_status = inuchar(c);
 *    (void) inuchar(c, 0);
 *    (void) inct(c);
 * \endverbatim
 **/
void ethernet_server_two_port(mii_interface_t &mii1,
                              mii_interface_t &mii2,
                              chanend rx[],
                              int num_rx,
                              chanend tx[],
                              int num_tx,
                              smi_interface_t &?smi1,
                              smi_interface_t &?smi2,
                              chanend ?connect_status,
                              CLIENT_INTERFACE(configInterface, iConfigFilter),
                              CLIENT_INTERFACE(configInterface, iConfigRx),
                              CLIENT_INTERFACE(configInterface, iConfigTx));

Can I do something similar with the newest "lib_ethernet"?

Thanks
Armin


View Solution
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Yes, it is possible. You can extend the real time single port MAC to support two MII interfaces. It will take some work; I did it for the company I work for so I doubt I will be able to post much about it. I referred to the old dual MII port MAC and made the necessary changes to the new lib ethernet so it would work with multiple interfaces. It's not terrible, mostly just changing the state information to arrays of variables/structures (one per interface) and adding support for interface number (0, 1, or all interfaces) to the send function, e.g.
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

There's some trickiness with parallel access to shared resources but the existing code should show you basically how you can work around that.
aritec
Member
Posts: 14
Joined: Thu Sep 15, 2011 7:19 pm

Post by aritec »

Thank's akp, so i follow the old sc_ethernet code and will come to an end. I did dig into this code 8 years ago.
By the way - is it worth the trouble just to have the newest tcp/ip stack?
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

I don't think it's really worth the effort. I needed it since I use the newer lib_tsn (which I also updated to properly support two ports) but if all you're using is TCP/IP and it works OK with the older code, I would stick with that. Of course I use the newer lib_xtcp as well since I made the updates.
aritec
Member
Posts: 14
Joined: Thu Sep 15, 2011 7:19 pm

Post by aritec »

Is it worth for using the new lib_xtcp?
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Well, the new lib_xtcp has its own problems you'll need to fix. XMOS doesn't really maintain it so far as I can tell. I think you'll have to decide if it has a feature you need so much it's worth your trouble to get it working. Personally I doubt that's the case, but I can't speak for what you need.
aritec
Member
Posts: 14
Joined: Thu Sep 15, 2011 7:19 pm

Post by aritec »

Thanks, I think I stick to the old module, cause I just need multiple tcp connection to the same port number. Should also work with the old module.
Post Reply