Stream Setup
During the stream setup, the application should call the new set of
*WithCrc
APIs to get and save the CRC values. Before
entering the streaming phase, the producer application must verify the CRC values
and other validation data provided by all ASIL-D consumers and indicate whether it
is safe to start streaming.
The producer application must maintain the init-time CRC values of:
- Producer’s user-defined endpoint information
- Consumer’s user-defined endpoint information (optional)
- The endpoint information from each consumer may be different; the producer must maintain an array of CRC values for each consumer
- Buffer information
- The consumer will not receive another consumer’s CRC buffer object, so the producer must maintain an array of buffer CRC values for each consumer
- Producer’s synchronization information
- Consumer’s synchronization information
- The consumer may provide different synchronization information, so the producer needs to maintain an array of synchronization CRC values for each consumer
The consumer application needs to maintain the CRC init-time values of:
- Producer’s user-defined endpoint information
- Consumer’s user-defined endpoint information (optional)
- Buffer information
- Producer’s synchronization information
- Consumer’s synchronization information
Create Blocks
The ASIL-D or ASIL-B(D) producer and consumers must indicate whether they
require CRC validation when creating the blocks by calling
NvSciStreamProducerCreate2()
with
crcValidate
set to true
. Similarly,
the consumer application can call
NvSciStreamConsumerCreate2()
with
crcValidate
set to true
.
User-defined Endpoint Information
When the producer/consumer provides the endpoint information to the other side,
it calls NvSciStreamBlockUserInfoSetWithCrc()
to send the
endpoint information and calls
NvSciStreamBlockUserInfoGetWithCrc()
to query the
endpoint information.
The producer application must define a unique stream ID for each stream and send it to all consumer applications as part of the endpoint information. The consumers share this stream ID along with the CRC values the producer to validate if the producer process and consumer process are connected to the same stream.
The application must query the user information by different
userType
in the same order as that set by the
application at remote ends. As CRC is generated based on the order of
information set or retrieved, the order of setting the user information and
retrieving the user information must be same on both ends.
Query Connection Index
Once the consumer receives the NvSciStreamEventType_Connected
event, The consumer calls NvSciStreamConsumerIndexGet()
to
query the connection index. It must share the connection index with the
producer along with the NvSciIpc endpoint name in a later validation step.
The producer application can tell which indexed consumer is ASIL-D or
ASIL-B(D) according to the NvSciIpc channel.
Packet Layout
The application must set up buffer attributes to allocate extra CRC buffers in each packet for each endpoint, because they need to exchange the CRC values and additional validation data in the shared buffer instead of the regular communication channel used for sending and receiving messages. For example, in a stream with two consumers, it needs to allocate three CRC buffers per packet: one for the producer and the remaining two for each consumer.
When the pool sends the final layout, it calls
NvSciStreamBlockElementAttrSetWithCrc()
to set the
reconciled element attributes. All CRC buffer objects are visible to the
producer reapplication, but the consumer application should only access the
producer’s CRC element and its own CRC element. The pool calls
NvSciStreamBlockElementNotVisible()
to mark the
consumer’s CRC buffer objects only visible to the owner, who has read-write
permission.
The produer/consumer applications must call
NvSciStreamBlockElementAttrGetWithCrc()
to query the
reconciled attributes for each element in the same order in which the pool
set the attributes, such as from element index 0 to element index
(element_count -1).
Buffer Objects
The pool creates new packets one by one. The next new packet is created after
receiving the packet acceptance status from producer and consumers, and it
calls NvSciStreamPoolPacketInsertBufferWithCrc()
to add the
buffer objects to the new packet.
The producer/consumer applications call
NvSciStreamBlockPacketBufferGetWithCrc()
to query the
buffer objects from each packet. The producer application must track CRC
values for each consumer by providing an array of CRC values to this call.
According to the element type and the index of the consumer, the producer
can tell if the indexed element is a CRC element for the indexed consumer,
and it only updates the CRC value for that consumer.
Synchronization Objects
The producer/consumer calls
NvSciStreamBlockElementSignalObjSetWithCrc()
/
NvSciStreamBlockElementSignalObjGetWithCrc()
to
set/query the synchronization objects. The applications must set or get the
information in the same order, such as from element index 0 to element index
(element_count - 1).
When the producer queries the synchronization objects from each consumer, it should maintain the CRC values for different consumers.
Validation Event
When the consumer application completes the buffer and synchronization setup steps, it must validate whether the buffer and synchronization objects to meet its buffer/ synchronization requirement.
- Retrieve the reconciled attribute list from the
buffer/synchronization objects via
NvSciBufObjGetAttrList
/NvSciSyncObjGetAttrList
- Validate that the reconciled attribute list meets its own
requirements via
NvSciBufAttrListValidateReconciledAgainstAttrs
/NvSciSyncAttrListValidateReconciledAgainstAttrs
- Validate the buffer/synchronization objects satisfies the
constraints of the the associated reconciled attribute list
via
NvSciBufObjValidate
/NvSciSyncObjValidate
If the above validation is passed, the consumer application
writes the validation data into its own CRC element of the first created
packet and calls NvSciStreamBlockSetupStatusSet()
with
NvSciStreamSetup_CrcImport
to inform the producer
that the initialization-time validation data is ready. The validation data
should include the following:
- A user-defined magic ID to indicate it is init-time validation data
- All the CRC init-time values maintained by the consumer
- The stream ID received from the producer as one part of the endpoint information
- A connection index of the consumer
- The NvSciIpc endpoint name used by the consumer process
When the producer application receives the
NvSciStreamEventType_Validate
event, the producer
application must verify the data provided by each ASIL-D or ASIL-B(D)
consumer in the consumer’s CRC elements of the first created packet:
- The magic number matches the init-time magic number
- The stream ID is the same as that sent by the producer
- The consumer index is unique and in a valid range
- Determine which indexed consumer is the ASIL-D or ASIL-B(D) consumer according to the NvSciIpc endpoint name provided by the consumer. The Producer application must keep track of the consumer indexes of ASIL-D or ASIL-B(D) consumers and must validate the data only from those consumers
- The CRC values provided by the consumers are the same as those calculated by the producer
The producer application can skip validating the information from non ASIL-D or non ASIL-B(D) consumers, which may provide incorrect information.
The producer application also must validate the buffer and synchronization objects to meet its buffer/ synchronization requirement.
- Retrieve the reconciled attribute list from the buffer/synchronization
objects via
NvSciBufObjGetAttrList
/NvSciSyncObjGetAttrList
- Validate that the reconciled attribute list meets its own requirements
via
NvSciBufAttrListValidateReconciledAgainstAttrs
/NvSciSyncAttrListValidateReconciledAgainstAttrs
- Validate the buffer/synchronization objects satisfies the constraints of
the the associated reconciled attribute list via
NvSciBufObjValidate
/NvSciSyncObjValidate
The producer application must query the max buffer access permission for the
lower ASIL consumers on the reconciled attribute list associated with the
NvSciBufObj
(s) using
NvSciBufObjGetMaxPerm
.
Only when the validation process is complete, the producer application can
inform the stream to start streaming by calling
NvSciStreamBlockSetupStatusSet()
with
NvSciStreamSetup_CrcImport
.