spinnaker_tools 3.4.0
SpiNNaker API, sark, sc&mp, bmp firmware and build tools
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
scamp-p2p.c File Reference

P2P packet handling for SC&MP. More...

#include "spinnaker.h"
#include "sark.h"
#include "scamp.h"
#include "spinn_net.h"

Data Structures

struct  rx_desc_t
 P2P channel state structure: receiver. More...
 
struct  tx_desc_t
 P2P channel state structure: transmitter. More...
 

Macros

#define P2P_NUM_STR   8
 Number of streams.
 

Enumerations

enum  p2p_tx_state {
  TX_IDLE = 0 , TX_OPEN_REQ = 1 , TX_OPEN = 2 , TX_RETRY = 3 ,
  TX_CLOSE = 4
}
 Possible states in P2P protocol: transmitter side.
 
enum  p2p_rx_state { RX_IDLE = 0 , RX_OPEN = 1 , RX_CLOSE_REQ = 2 }
 Possible states in P2P protocol: receiver side.
 
enum  p2p_stats_indices {
  DATA_TO = 0 , ACK_TO = 1 , OPEN_TO = 2 , CLOSE_TO = 3 ,
  P2P_SENDS = 4 , P2P_OPENS = 5 , P2P_BUSY1 = 6 , P2P_BUSY2 = 7 ,
  P2P_REJECTS = 8 , TCOUNT = 9 , OPEN_DUP = 10 , TX_FAIL = 11 ,
  OPEN_EVENT = 12 , P2P_OPEN_N = 16
}
 Indices into p2p_stats. More...
 

Functions

void desc_init (void)
 initialise TX and RX descriptors
 
static void p2p_send_data (uint data, uint addr)
 Send a P2P data packet. Delegates to pkt_tx()
 
static uint p2p_send_ctl (uint ctrl, uint addr, uint data)
 Send a P2P control packet. Delegates to pkt_tx()
 
void p2p_data_ack (uint data, uint srce)
 Received ACK from receiver. Cancel ack timeout and update tx_desc.
 
void p2p_close_req (uint data, uint srce)
 Received CLOSE_REQ from receiver.
 
void p2p_ack_timeout (uint txd, uint a2)
 Timed out waiting for data ACK from receiver.
 
void p2p_open_timeout (uint a, uint b)
 Timeout handler during channel opening phase.
 
uint p2p_send_msg (uint addr, sdp_msg_t *msg)
 Send an SDP message to another SCAMP instance.
 
void p2p_data_timeout (uint rxd, uint a2)
 Timed out waiting for "seq_len" data packets. Send P2P_DATA_ACK with current mask and restart timeout.
 
void p2p_open_ack (uint data, uint srce)
 Received OPEN_ACK packet.
 
void p2p_open_req (uint data, uint addr)
 Another SCAMP has asked for an open channel.
 
void p2p_close_timeout (uint rxd, uint rid)
 Timed out waiting for CLOSE_ACK. Repeat P2P_CLOSE_REQ a few times then give up.
 
void p2p_close_ack (uint data, uint srce)
 Received an acknowledge that a channel has been closed.
 
void p2p_rcv_data (uint data, uint addr)
 Receive data on channel.
 
uint p2p_send_ping (uint addr, uint link)
 
void p2p_ping (uint data, uint addr)
 
void p2p_req_count (uint addr, uint app_id, uint state)
 
uint n_cores_in_state (uint app_id, uint state)
 
void p2p_count (uint data, uint addr)
 
void p2p_count_resp (uint data, uint addr)
 
void p2p_rcv_ctrl (uint data, uint addr)
 Received P2P control packet.
 

Variables

tx_desc_t tx_desc
 Transmitter state descriptor. Transmission is a foreground task.
 
rx_desc_t rx_desc_table [P2P_NUM_STR]
 Receiver state descriptors. Reception is a background task.
 
uint p2p_stats [32]
 Peer-to-peer statistics table.
 
const uint open_req_retry = 16
 Number of retries for an open request.
 
const uint open_ack_retry = 4
 Number of retries for an open acknowledge.
 
const uint data_ack_retry = 4
 Number of retries for a data acknowledge.
 
const uint close_req_retry = 4
 Number of retries for a close request.
 
const uint open_ack_time = 250
 Timeout on open acknowledge, in μs.
 
const uint data_ack_time = 3000
 Timeout on data acknowledge, in μs.
 
const uint data_time = 500
 Timeout on data, in μs.
 
const uint close_ack_time = 250
 Timeout on close acknowledge, in μs.
 
volatile uint pp_ping_count [NUM_LINKS]
 Reserved for performing P2P pings.
 
volatile uint p2p_count_result
 Reserved for performing a P2P count operation.
 
volatile uint p2p_count_n_results
 
uint p2p_count_id
 

Detailed Description

P2P packet handling for SC&MP.

Author
Steve Temple, APT Group, School of Computer Science

Data Structure Documentation

◆ rx_desc_t

struct rx_desc_t

P2P channel state structure: receiver.

Data Fields
uchar state
uchar seq_len
uchar done
uchar tid
uchar tcount
uchar ctrl
uchar phase
ushort mask
ushort new_mask
uint srce
uchar * base
uchar * limit
sdp_msg_t * msg
event_t * event pre-allocated reused event
uint event_id

◆ tx_desc_t

struct tx_desc_t

P2P channel state structure: transmitter.

Data Fields
uchar seq_len
uchar seq
uchar odd
uchar done
uchar state
uchar rid
uchar tid
uchar tcount
uchar rc
uchar phase
volatile uchar ack
ushort mask
uint dest
uchar * base
uchar * limit
event_t * event pre-allocated reused event
uint event_id

Enumeration Type Documentation

◆ p2p_stats_indices

Indices into p2p_stats.

Enumerator
DATA_TO 

Timeouts waiting for data.

ACK_TO 

Timeouts waiting for acknowledgements.

OPEN_TO 

Timeouts during channel open (request)

CLOSE_TO 

Timeouts during channel close.

P2P_SENDS 

Number of sends.

P2P_OPENS 

Number of opens.

P2P_BUSY1 

Number of times busy due to no more streams.

P2P_BUSY2 

Number of times busy due to no more SDP buffers.

P2P_REJECTS 

Number of times message was rejected.

TCOUNT 

Most recent value of tx_desc_t::tcount.

OPEN_DUP 

Number of times a channel was already open.

TX_FAIL 

Number of transmission failures.

OPEN_EVENT 

Timeouts during open (timeout handler)

P2P_OPEN_N 

Base for array of counters for tracking channel usage.

Function Documentation

◆ p2p_send_data()

static void p2p_send_data ( uint  data,
uint  addr 
)
static

Send a P2P data packet. Delegates to pkt_tx()

Parameters
[in]dataPayload of the message
[in]addrWhere to send to

◆ p2p_send_ctl()

static uint p2p_send_ctl ( uint  ctrl,
uint  addr,
uint  data 
)
static

Send a P2P control packet. Delegates to pkt_tx()

Parameters
[in]ctrlWhat message to send
[in]addrWhere to send to
[in]dataPayload of the message

◆ p2p_data_ack()

void p2p_data_ack ( uint  data,
uint  srce 
)

Received ACK from receiver. Cancel ack timeout and update tx_desc.

+-------+-----+-+---+-+---------+---------------+---------------+
| | | | |P| | |
Data | Sum | 001 |1| 00|H| TID | Ack mask |
Ack | | | | |A| | |
+-------+-----+-+---+-+---------+---------------+---------------+
Parameters
[in]dataThe payload from the packet
[in]srceThe sender address (lower 16 bits) from the packet

◆ p2p_close_req()

void p2p_close_req ( uint  data,
uint  srce 
)

Received CLOSE_REQ from receiver.

If TX_OPEN then tidy up tx_desc. In any case, send a CLOSE_ACK back to receiver.

Parameters
[in]dataThe payload from the packet
[in]srceThe sender address (lower 16 bits) from the packet

◆ p2p_ack_timeout()

void p2p_ack_timeout ( uint  txd,
uint  a2 
)

Timed out waiting for data ACK from receiver.

This suggests that the receiver has died so close the connection.

Parameters
[out]txdTransmit descriptor
[in]a2ignored

◆ p2p_open_timeout()

void p2p_open_timeout ( uint  a,
uint  b 
)

Timeout handler during channel opening phase.

Parameters
[out]apointer to transmit descriptor
[in]bcode to write to tx_desc_t::ack on timeout

◆ p2p_send_msg()

uint p2p_send_msg ( uint  addr,
sdp_msg_t msg 
)

Send an SDP message to another SCAMP instance.

Parameters
[in]addrthe P2P address of the SCAMP to send to
[in]msgthe message to send, presumably for either the target SCAMP or a core that that SCAMP can deliver to
Returns
result code saying whether message sending was successful

◆ p2p_data_timeout()

void p2p_data_timeout ( uint  rxd,
uint  a2 
)

Timed out waiting for "seq_len" data packets. Send P2P_DATA_ACK with current mask and restart timeout.

Parameters
[in,out]rxdchannel receiver descriptor
[in]a2ignored

◆ p2p_open_ack()

void p2p_open_ack ( uint  data,
uint  srce 
)

Received OPEN_ACK packet.

If RX_BUSY do nothing so that timeout will expire (and we keep trying). Otherwise update tx_desc and cancel timeout.

Parameters
[in]dataThe payload from the packet
[in]srceThe sender address (lower 16 bits) from the packet

◆ p2p_open_req()

void p2p_open_req ( uint  data,
uint  addr 
)

Another SCAMP has asked for an open channel.

Parameters
[in]dataThe payload from the packet
[in]addrThe sender address (lower 16 bits) from the packet

◆ p2p_close_timeout()

void p2p_close_timeout ( uint  rxd,
uint  rid 
)

Timed out waiting for CLOSE_ACK. Repeat P2P_CLOSE_REQ a few times then give up.

State should be RX_CLOSE_REQ

Parameters
[in,out]rxdReceive descriptor
[in]ridReceiver ID

◆ p2p_close_ack()

void p2p_close_ack ( uint  data,
uint  srce 
)

Received an acknowledge that a channel has been closed.

Parameters
[in]dataThe payload from the packet
[in]srceThe sender address (lower 16 bits) from the packet

◆ p2p_rcv_data()

void p2p_rcv_data ( uint  data,
uint  addr 
)

Receive data on channel.

May write 1 or 2 bytes beyond end of buffer (buffer has pad word)

Parameters
[in]dataThe payload from the packet
[in]addrThe sender address (lower 16 bits) from the packet

◆ p2p_rcv_ctrl()

void p2p_rcv_ctrl ( uint  data,
uint  addr 
)

Received P2P control packet.

Delegates to:

Parameters
[in]dataThe payload from the packet
[in]addrThe sender address (lower 16 bits) from the packet