blob: c1db3408c6b4365094e49c0114cbfc3b7680c952 [file] [log] [blame]
developer02e65912023-08-17 16:33:10 +08001+=============================================================================+
2| Copyright (c) 2012-2020 Rambus, Inc. and/or its subsidiaries. |
3| |
4| Subject : PCL API Implementation Notes |
5| Product : PCL API |
6| Date : 18 November, 2020 |
7| |
8+=============================================================================+
9
10The SLAD API is a set of the APIs one of which is the Packet Classification
11(PCL) API. The driver implementation specifics of these APIs are
12described in short documents that serve as an addendum to the API
13specifications. This document describes the PCL API.
14
15This document uses the phrase "configurable" to indicate that a parameter or
16option is build-time configurable in the driver. Please refer to the User Guide
17of the driver for details.
18
19
20PCL API
21-------
22
23The PCL API manages two types of data structures relevant to the
24Packet Classification Engine: flow data structures and transform data
25structures.
26
27The PCL API is not used to submit packets (command descriptors) to the
28Packet Engine and to retrieve result descriptors (referring to
29processed packets). This is performed by the PEC API (see the PEC API
30Implementation Notes for details.
31
32Transform records
33 Transform records are allocated outside the Driver (using the
34 DMABuf API) and are initialized outside the Driver by the
35 Extended SA Builder. The Extended SA Builder is the SA Builder
36 that is compiled with the "Extended" configuration option
37 enabled. Transform records are represented by their DMABuf
38 Handle. They can be registered with PCL_Transform_Register() before
39 they are used and they are unregistered by
40 PCL_Transform_Unregister() after use. A subset of the contents
41 (sequence number and statistics) can be read with
42 PCL_Transform_Get_ReadOnly().
43
44Flow records
45 Flow Records are represented by an internal data structure
46 (represented by PCL_FlowHandle_t), which is invisible to the application.
47 The internal data structure is allocated within the Driver.
48 A DMA-safe buffer is associated with it and this is also allocated
49 within the Driver and invisible to the application.
50
51 The Driver makes use of the internal DMAResource API to allocate
52 the DMA-safe buffer and of an internal memory allocation API
53 (adapter_alloc.h) to allocate the data structure.
54
55 Allocation of flow records can be a time consuming operation and
56 it may not be allowed at all in certain situations (e.g. in
57 interrupt context). Therefore allocating and deallocating the
58 resources for a flow record is decoupled from adding and removing
59 flow records in the flow record table.
60
61 When a flow record is allocated with PCL_Flow_Alloc() its
62 resources (internal data structure and DMA-safe buffer) are
63 allocated, but the flow record is not initialized, is not part of
64 the flow table and is inaccessible to the Packet Classification
65 Engine. PCL_Flow_Add() initializes the record and adds it to a
66 lookup table. The size of the hash table from which flow lookup
67 is started has a configurable size.
68
69 PCL_Flow_Get_ReadOnly() reads the variable fields (last used time,
70 packet statistics) from a flow record. PCL_Flow_Remove() removes it
71 from the lookup table. At this time the resources are still allocated
72 and can be reused by another flow record. PCL_Flow_Release() deallocates
73 all flow resources.
74
75 This implementation does not implement the PCL_Flow_Lookup() function.
76
77Direct Transform Lookup
78 Transform records can be looked up directly (without the need for
79 a flow record). Use the function PCL_DTL_Transform_Add to add an
80 existing record (already registered with PCL_Transform_Register)
81 to the lookup table. PCL_DTL_Transform_Remove removes the transform
82 record from the lookup table again.
83
84Record invalidation
85 When flow records or transform records must be removed from the
86 system, they must also be removed from the record cache of the packet
87 engine, by means of a special command descriptor. The following
88 steps are required:
89 - Prevent the record from being looked up again. Use PCL_Flow_Remove
90 to remove a flow record from the lookup table. Use
91 PCL_DTL_Transform_Remove to remove a transform record from the lookup
92 table.
93 - Submit a special command descriptor containing a record invalidation
94 command with PEC_Packet_Put.
95 - Wait until the corresponding result descriptor is received with
96 PEC_Packet_Get.
97
98Byte ordering (endianness)
99 The transform buffers are considered arrays of 32-bit integers, in host-
100 native byte ordering. The driver will change the byte order if this is
101 required (configurable). The data buffers are considered byte arrays and
102 the driver will not touch these. Flow records are allocated and managed
103 entirely by the driver and their internal representation is never used by
104 the application.
105
106Bounce Buffers
107 The PCL API does not use bounce buffers. Transform buffers can be
108 allocated by the application in a DMA-safe way and buffers for the
109 flow table are allocated entirely within the Driver.
110
111Banks for DMA resources.
112 The PCL API requires that all DMA buffers for transform records
113 are allocated in Bank 1 (Bank parameter in
114 DMABuf_Properties_t). Internally the PCL adapter takes care of
115 allocating DMA-safe buffers for flow records in Bank 2. Memory
116 allocations in Bank 1 and Bank 2 are taken from special-purpose
117 memory pools. On 64-bit systems these pools are guaranteed to lay
118 in a 4GB address range. The PCL implementation takes care to convert
119 64-bit bus addresses for flow and transform records to 32-bit offsets
120 with respect to the base address of the pool.
121
122Concurrent Context Synchronization (CCS)
123 The PCL API implementation supports one single multi-threaded application,
124 allowing concurrent and independent use of PCL_Init/UnInit, PCL_Flow and
125 PCL_Transform functions. Multiple applications for the PCL API are
126 not supported.
127
128 The PCL API implementation provides synchronization mechanisms for
129 concurrent contexts invoking the API functions. The API can be used
130 by multi-threaded user-space or kernel-space applications. The latter
131 can invoke the API functions from the user process as well as from softirq
132 contexts. Mixing user process execution with softirq contexts is also
133 supported. Both Linux Uni-Processor (UP) and Symmetric Multi-Processor
134 (SMP) kernel configurations are supported.
135
136 All the PCL API functions allow for just one execution context at a time.
137 Note that although the API functions take the interface ID as an input
138 parameter it is not used in the current implementation.
139
140 The PCL API implementation serializes the access from concurrent execution
141 contexts to the classification device so having multiple contexts using
142 this API will not result in better performance.
143
144 When a function from the PCL API detects that it competes for a resource
145 already used at the time by another context executing the PCL code it will
146 not block and return PCL_STATUS_BUSY return code. The caller should try
147 calling this function again short after.
148
149
150<end of document>