@@ -42,86 +42,198 @@ typedef enum _sai_native_hash_field_t
4242 * @brief Native hash field source IP.
4343 *
4444 * Also, refers to the outer source IP
45- * in case for encapsulated packets
45+ * in case for encapsulated packets.
46+ * Used for both IPv4 and IPv6
4647 */
47- SAI_NATIVE_HASH_FIELD_SRC_IP = 0 ,
48+ SAI_NATIVE_HASH_FIELD_SRC_IP ,
4849
4950 /**
50- * @brief Native hash field destination IP
51+ * @brief Native hash field destination IP.
5152 *
5253 * Also, refers to the outer source IP
53- * in case for encapsulated packets
54+ * in case for encapsulated packets.
55+ * Used for both IPv4 and IPv6
5456 */
55- SAI_NATIVE_HASH_FIELD_DST_IP = 1 ,
57+ SAI_NATIVE_HASH_FIELD_DST_IP ,
5658
5759 /** Native hash field inner source IP */
58- SAI_NATIVE_HASH_FIELD_INNER_SRC_IP = 2 ,
60+ SAI_NATIVE_HASH_FIELD_INNER_SRC_IP ,
5961
6062 /** Native hash field inner destination IP */
61- SAI_NATIVE_HASH_FIELD_INNER_DST_IP = 3 ,
63+ SAI_NATIVE_HASH_FIELD_INNER_DST_IP ,
64+
65+ /**
66+ * @brief Native hash field source IPv4.
67+ *
68+ * Also, refers to the outer source IPv4
69+ * in case for encapsulated packets
70+ */
71+ SAI_NATIVE_HASH_FIELD_SRC_IPV4 ,
72+
73+ /**
74+ * @brief Native hash field destination IPv4
75+ *
76+ * Also, refers to the outer source IPv4
77+ * in case for encapsulated packets
78+ */
79+ SAI_NATIVE_HASH_FIELD_DST_IPV4 ,
80+
81+ /**
82+ * @brief Native hash field source IPv6.
83+ *
84+ * Also, refers to the outer source IPv6
85+ * in case for encapsulated packets
86+ */
87+ SAI_NATIVE_HASH_FIELD_SRC_IPV6 ,
88+
89+ /**
90+ * @brief Native hash field destination IPv6
91+ *
92+ * Also, refers to the outer source IPv6
93+ * in case for encapsulated packets
94+ */
95+ SAI_NATIVE_HASH_FIELD_DST_IPV6 ,
96+
97+ /** Native hash field inner source IPv4 */
98+ SAI_NATIVE_HASH_FIELD_INNER_SRC_IPV4 ,
99+
100+ /** Native hash field inner destination IPv4 */
101+ SAI_NATIVE_HASH_FIELD_INNER_DST_IPV4 ,
102+
103+ /** Native hash field inner source IPv6 */
104+ SAI_NATIVE_HASH_FIELD_INNER_SRC_IPV6 ,
105+
106+ /** Native hash field inner destination IPv6 */
107+ SAI_NATIVE_HASH_FIELD_INNER_DST_IPV6 ,
62108
63109 /** Native hash field vlan id */
64- SAI_NATIVE_HASH_FIELD_VLAN_ID = 4 ,
110+ SAI_NATIVE_HASH_FIELD_VLAN_ID ,
65111
66112 /** Native hash field IP protocol */
67- SAI_NATIVE_HASH_FIELD_IP_PROTOCOL = 5 ,
113+ SAI_NATIVE_HASH_FIELD_IP_PROTOCOL ,
68114
69115 /** Native hash field Ethernet type */
70- SAI_NATIVE_HASH_FIELD_ETHERTYPE = 6 ,
116+ SAI_NATIVE_HASH_FIELD_ETHERTYPE ,
71117
72118 /** Native hash field L4 source port */
73- SAI_NATIVE_HASH_FIELD_L4_SRC_PORT = 7 ,
119+ SAI_NATIVE_HASH_FIELD_L4_SRC_PORT ,
74120
75121 /** Native hash field L4 destination port */
76- SAI_NATIVE_HASH_FIELD_L4_DST_PORT = 8 ,
122+ SAI_NATIVE_HASH_FIELD_L4_DST_PORT ,
77123
78124 /** Native hash field source MAC */
79- SAI_NATIVE_HASH_FIELD_SRC_MAC = 9 ,
125+ SAI_NATIVE_HASH_FIELD_SRC_MAC ,
80126
81127 /** Native hash field destination MAC */
82- SAI_NATIVE_HASH_FIELD_DST_MAC = 10 ,
128+ SAI_NATIVE_HASH_FIELD_DST_MAC ,
83129
84130 /** Native hash field source port */
85- SAI_NATIVE_HASH_FIELD_IN_PORT = 11 ,
131+ SAI_NATIVE_HASH_FIELD_IN_PORT ,
86132
87133 /** Native hash field inner IP protocol */
88- SAI_NATIVE_HASH_FIELD_INNER_IP_PROTOCOL = 12 ,
134+ SAI_NATIVE_HASH_FIELD_INNER_IP_PROTOCOL ,
89135
90136 /** Native hash field inner Ethernet type */
91- SAI_NATIVE_HASH_FIELD_INNER_ETHERTYPE = 13 ,
137+ SAI_NATIVE_HASH_FIELD_INNER_ETHERTYPE ,
92138
93139 /** Native hash field inner L4 source port */
94- SAI_NATIVE_HASH_FIELD_INNER_L4_SRC_PORT = 14 ,
140+ SAI_NATIVE_HASH_FIELD_INNER_L4_SRC_PORT ,
95141
96142 /** Native hash field inner L4 destination port */
97- SAI_NATIVE_HASH_FIELD_INNER_L4_DST_PORT = 15 ,
143+ SAI_NATIVE_HASH_FIELD_INNER_L4_DST_PORT ,
98144
99145 /** Native hash field inner source MAC */
100- SAI_NATIVE_HASH_FIELD_INNER_SRC_MAC = 16 ,
146+ SAI_NATIVE_HASH_FIELD_INNER_SRC_MAC ,
101147
102148 /** Native hash field inner destination MAC */
103- SAI_NATIVE_HASH_FIELD_INNER_DST_MAC = 17 ,
149+ SAI_NATIVE_HASH_FIELD_INNER_DST_MAC ,
104150
105151 /** Native hash field entire MPLS label stack */
106- SAI_NATIVE_HASH_FIELD_MPLS_LABEL_ALL = 18 ,
152+ SAI_NATIVE_HASH_FIELD_MPLS_LABEL_ALL ,
107153
108154 /** Native hash field the top MPLS label */
109- SAI_NATIVE_HASH_FIELD_MPLS_LABEL_0 = 19 ,
155+ SAI_NATIVE_HASH_FIELD_MPLS_LABEL_0 ,
110156
111157 /** Native hash field second MPLS label from the top */
112- SAI_NATIVE_HASH_FIELD_MPLS_LABEL_1 = 20 ,
158+ SAI_NATIVE_HASH_FIELD_MPLS_LABEL_1 ,
113159
114160 /** Native hash field third MPLS label from the top */
115- SAI_NATIVE_HASH_FIELD_MPLS_LABEL_2 = 21 ,
161+ SAI_NATIVE_HASH_FIELD_MPLS_LABEL_2 ,
116162
117163 /** Native hash field fourth MPLS label from the top */
118- SAI_NATIVE_HASH_FIELD_MPLS_LABEL_3 = 22 ,
164+ SAI_NATIVE_HASH_FIELD_MPLS_LABEL_3 ,
119165
120166 /** Native hash field fifth MPLS label from the top */
121- SAI_NATIVE_HASH_FIELD_MPLS_LABEL_4 = 23 ,
167+ SAI_NATIVE_HASH_FIELD_MPLS_LABEL_4 ,
168+
169+ /** No field - for compatibility, must be last */
170+ SAI_NATIVE_HASH_FIELD_NONE ,
122171
123172} sai_native_hash_field_t ;
124173
174+ /**
175+ * @brief Fine-grained hash field attribute IDs
176+ */
177+ typedef enum _sai_fine_grained_hash_field_attr_t
178+ {
179+ /**
180+ * @brief Start of attributes
181+ */
182+ SAI_FINE_GRAINED_HASH_FIELD_ATTR_START ,
183+
184+ /**
185+ * @brief Hash native field ID.
186+ *
187+ * @type sai_native_hash_field_t
188+ * @flags CREATE_ONLY
189+ * @default SAI_NATIVE_HASH_FIELD_NONE
190+ */
191+ SAI_FINE_GRAINED_HASH_FIELD_ATTR_NATIVE_HASH_FIELD = SAI_FINE_GRAINED_HASH_FIELD_ATTR_START ,
192+
193+ /**
194+ * @brief Mask for a IPv4 address.
195+ *
196+ * @type sai_ip4_t
197+ * @flags MANDATORY_ON_CREATE | CREATE_ONLY
198+ * @condition SAI_FINE_GRAINED_HASH_FIELD_ATTR_NATIVE_HASH_FIELD == SAI_NATIVE_HASH_FIELD_SRC_IPV4 or SAI_FINE_GRAINED_HASH_FIELD_ATTR_NATIVE_HASH_FIELD == SAI_NATIVE_HASH_FIELD_DST_IPV4 or SAI_FINE_GRAINED_HASH_FIELD_ATTR_NATIVE_HASH_FIELD == SAI_NATIVE_HASH_FIELD_INNER_SRC_IPV4 or SAI_FINE_GRAINED_HASH_FIELD_ATTR_NATIVE_HASH_FIELD == SAI_NATIVE_HASH_FIELD_INNER_DST_IPV4
199+ */
200+ SAI_FINE_GRAINED_HASH_FIELD_ATTR_IPV4_MASK ,
201+
202+ /**
203+ * @brief Mask for a IPv6 address.
204+ *
205+ * @type sai_ip6_t
206+ * @flags MANDATORY_ON_CREATE | CREATE_ONLY
207+ * @condition SAI_FINE_GRAINED_HASH_FIELD_ATTR_NATIVE_HASH_FIELD == SAI_NATIVE_HASH_FIELD_SRC_IPV6 or SAI_FINE_GRAINED_HASH_FIELD_ATTR_NATIVE_HASH_FIELD == SAI_NATIVE_HASH_FIELD_DST_IPV6 or SAI_FINE_GRAINED_HASH_FIELD_ATTR_NATIVE_HASH_FIELD == SAI_NATIVE_HASH_FIELD_INNER_SRC_IPV6 or SAI_FINE_GRAINED_HASH_FIELD_ATTR_NATIVE_HASH_FIELD == SAI_NATIVE_HASH_FIELD_INNER_DST_IPV6
208+ */
209+ SAI_FINE_GRAINED_HASH_FIELD_ATTR_IPV6_MASK ,
210+
211+ /**
212+ * @brief Optional field ordering.
213+ *
214+ * Specifies in which order the fields are hashed,
215+ * and defines in which fields should be associative for CRC with the same sequence ID.
216+ * If not provided, it's up to SAI driver to choose.
217+ *
218+ * @type sai_uint32_t
219+ * @flags CREATE_ONLY
220+ * @default 0
221+ */
222+ SAI_FINE_GRAINED_HASH_FIELD_ATTR_SEQUENCE_ID ,
223+
224+ /**
225+ * @brief End of attributes
226+ */
227+ SAI_FINE_GRAINED_HASH_FIELD_ATTR_END ,
228+
229+ /** Custom range base value */
230+ SAI_FINE_GRAINED_HASH_FIELD_ATTR_CUSTOM_RANGE_START = 0x10000000 ,
231+
232+ /** End of custom range base */
233+ SAI_FINE_GRAINED_HASH_FIELD_ATTR_CUSTOM_RANGE_END
234+
235+ } sai_fine_grained_hash_field_attr_t ;
236+
125237/**
126238 * @brief Hash attribute IDs
127239 */
@@ -151,6 +263,16 @@ typedef enum _sai_hash_attr_t
151263 */
152264 SAI_HASH_ATTR_UDF_GROUP_LIST ,
153265
266+ /**
267+ * @brief Hash fine-grained field list
268+ *
269+ * @type sai_object_list_t
270+ * @flags CREATE_AND_SET
271+ * @objects SAI_OBJECT_TYPE_FINE_GRAINED_HASH_FIELD
272+ * @default empty
273+ */
274+ SAI_HASH_ATTR_FINE_GRAINED_HASH_FIELD_LIST ,
275+
154276 /**
155277 * @brief End of attributes
156278 */
@@ -164,6 +286,58 @@ typedef enum _sai_hash_attr_t
164286
165287} sai_hash_attr_t ;
166288
289+ /**
290+ * @brief Create fine-grained hash field
291+ *
292+ * @param[out] fine_grained_hash_field_id Fine-grained hash field id
293+ * @param[in] switch_id Switch object id
294+ * @param[in] attr_count Number of attributes
295+ * @param[in] attr_list Array of attributes
296+ *
297+ * @return #SAI_STATUS_SUCCESS on success, failure status code on error
298+ */
299+ typedef sai_status_t (* sai_create_fine_grained_hash_field_fn )(
300+ _Out_ sai_object_id_t * fine_grained_hash_field_id ,
301+ _In_ sai_object_id_t switch_id ,
302+ _In_ uint32_t attr_count ,
303+ _In_ const sai_attribute_t * attr_list );
304+
305+ /**
306+ * @brief Remove fine-grained hash field
307+ *
308+ * @param[in] fine_grained_hash_field_id Fine-grained hash field id
309+ *
310+ * @return #SAI_STATUS_SUCCESS on success, failure status code on error
311+ */
312+ typedef sai_status_t (* sai_remove_fine_grained_hash_field_fn )(
313+ _In_ sai_object_id_t fine_grained_hash_field_id );
314+
315+ /**
316+ * @brief Set fine-grained hash field attribute
317+ *
318+ * @param[in] fine_grained_hash_field_id Fine-grained hash field id
319+ * @param[in] attr Attribute
320+ *
321+ * @return #SAI_STATUS_SUCCESS on success, failure status code on error
322+ */
323+ typedef sai_status_t (* sai_set_fine_grained_hash_field_attribute_fn )(
324+ _In_ sai_object_id_t fine_grained_hash_field_id ,
325+ _In_ const sai_attribute_t * attr );
326+
327+ /**
328+ * @brief Get fine-grained hash field attribute value
329+ *
330+ * @param[in] fine_grained_hash_field_id Fine-grained hash field id
331+ * @param[in] attr_count Number of attributes
332+ * @param[inout] attr_list Array of attributes
333+ *
334+ * @return #SAI_STATUS_SUCCESS on success, failure status code on error
335+ */
336+ typedef sai_status_t (* sai_get_fine_grained_hash_field_attribute_fn )(
337+ _In_ sai_object_id_t fine_grained_hash_field_id ,
338+ _In_ uint32_t attr_count ,
339+ _Inout_ sai_attribute_t * attr_list );
340+
167341/**
168342 * @brief Create hash
169343 *
@@ -221,10 +395,14 @@ typedef sai_status_t (*sai_get_hash_attribute_fn)(
221395 */
222396typedef struct _sai_hash_api_t
223397{
224- sai_create_hash_fn create_hash ;
225- sai_remove_hash_fn remove_hash ;
226- sai_set_hash_attribute_fn set_hash_attribute ;
227- sai_get_hash_attribute_fn get_hash_attribute ;
398+ sai_create_hash_fn create_hash ;
399+ sai_remove_hash_fn remove_hash ;
400+ sai_set_hash_attribute_fn set_hash_attribute ;
401+ sai_get_hash_attribute_fn get_hash_attribute ;
402+ sai_create_fine_grained_hash_field_fn create_fine_grained_hash_field ;
403+ sai_remove_fine_grained_hash_field_fn remove_fine_grained_hash_field ;
404+ sai_set_fine_grained_hash_field_attribute_fn set_fine_grained_hash_field_attribute ;
405+ sai_get_fine_grained_hash_field_attribute_fn get_fine_grained_hash_field_attribute ;
228406
229407} sai_hash_api_t ;
230408
0 commit comments