<< >>

General Control Functions

avb_status_t

AVB Status Report Type.

This type is returned by avb_periodic(), avb_srp_process_packet() and avb_1722_maap_process_packet(). and indicates any change in state of the AVB system.

Enum Values:

AVB_NO_STATUS
-1

No status to report.

AVB_SRP_OK
0

Status is ok (no change).

AVB_SRP_TALKER_ROUTE_FAILED

A route from one of the devices sources has failed to reach an intended listener (probably due to lack of bandwidth).

Use avb_srp_get_failed_stream() to find the streamID of the failed stream.

AVB_SRP_LISTENER_ROUTE_FAILED

A route from to one of the devices sinks has failed to reach from an intended talker (probably due to lack of bandwidth).

Use avb_srp_get_failed_stream() to find the streamID of the failed stream.

AVB_SRP_INDICATION

One of the SRP indications has occured.

The stream flags will be marked appropriately.

AVB_MAAP_ADDRESSES_RESERVED

Multicast addresses have been successfully been reserved after a called to avb_1722_maap_request_addresses().

Use avb_1722_maap_get_base_address() or avb_1722_maap_get_offset_address() to access the reserved addresses.

AVB_MAAP_ADDRESSES_LOST

Previously reserved multicast addresses have been lost.

After this event the control thread should disable any streams using MAAP addresses and recall avb_1722_maap_request_addresses()

AVB_1722_1_OK

1722.1 status ok

AVB_1722_1_ENTITY_ADDED

An entity has been added to the database by the discovery protocol.

AVB_1722_1_ENTITY_REMOVED

An entity has been removed from the database by the discovery protocol.

AVB_1722_1_CONNECT_TALKER

A connection management protocol message has been received indicating that a talker component should initiate a connection.

AVB_1722_1_DISCONNECT_TALKER

An SCM message indicates that a talker should release a connection.

AVB_1722_1_CONNECT_LISTENER

An SCM message indicates that a listener should initiate a connection.

AVB_1722_1_DISCONNECT_LISTENER

An SCM message indicates that a listener should release a connection.

void avb_init(chanend media_ctl[], chanend ?listener_ctl[], chanend ?talker_ctl[], chanend ?media_clock_ctl, chanend c_mac_rx, chanend c_mac_tx, chanend c_ptp)

Initialize the AVB control thread.

This function initializes the AVB system. It needs to be called in the main user control thread before any other AVB control call. The function takes chanends connected to other parts of the system and registers all of these components.

At this point the sinks, sources and media FIFOs are allocated numbers. The allocation is performed by registering numbers from 0 upwards working through the listener_ctl/talker_ctl/media_ctl arrays. Each component in this array may register several sink/sources/FIFOs. For example, if the listener_ctl array connects to two listener units each registering 3 sinks then the first unit will be allocated sink numbers 0,1,2 and the second 3,4,5.

Note that this call does not start any protocols communicating over the network (e.g. advertising talkers via IEEE 802.1Qat). That is deferred until the call to avb_start().

Parameters:
  • media_ctl – array of chanends connected to components that register/control media FIFOs
  • listener_ctl – array of chanends connected to components that register/control IEEE 1722 sinks
  • talker_ctl – array of chanends connected to components that register/control IEEE 1722 sources
  • media_clock_ctl – chanend connected to the media clock server
  • c_mac_rx – chanend connected to the ethernet server (RX)
  • c_mac_tx – chanend connected to the ethernet server (TX)
  • c_ptp – chanend connected to the ptp server
void avb_start(void)

Start any AVB protocol state machines.

This call starts any AVB protocol state machines running. It should be called after the ethernet link goes up.

avb_status_t avb_periodic(void)

Perform AVB periodic processing.

This function performs AVB periodic processing. It should be called from the main control thread at least once each ms. If it returns a state other than AVB_NO_STATUS then it should be called again immediately.

Returns:A status update from the periodic processing to indicate an event due to a timeout etc. (see avb_status_t)
void avb_get_control_packet(chanend c_rx, unsigned int buf[], unsigned int &nbytes)

Receives an 802.1Qat SRP packet or an IEEE P1722 MAAP packet.

This function receives an AVB control packet from the ethernet MAC. It is selectable so can be used in a select statement as a case.

Parameters:
  • c_rx – chanend connected to the ethernet component
  • buf – buffer to retrieve the packet into; buffer must have length at least MAX_AVB_CONTROL_PACKET_SZIE bytes
  • nbytes – a reference parameter that is filled with the length of the received packet
avb_status_t avb_process_control_packet(unsigned int buf[], int len, chanend c_tx)

Process an AVB control packet.

This function processes an ethernet packet and if it is a 802.1Qat or IEEE 1722 MAAP packet will handle it.

This function should always be called on the buffer filled by avb_get_control_packet().

Parameters:
  • buf – the incoming message buffer
  • len – the length (in bytes) of the incoming buffer
  • c_tx – chanend connected to the ethernet mac (TX)
Returns:

AVB_SRP_TALKER_ROUTE_FAILED if the incoming packet reports a talker routing failure (i.e. a failure in getting an outgoing stream to its intended listener). AVB_SRP_LISTENER_ROUTE_FAILED if the incoming packet reports a listener routing failure (i.e. a failure in listening to a stream). If the packet causes a previously asked for, or reserved, multicast address range to be no longer available, then AVB_MAAP_ADDRESSES_LOST is returned.

int avb_check_for_new_stream(unsigned streamId[2], unsigned &vlan, unsigned char addr[6])

Check whether a new incoming AVB stream has been detected.

This function checks whether a new IEEE 1722 stream has been detected. A new stream will be detected if an 802.1Qat talker advertise packet is received by the endpoint.

Each new stream seen will be reported once by this function. Internally the AVB system keeps a history up to the size AVB_STREAM_HISTORY_SIZE which has a default value of 128 and can be set in avb_conf.h

Parameters:
  • streamId – an array to be filled with the new stream id
  • vlan – a reference param to be filled with the vlan the detected stream is on
Returns:

a non-zero value if a new stream is detected, zero otherwise

void avb_set_legacy_mode(int mode)

Set the endpoint into “legacy mode”.

This function sets the endpoint into “legacy mode” to work with non-AVB switches for testing or demonstration purposes. In this mode the destination address of certain protocols change to become legacy (non-AVB) traffic and the PTP 802.1as protocol behaves in a slightly different manner. In this case:

  • The protocols are non-longer AVB standard so will not work with any other AVB hardware. They will only work with other endpoints set to this mode.
  • There is no longer any quality of service guarantee so audio may be disrupted. Furthermore the traffic from the endpoint may disrupt other non-AVB ethernet devices on the network.
Parameters:
  • mode – non-zero to set legacy mode, zero to unset it