This source file includes following definitions.
- fman_sp_set_buf_pools_in_asc_order_of_buf_sizes
- fman_sp_build_buffer_struct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 #include "fman_sp.h"
34 #include "fman.h"
35
36 void fman_sp_set_buf_pools_in_asc_order_of_buf_sizes(struct fman_ext_pools
37 *fm_ext_pools,
38 u8 *ordered_array,
39 u16 *sizes_array)
40 {
41 u16 buf_size = 0;
42 int i = 0, j = 0, k = 0;
43
44
45
46
47 for (i = 0; i < fm_ext_pools->num_of_pools_used; i++) {
48
49 buf_size = fm_ext_pools->ext_buf_pool[i].size;
50
51
52
53
54 sizes_array[fm_ext_pools->ext_buf_pool[i].id] = buf_size;
55
56
57 for (j = 0; j <= i; j++) {
58
59 if (j == i)
60 ordered_array[i] =
61 fm_ext_pools->ext_buf_pool[i].id;
62 else {
63
64 if (buf_size < sizes_array[ordered_array[j]]) {
65
66
67
68 for (k = i; k > j; k--)
69 ordered_array[k] =
70 ordered_array[k - 1];
71
72
73
74
75 ordered_array[k] =
76 fm_ext_pools->ext_buf_pool[i].id;
77 break;
78 }
79 }
80 }
81 }
82 }
83 EXPORT_SYMBOL(fman_sp_set_buf_pools_in_asc_order_of_buf_sizes);
84
85 int fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy *
86 int_context_data_copy,
87 struct fman_buffer_prefix_content *
88 buffer_prefix_content,
89 struct fman_sp_buf_margins *buf_margins,
90 struct fman_sp_buffer_offsets *buffer_offsets,
91 u8 *internal_buf_offset)
92 {
93 u32 tmp;
94
95
96 int_context_data_copy->ext_buf_offset = (u16)
97 ((buffer_prefix_content->priv_data_size & (OFFSET_UNITS - 1)) ?
98 ((buffer_prefix_content->priv_data_size + OFFSET_UNITS) &
99 ~(u16)(OFFSET_UNITS - 1)) :
100 buffer_prefix_content->priv_data_size);
101
102
103
104 buffer_offsets->prs_result_offset = (u32)ILLEGAL_BASE;
105 buffer_offsets->time_stamp_offset = (u32)ILLEGAL_BASE;
106 buffer_offsets->hash_result_offset = (u32)ILLEGAL_BASE;
107
108
109
110
111
112
113
114
115
116
117 int_context_data_copy->size =
118 (u16)((buffer_prefix_content->pass_prs_result ? 32 : 0) +
119 ((buffer_prefix_content->pass_time_stamp ||
120 buffer_prefix_content->pass_hash_result) ? 16 : 0));
121
122
123 int_context_data_copy->int_context_offset =
124 (u8)(buffer_prefix_content->pass_prs_result ? 32 :
125 ((buffer_prefix_content->pass_time_stamp ||
126 buffer_prefix_content->pass_hash_result) ? 64 : 0));
127
128 if (buffer_prefix_content->pass_prs_result)
129 buffer_offsets->prs_result_offset =
130 int_context_data_copy->ext_buf_offset;
131 if (buffer_prefix_content->pass_time_stamp)
132 buffer_offsets->time_stamp_offset =
133 buffer_prefix_content->pass_prs_result ?
134 (int_context_data_copy->ext_buf_offset +
135 sizeof(struct fman_prs_result)) :
136 int_context_data_copy->ext_buf_offset;
137 if (buffer_prefix_content->pass_hash_result)
138
139
140
141 buffer_offsets->hash_result_offset =
142 buffer_prefix_content->pass_prs_result ?
143 (int_context_data_copy->ext_buf_offset +
144 sizeof(struct fman_prs_result) + 8) :
145 int_context_data_copy->ext_buf_offset + 8;
146
147 if (int_context_data_copy->size)
148 buf_margins->start_margins =
149 (u16)(int_context_data_copy->ext_buf_offset +
150 int_context_data_copy->size);
151 else
152
153
154
155 buf_margins->start_margins =
156 buffer_prefix_content->priv_data_size;
157
158
159 tmp = (u32)(buf_margins->start_margins %
160 buffer_prefix_content->data_align);
161 if (tmp)
162 buf_margins->start_margins +=
163 (buffer_prefix_content->data_align - tmp);
164 buffer_offsets->data_offset = buf_margins->start_margins;
165
166 return 0;
167 }
168 EXPORT_SYMBOL(fman_sp_build_buffer_struct);
169