1. Overview
    1. Responsibility
      1. Chaper 11
        1. Sending and receiving Address Frames
        2. Sending and receiving the Identification Sequence
        3. Management of Primitives
      2. Chaper 12
        1. Clock Compensation
        2. CRC Generation and Checking
        3. Scrambling
      3. ?
        1. Connection Management
        2. Generation of Idle Cycles
        3. Byte Ordering
    2. Introduction
      1. Hard reset
        1. SSP port
          1. Cause a Transport Reset event notification to the Application Layer
          2. Result in a SCSI device reset
        2. STP port
          1. equal to a power on hardware reset (a Phy reset)
    3. Address Frames
      1. OPEN Address Frame
        1. Initiator Connection Tag
          1. Facilitate quickly looking up the context when the reply returns from the target at some later time
          2. Target are not required to check for consistency on this
        2. Destination SAS Address
          1. Identify the intended recipient of this connection request
          2. Expander
          3. Port selection
          4. Check the other arguments to verify that the matching port will actually support the request
          5. Recipient
          6. Verify that the address matches its own SAS address
        3. Source SAS Address
          1. Only AWT and source address are compared to see which will win access to that link
        4. Pathway Blocked Count
          1. The number of times this request has been forced to retry
          2. It received an OPEN_REJECT (PATHWAY BLOCKED) response
          3. Ensure that a request which has previously been retried will have a higher priority next time
        5. Arbitration Wait Time (AWT)
          1. microseconds
          2. milliseconds
          3. Used to assign arbitration priority
          4. Zero or at most 8000h
          5. unfair arbitration
          6. Most significant consideration in determining the priority in the expander
      2. IDENTIFY Address Frame
        1. The information that a SAS Phy passes to its neighbor over the link during a link reset (after Phy reset)
        2. The two devices on either end of a link exchange IDENTIFY frames with each other
        3. SATA devices implement a Phy reset
          1. But no identification sequence
    4. Primitives
      1. General
        1. dwords
          1. four bytes
          2. four characters
        2. Special meaning to the system
        3. The first character
          1. K28.5
          2. SAS
          3. K28.3
          4. SATA
          5. K28.6
          6. A bridge to a SATA device
          7. Receive an error in the flow of traffic to the SATA target
      2. Endian Notation
        1. SAS
          1. Big-Endian
          2. The highest-order byte first
        2. SATA
          1. Little-Endian
          2. The lowest-order byte first
        3. Not a factor for primitives
      3. Error Portection
        1. Not include CRC protection
        2. Chose combination of characters that would maximize the Hamming distance between any two valid primitives
      4. Usage
        1. Indicate address frames for connection and identification
        2. Start and end frames
        3. Ensure proper clock compensation
        4. Perform flow control
      5. Contexts
        1. Non Protocol Specific
          1. outside of a connection
          2. AIP
          3. Used by expanders
          4. Report that the arbitration process for a connection request is under way
          5. BREAK
          6. Terminate a connection without the normal close handshake process
          7. CLOSE
          8. Close out a connection
          9. Free the resources for otheer connections
          10. OPEN_ACCEPT
          11. Sent by the recipient of a connection request
          12. OPEN_REJECT
          13. Sent by the recipient of a connection request
          14. SOAF, EOAF
          15. within a connection
          16. ALIGN
          17. Clock skew management
          18. inside
          19. outside
          20. NOTIFY
          21. BROADCAST
          22. Sent out on all expander ports
          23. Except the one experiencing the change to tell initiator in the system that they need to take steps to discover the change
          24. ERROR
          25. Send by Expander
          26. When forwarding dwords that have been detected on the incoming 'Phy as invalid dwords
          27. HARD_RESET
          28. Force a device-level reset
        2. Within SSP and SMP Connections
          1. Manage aspects of the Link Layer protocol
          2. SOP and EOF
          3. DONE
          4. The connection is being prepared for closing
          5. ACK, NAK
          6. INdicate status of SSP frame reception
          7. RRDY
          8. Indicate readiness to receive a frame
          9. Used in SSP
          10. CREDIT_BLOCKED
          11. No more RRDYs to be sent in this connection
      6. Single Primitives
        1. Only one instance of the primitive to be sent
        2. Only one needs to be detected to achieve a valid result
        3. Used exclusively within SSP and SMP are this type
      7. Repeated Primitives
        1. Repeated several times by the sender
        2. Detected several times in a row by the receiver to be valid
        3. STP connections when responding to power management requests
      8. Continued Primitives
        1. Only used in SATA connections
        2. Allow primitives to repeat indefinitely
      9. Triple Primitives
        1. During normal operation, the same meaning, encoded differently
        2. Sent three times by the transmitter
        3. Seen three times in a row at the receiver
        4. ALIGN and NOTIFY can be mixed into the sequence with no loss of continuity
        5. The four versions of CLOSE
      10. Redundatnt Primitives
        1. Sent 6 times in a row
        2. At least 3 fo those must be seen consecutively by the receiver
        3. The eight versions of BROADCAST
        4. HARD_RESET
        5. ALIGN can be mixed into the sequence with no loss of continuity
    5. State Machine - Link Layer Identification and Reset
      1. General
        1. Control the generation and receipt of the identification sequence
      2. TRansmitter and Receiver
        1. SL_IR Transmitter: Told to send
          1. Identify frame
          2. Hard Reset
          3. Idle dwords
        2. SL_IR Receiver: Report receipt of Identify or Reset sequences
          1. SOAF
          2. data dwords
          3. EOAF
          4. ERROR
          5. Invalid dword
          6. Hard Reset
      3. SL_IR_TIR
        1. Transmit IDENTIFY or HARD_RESET
        2. After the Phy Layer enables the Link Layer, Send:
          1. One IDENTIFY address frame
          2. Hard Reset
      4. SL_IR_RIF
        1. Receive IDENTIFY address Frame
        2. Verify the receipt of a valid IDENTIFY address frame
        3. Start SL_IR Receiver confirmation from the Pjhy Layer has been received
          1. The dword synchroniztion has been achieved
        4. SOAF received confirmation has been received
          1. An address frame has arrived
      5. SL_IR_IRC
        1. Identification and Hard Reset Control
  2. Serial Support
    1. Clock Compensation
      1. General
        1. Embed the clock into the data at the transmitter and recover it at the receiver
        2. The transmitter and receiver clocks are essentially asynchronous to each other
          1. Solution: Elastic Buffer
      2. Elastic Buffer
      3. Crossing Clock Domains
        1. Frequnecy Difference Can Change
          1. ALIGN Injection/Remove is done in Phy Layer of Transmitter
          2. Transmitter's clock is faster
          3. Overflow
          4. Remove ALIGN
          5. Receiver's clock is faster
          6. Underflow
          7. Inject more ALIGNs into the buffer
        2. Metastability Risk
          1. Synchronizer
          2. No method that can completely eliminate the possibility of metastability
          3. Adding more input register
          4. Exist in the Elastic Buffer
          5. Around 4 entries deep
      4. Elastic Buffer Design
        1. Always keep the buffer half full using the incoming data stream
      5. Justification for an Elastic Buffer
        1. Sufficient for ALIGN injection only?
          1. No! Elastic needed to handle both overflow and underflow
    2. CRC Generation and Checking
      1. General
        1. Error checking scheme
        2. Hash function
        3. Create a 32-bit result which is appended at the end of the frame
        4. The primitives are not considered part of the payload and are therefore not involved in CRC calculations
      2. Incoming Frames Verification
        1. Duplicate the process that the transmitter used and compare wtih the received CRC
        2. Process the entiring frame including the received CRC to confirm whether it is the expected constant value
        3. Robust Error Dectection
          1. Discard the entire frame if a CRC error is detected
          2. SSP
          3. NAK (CRC ERROR)
          4. SMP
          5. BREAK
        4. Error Coverage
          1. Based on the number of dwords that are transmitted in a given frame
    3. Scrambling
      1. Reduce the EMI
      2. All data dwords for both SAS and SATA are scrambled
      3. Primitives are not scrambled
        1. multi-version Primitives
          1. ALIGN
          2. ALIGN(0)
          3. ALIGN(1)
          4. ALIGN(2)
          5. ALIGN(3)
      4. Reset to its initial value every time an SOF or SOAF primitive appears
  3. Connection Management
    1. Introduction
    2. Opening the Connection
    3. Rate Matching
      1. Reduced performance on the links that were capable of faster operation
      2. Allow mixing older and newer parts in the same system
    4. State Machines
      1. Introduction
        1. Begin when they receive an Enable Disable SAS Link (Enable) message from the SL_IR
      2. SL Transmitter and Receiver
        1. SL Transmitter
          1. Receive instructions about what needs to be transmitted
          2. No request are pending: Send Idle dwords
          3. Multiple requests are queue up (↓)
          4. BREAK
          5. CLOSE
          6. OPEN_ACCEPT or REJECT
          7. SOAF, or data dword, or EOAF
          8. Idle dword
        2. SL Receiver
          1. Take in the incoming dword stream
          2. Pass messages about the status of what has been received to SL state machines
      3. SL_RA State Machine
        1. Receive open Address frame
        2. Only one state
        3. Function
          1. Detect incoming OPEN address frames
          2. Evaluate them for correctness
        4. Receive from SL Receiver
          1. SOAF Received
          2. Data Dword Received
          3. EOAF Received
        5. Check correctness
          1. 8 data dwords received between SOAF and EOAF
          2. Destination address match?
          3. CRC
        6. If correct
          1. Send an OPEN Address Frame Received to SL_CC
      4. SL_CC State Machine
        1. Connection Control
        2. The highest level control in the Link Layer
  4. Arbitration
    1. Arbitration Fairness
      1. Arguments used for arbitration
        1. Arbitration Wait Time(AWT)
        2. Source SAS Address
        3. Connection Rate
        4. Retry Priority Status
        5. Partial Pathway Timeout Status
        6. Pathway Blocked Count
      2. Arbitration
        1. Competition for Narrow Port (↓)
          1. AWT
          2. PBC
          3. Source SAS address
          4. Connection rate
        2. Partial Pathway Counter
          1. If this timer expired, it will increase its own PBC to have a higher priority for the next time
        3. Backoff-Reverse Path
          1. The incoming request has a source address matching the destination address of the outgoing request
          2. OPEN after receiving AIP(NORMAL)
          3. its outgoing request has lost arbitration
        4. Crossing Requests
        5. Backoff-Retry
    2. Deadlock and Livelock
      1. Deadlock
        1. Several devices attempt to access a set of pathways at the same time
          1. The requests end up blocking each other without any of them succeeding
        2. Necessary conditions
          1. Mutual Exclusion
          2. a resource that cannot be used by more than one process at a time
          3. Topic
          4. Prevent: Require shareing of resources
          5. Not a possibility in SAS
          6. Hold and Wait
          7. processes already holding resources may request new resources
          8. Prevent: Require that requesters hold and release all their resources at the same time
          9. Not work in SAS
          10. No Preemption
          11. No resource can be forcibly removed from a process holding it, resources can be released only by the explicit action of the process
          12. Prevent: Let an initiator override a connection or connection request from another initiator
          13. One initiator could cause another to starve for bus access
          14. Difficult to take over resources in other expander
          15. Circular Wait
          16. two or more processes form a circular chain where each process waits for a resource that the next process in the chain holds
          17. Prevent: Require imposing some form of global ordering to ensure that all requesters request resources in order
        3. Recovery
          1. Detect situations that might indicate that a deadlock has occurred and recover from it
          2. Track how long a partially-completed connection waits
          3. Measured by the Partial Pathway Timeout timer
      2. Livelock
        1. Variation of deadlock
        2. All arrive at the same time
        3. Back up by the same amount at the same time and then try again
  5. Protocol Differences
    1. Flow Control
      1. SSP and STP
        1. SSP supports full-duplex traffic
        2. STP only half-duplex
      2. SSP flow control rules ordinarily require that no frames arrive before the receiver explicitly indicates readiness to receive them
      3. Exception Case
        1. the First Burst mechanism
      4. Normal Case
        1. One RRDY → One frame up to 1KB of data
          1. RRDY are primitives
          2. No flow control permission is needed to send primitives
    2. Frame Acknowledgement (ACN/NAK Handshake)
      1. Interlocked Frames
        1. All frames except data frames are interlocked
          1. Another frame can't be sent until receipt of the previous frame has been acknowledge with ACK or NAK
      2. Non-interlocked Frames
        1. Data frames
        2. Several non-interlocked data frames may be sent consecutively without waiting on an ACK/NAK response
        3. Count how many frames have been sent and how may ACK/NAK have been returned
        4. Balance Required
        5. Balance Not Required
          1. Use the same logical unit
          2. The same tag value as the previous Tx Frame message
      3. Only one reason for NAK
        1. CRC ERROR
    3. SSP Connection
      1. State Machines
        1. 4 for frame transmission
        2. 5 for frame reception
      2. Transmit State MAchines
        1. TIM
          1. Transmit Interlocked Frame Monitor
          2. Count the number of frames sent and the number of ACK/NAKs received
          3. Send a Tx Balance Status message to the SSP_TF2:Tx_Wait state
          4. Automatically set equal to each other whenever receive
          5. Request Close
          6. Request Break
          7. SSP Enable Disable (Enable)
        2. TF
          1. Transmit Frame control
        3. TCM
          1. Transmit frame Credit Monitor
          2. Track the number of frame credits available to make sure that there is credit before a frame is transmitted
          3. Add one credit for every RRDY received
          4. Subtract one for every Tx Credit Used message it receives
        4. D
          1. Done control
          2. Make sure a DONE has been both sent and received before disabling the SSP state machines
      3. Receive State Machines
        1. RF
          1. Receive Frame control
          2. Check incoming frames to verify that they are legal and should be accepted
        2. RCM
          1. Receive frame Credit Monitor
          2. Track the number of RRDYs sent versus the number of frames received
        3. TC
          1. Transmit Credit control
          2. Oversee the requests to transmit an RRDY or CREDIT_BLOCKED
        4. TAN
          1. Transmit ACK/NAK control
          2. Control the sending of ACKs or NAKs in response to received frames
          3. The sending of ACKs and NAKs is reported to SSP_RIM
        5. RIM
          1. Receive Interlocked frame Monitor
          2. Track the ACK.NAK balance at the receiver
          3. Report that status with an Rx Balance Status message
    4. SMP Connections
      1. SMP_IP
        1. Initiator Port
      2. SMP_TP
        1. Target Port