The file ethernet_conf.h must be provided in the application source code. This file can set the following defines:
MAX_ETHERNET_PACKET_SIZE
This define sets the largest packet size in bytes that the ethernet mac will receive. The default it the largest possible ethernet packet size (1518 bytes). Setting this to a smaller value will save memory but restrict the type of packets you can receieve.
NUM_MII_RX_BUF
Number of incoming packets that will be buffered within the MAC.
NUM_MII_TX_BUF
Number of outgoing packets that will be buffered within the MAC.
MAX_ETHERNET_CLIENTS
The maximum number of clients that can be connected to the ethernet_server() function via the rx and tx channel arrays.
NUM_ETHERNET_PORTS
The number of ethernet ports to support. Maximum value is 2 in the current implementation.
ETHERNET_TX_HP_QUEUE
Define this constant to include the high priority transmit queueing mechanism. This enables frames which have an ethernet VLAN priority tag to be queued in a high priority queue, which in turn can be managed with the 802.1qav transmit traffic shaper.
ETHERNET_RX_HP_QUEUE
Define this constant to include high priority reception of ethernet VLAN priority tagged traffic. This traffic will be queued into a fast queue and delivered to the clients ahead of non-tagged traffic.
ETHERNET_TRAFFIC_SHAPER
If high priority transmit queueing is in use (see ETHERNET_TX_HP_QUEUE) then this enables the 802.1qav traffic shaping algorithm.
MII_RX_BUFSIZE_HIGH_PRIORITY
The number of quadlets (4 byte integers) of space in the high priority receive buffer. The buffer will actually be two full packets longer than this to avoid the need to be circular. This constant applies when the high priority receive queue is in use.
MII_RX_BUFSIZE_LOW_PRIORITY
The number of quadlets (4 byte integers) of space in the low priority receive buffer. The buffer will actually be two full packets longer than this to avoid the need to be circular. This constant applies when the high priority receive is in use.
MII_RX_BUFSIZE
The number of quadlets (4 byte integers) of space in the low priority receive buffer. The buffer will actually be two full packets longer than this to avoid the need to be circular. This constant applies when the high priority receive is not in use.
MII_TX_BUFSIZE
The number of quadlets (4 byte integers) of space in the low priority transmit buffer. The buffer will actually be two full packets longer than this to avoid the need to be circular.
MII_TX_BUFSIZE_HIGH_PRIORITY
The number of quadlets (4 byte integers) of space in the high priority transmit buffer. The buffer will actually be two full packets longer than this to avoid the need to be circular. This constant applies when the high priority receive is in use.
ENABLE_ETHERNET_SOURCE_ADDRESS_WRITE
By defining this preprocessor symbol, the source MAC address will be automatically filled in with the MAC address passed to the port during initialization.
DISABLE_ETHERNET_PORT_FORWARDING
By defining this preprocessor symbol, the forwarding of packets between ports, when there are multiple ports, is disabled. Traffic is only forwarded to the clients.
Every application is required to provide this function. It also needs to be prototyped (or defined as an inline definition) in the header file mac_custom_filter.h.
This function examines an ethernet packet and returns a filter number to allow different clients to obtain different types of packet. The function must run within 6us to allow 100Mbit filtering of packets.
Parameters: |
|
---|---|
Returns: | 0 if the packet is not wanted by the application or a number that can be registed by mac_set_custom_filter() by a client. Clients register a mask so the number is usually made up of a bit per unique client destination for the packet. |
Structure containing resources required for the MII ethernet interface.
This structure contains resources required to make up an MII interface. It consists of 7 ports and 2 clock blocks.
The clock blocks can be any available clock blocks and will be clocked of incoming rx/tx clock pins.
Structure Members:
MII RX Clock Block.
MII TX Clock Block.
MII RX clock wire.
MII RX error wire.
MII RX data wire.
MII RX data valid wire.
MII TX clock wire.
MII TX enable wire.
MII TX data wire.
A port that is not used for anything, used by the LLD for timing purposes.
Must be clocked of the reference clock
Structure containing resources required for the SMI ethernet phy interface.
This structure contains the resources required to communicate with an ethernet phy over smi.
Structure Members:
MDIO port.
MDC port.
This flag needs to be set if the MDIO port is shared with the phy reset line.
Retrieves the first MAC address stored in the OTP.
Parameters: |
|
---|
Retrieves the requested indexed MAC address stored in the OTP.
Parameters: |
|
---|
Retrieves a set of MAC addresses stored in the OTP.
Parameters: |
|
---|
Reset and initialize the ethernet phy.
This function resets the ethernet phy and initializes the MII resources. It should be called before calling ethernet_server(). This function is designed to work with SMSC phys
Parameters: |
|
---|
Reset and initialize two ethernet phys.
This function resets the ethernet phys and initializes the MII resources. It should be called before calling ethernet_server_two_port(). This function is designed to work with SMSC phys
Parameters: |
|
---|
Single MII port MAC/ethernet server.
This function provides both MII layer and MAC layer functionality. It runs in 5 threads and communicates to clients over the channel array parameters.
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
Parameters: |
|
---|
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:
(void) inuchar(connect_status); new_status = inuchar(c); (void) inuchar(c, 0); (void) inct(c);
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.
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
Parameters: |
|
---|
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:
(void) inuchar(connect_status); new_status = inuchar(c); (void) inuchar(c, 0); (void) inct(c);
This function receives a complete frame (i.e.
src/dest MAC address, type & payload), excluding pre-amble, SoF & CRC32 from the ethernet server.
This function is selectable i.e. it can be used as a case in a select e.g.
select { ... case mac_rx(...): break; ... }
Parameters: |
|
---|
This function receives a complete frame (i.e.
src/dest MAC address, type & payload), excluding pre-amble, SoF & CRC32. It also timestamps the arrival of the frame.
This function is selectable.
Parameters: |
|
---|
This function receives a complete frame (i.e.
src/dest MAC address, type & payload), excluding pre-amble, SoF & CRC32 from the ethernet server. In addition it will only fill the given buffer up to a specified length.
This function is selectable i.e. it can be used as a case in a select.
Parameters: |
|
---|
This function receives a complete frame (i.e.
src/dest MAC address, type & payload), excluding pre-amble, SoF & CRC32. It also timestamp the arrival of the frame. In addition it will only fill the given buffer up to a specified length.
This function is selectable.
Parameters: |
|
---|
Receive a packet starting at the second byte of a buffer.
This is useful when the contents of the packet should be aligned on a different boundary.
Parameters: |
|
---|
Setup whether a link should drop packets or block if the link is not ready.
NOTE: setting no dropped packets does not mean no packets will be dropped. If packets are not dropped at the mac layer, it will block the mii fifo. The Mii fifo could possibly overflow and frames for other links could be dropped.
Parameters: |
|
---|
Setup the size of the buffer queue within the mac attached to this link.
Parameters: |
|
---|
Setup the custom filter up on a link.
For each packet, the filter value is &-ed against the result of the mac_custom_filter function. If the result is non-zero then the packet is transmitted down the link.
Parameters: |
|
---|
Sends an ethernet frame.
Frame includes dest/src MAC address(s), type and payload.
Parameters: |
|
---|
Sends an ethernet frame and gets the timestamp of the send.
Frame includes dest/src MAC address(s), type and payload.
This is a blocking call and returns the actual time the frame is sent to PHY according to the XCore 100Mhz 32-bit timer on the core the ethernet server is running.
NOTE: This function will block until the packet is sent to PHY.
Parameters: |
|
---|
Sends an ethernet frame.
Frame includes dest/src MAC address(s), type and payload.
The packet should start at offset 2 in the buffer. This allows the packet to be constructed with alignment on a different boundary, allowing for more efficient construction where many word values are not naturally aligned on word boundaries.
Parameters: |
|
---|
Synonym | Function |
---|---|
ethernet_send_frame | ethernet_send_frame |
ethernet_send_frame_getTime | ethernet_send_frame_getTime |
ethernet_send_frame_offset2 | mac_tx_offset2 |
ethernet_get_my_mac_adrs | mac_get_macaddr |
Get the device MAC address.
This function gets the MAC address of the device (the address passed into the ethernet_server() function.
Parameters: |
|
---|---|
Returns: | zero on success and non-zero on failure. |