diff options
author | Ingo Molnar <mingo@kernel.org> | 2012-03-26 11:18:44 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-03-26 11:19:03 -0400 |
commit | 7fd52392c56361a40f0c630a82b36b95ca31eac6 (patch) | |
tree | 14091de24c6b28ea4cae9826f98aeedb7be091f5 /tools | |
parent | b01c3a0010aabadf745f3e7fdb9cab682e0a28a2 (diff) | |
parent | e22057c8599373e5caef0bc42bdb95d2a361ab0d (diff) |
Merge branch 'linus' into perf/urgent
Merge reason: we need to fix a non-trivial merge conflict.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/hv/hv_kvp_daemon.c | 458 | ||||
-rw-r--r-- | tools/include/tools/be_byteshift.h | 70 | ||||
-rw-r--r-- | tools/include/tools/le_byteshift.h | 70 | ||||
-rw-r--r-- | tools/perf/util/include/linux/bitops.h | 2 | ||||
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 58 | ||||
-rw-r--r-- | tools/testing/ktest/sample.conf | 14 | ||||
-rw-r--r-- | tools/usb/Makefile | 2 | ||||
-rw-r--r-- | tools/usb/ffs-test.c | 31 | ||||
-rw-r--r-- | tools/usb/testusb.c | 2 |
9 files changed, 614 insertions, 93 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index 11224eddcdc2..146fd6147e84 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c | |||
@@ -34,21 +34,13 @@ | |||
34 | #include <errno.h> | 34 | #include <errno.h> |
35 | #include <arpa/inet.h> | 35 | #include <arpa/inet.h> |
36 | #include <linux/connector.h> | 36 | #include <linux/connector.h> |
37 | #include <linux/hyperv.h> | ||
37 | #include <linux/netlink.h> | 38 | #include <linux/netlink.h> |
38 | #include <ifaddrs.h> | 39 | #include <ifaddrs.h> |
39 | #include <netdb.h> | 40 | #include <netdb.h> |
40 | #include <syslog.h> | 41 | #include <syslog.h> |
41 | 42 | #include <sys/stat.h> | |
42 | /* | 43 | #include <fcntl.h> |
43 | * KYS: TODO. Need to register these in the kernel. | ||
44 | * | ||
45 | * The following definitions are shared with the in-kernel component; do not | ||
46 | * change any of this without making the corresponding changes in | ||
47 | * the KVP kernel component. | ||
48 | */ | ||
49 | #define CN_KVP_IDX 0x9 /* MSFT KVP functionality */ | ||
50 | #define CN_KVP_VAL 0x1 /* This supports queries from the kernel */ | ||
51 | #define CN_KVP_USER_VAL 0x2 /* This supports queries from the user */ | ||
52 | 44 | ||
53 | /* | 45 | /* |
54 | * KVP protocol: The user mode component first registers with the | 46 | * KVP protocol: The user mode component first registers with the |
@@ -60,25 +52,8 @@ | |||
60 | * We use this infrastructure for also supporting queries from user mode | 52 | * We use this infrastructure for also supporting queries from user mode |
61 | * application for state that may be maintained in the KVP kernel component. | 53 | * application for state that may be maintained in the KVP kernel component. |
62 | * | 54 | * |
63 | * XXXKYS: Have a shared header file between the user and kernel (TODO) | ||
64 | */ | 55 | */ |
65 | 56 | ||
66 | enum kvp_op { | ||
67 | KVP_REGISTER = 0, /* Register the user mode component*/ | ||
68 | KVP_KERNEL_GET, /*Kernel is requesting the value for the specified key*/ | ||
69 | KVP_KERNEL_SET, /*Kernel is providing the value for the specified key*/ | ||
70 | KVP_USER_GET, /*User is requesting the value for the specified key*/ | ||
71 | KVP_USER_SET /*User is providing the value for the specified key*/ | ||
72 | }; | ||
73 | |||
74 | #define HV_KVP_EXCHANGE_MAX_KEY_SIZE 512 | ||
75 | #define HV_KVP_EXCHANGE_MAX_VALUE_SIZE 2048 | ||
76 | |||
77 | struct hv_ku_msg { | ||
78 | __u32 kvp_index; | ||
79 | __u8 kvp_key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; /* Key name */ | ||
80 | __u8 kvp_value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; /* Key value */ | ||
81 | }; | ||
82 | 57 | ||
83 | enum key_index { | 58 | enum key_index { |
84 | FullyQualifiedDomainName = 0, | 59 | FullyQualifiedDomainName = 0, |
@@ -93,10 +68,6 @@ enum key_index { | |||
93 | ProcessorArchitecture | 68 | ProcessorArchitecture |
94 | }; | 69 | }; |
95 | 70 | ||
96 | /* | ||
97 | * End of shared definitions. | ||
98 | */ | ||
99 | |||
100 | static char kvp_send_buffer[4096]; | 71 | static char kvp_send_buffer[4096]; |
101 | static char kvp_recv_buffer[4096]; | 72 | static char kvp_recv_buffer[4096]; |
102 | static struct sockaddr_nl addr; | 73 | static struct sockaddr_nl addr; |
@@ -109,6 +80,345 @@ static char *os_build; | |||
109 | static char *lic_version; | 80 | static char *lic_version; |
110 | static struct utsname uts_buf; | 81 | static struct utsname uts_buf; |
111 | 82 | ||
83 | |||
84 | #define MAX_FILE_NAME 100 | ||
85 | #define ENTRIES_PER_BLOCK 50 | ||
86 | |||
87 | struct kvp_record { | ||
88 | __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | ||
89 | __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; | ||
90 | }; | ||
91 | |||
92 | struct kvp_file_state { | ||
93 | int fd; | ||
94 | int num_blocks; | ||
95 | struct kvp_record *records; | ||
96 | int num_records; | ||
97 | __u8 fname[MAX_FILE_NAME]; | ||
98 | }; | ||
99 | |||
100 | static struct kvp_file_state kvp_file_info[KVP_POOL_COUNT]; | ||
101 | |||
102 | static void kvp_acquire_lock(int pool) | ||
103 | { | ||
104 | struct flock fl = {F_WRLCK, SEEK_SET, 0, 0, 0}; | ||
105 | fl.l_pid = getpid(); | ||
106 | |||
107 | if (fcntl(kvp_file_info[pool].fd, F_SETLKW, &fl) == -1) { | ||
108 | syslog(LOG_ERR, "Failed to acquire the lock pool: %d", pool); | ||
109 | exit(-1); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | static void kvp_release_lock(int pool) | ||
114 | { | ||
115 | struct flock fl = {F_UNLCK, SEEK_SET, 0, 0, 0}; | ||
116 | fl.l_pid = getpid(); | ||
117 | |||
118 | if (fcntl(kvp_file_info[pool].fd, F_SETLK, &fl) == -1) { | ||
119 | perror("fcntl"); | ||
120 | syslog(LOG_ERR, "Failed to release the lock pool: %d", pool); | ||
121 | exit(-1); | ||
122 | } | ||
123 | } | ||
124 | |||
125 | static void kvp_update_file(int pool) | ||
126 | { | ||
127 | FILE *filep; | ||
128 | size_t bytes_written; | ||
129 | |||
130 | /* | ||
131 | * We are going to write our in-memory registry out to | ||
132 | * disk; acquire the lock first. | ||
133 | */ | ||
134 | kvp_acquire_lock(pool); | ||
135 | |||
136 | filep = fopen(kvp_file_info[pool].fname, "w"); | ||
137 | if (!filep) { | ||
138 | kvp_release_lock(pool); | ||
139 | syslog(LOG_ERR, "Failed to open file, pool: %d", pool); | ||
140 | exit(-1); | ||
141 | } | ||
142 | |||
143 | bytes_written = fwrite(kvp_file_info[pool].records, | ||
144 | sizeof(struct kvp_record), | ||
145 | kvp_file_info[pool].num_records, filep); | ||
146 | |||
147 | fflush(filep); | ||
148 | kvp_release_lock(pool); | ||
149 | } | ||
150 | |||
151 | static void kvp_update_mem_state(int pool) | ||
152 | { | ||
153 | FILE *filep; | ||
154 | size_t records_read = 0; | ||
155 | struct kvp_record *record = kvp_file_info[pool].records; | ||
156 | struct kvp_record *readp; | ||
157 | int num_blocks = kvp_file_info[pool].num_blocks; | ||
158 | int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK; | ||
159 | |||
160 | kvp_acquire_lock(pool); | ||
161 | |||
162 | filep = fopen(kvp_file_info[pool].fname, "r"); | ||
163 | if (!filep) { | ||
164 | kvp_release_lock(pool); | ||
165 | syslog(LOG_ERR, "Failed to open file, pool: %d", pool); | ||
166 | exit(-1); | ||
167 | } | ||
168 | while (!feof(filep)) { | ||
169 | readp = &record[records_read]; | ||
170 | records_read += fread(readp, sizeof(struct kvp_record), | ||
171 | ENTRIES_PER_BLOCK * num_blocks, | ||
172 | filep); | ||
173 | |||
174 | if (!feof(filep)) { | ||
175 | /* | ||
176 | * We have more data to read. | ||
177 | */ | ||
178 | num_blocks++; | ||
179 | record = realloc(record, alloc_unit * num_blocks); | ||
180 | |||
181 | if (record == NULL) { | ||
182 | syslog(LOG_ERR, "malloc failed"); | ||
183 | exit(-1); | ||
184 | } | ||
185 | continue; | ||
186 | } | ||
187 | break; | ||
188 | } | ||
189 | |||
190 | kvp_file_info[pool].num_blocks = num_blocks; | ||
191 | kvp_file_info[pool].records = record; | ||
192 | kvp_file_info[pool].num_records = records_read; | ||
193 | |||
194 | kvp_release_lock(pool); | ||
195 | } | ||
196 | static int kvp_file_init(void) | ||
197 | { | ||
198 | int ret, fd; | ||
199 | FILE *filep; | ||
200 | size_t records_read; | ||
201 | __u8 *fname; | ||
202 | struct kvp_record *record; | ||
203 | struct kvp_record *readp; | ||
204 | int num_blocks; | ||
205 | int i; | ||
206 | int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK; | ||
207 | |||
208 | if (access("/var/opt/hyperv", F_OK)) { | ||
209 | if (mkdir("/var/opt/hyperv", S_IRUSR | S_IWUSR | S_IROTH)) { | ||
210 | syslog(LOG_ERR, " Failed to create /var/opt/hyperv"); | ||
211 | exit(-1); | ||
212 | } | ||
213 | } | ||
214 | |||
215 | for (i = 0; i < KVP_POOL_COUNT; i++) { | ||
216 | fname = kvp_file_info[i].fname; | ||
217 | records_read = 0; | ||
218 | num_blocks = 1; | ||
219 | sprintf(fname, "/var/opt/hyperv/.kvp_pool_%d", i); | ||
220 | fd = open(fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IROTH); | ||
221 | |||
222 | if (fd == -1) | ||
223 | return 1; | ||
224 | |||
225 | |||
226 | filep = fopen(fname, "r"); | ||
227 | if (!filep) | ||
228 | return 1; | ||
229 | |||
230 | record = malloc(alloc_unit * num_blocks); | ||
231 | if (record == NULL) { | ||
232 | fclose(filep); | ||
233 | return 1; | ||
234 | } | ||
235 | while (!feof(filep)) { | ||
236 | readp = &record[records_read]; | ||
237 | records_read += fread(readp, sizeof(struct kvp_record), | ||
238 | ENTRIES_PER_BLOCK, | ||
239 | filep); | ||
240 | |||
241 | if (!feof(filep)) { | ||
242 | /* | ||
243 | * We have more data to read. | ||
244 | */ | ||
245 | num_blocks++; | ||
246 | record = realloc(record, alloc_unit * | ||
247 | num_blocks); | ||
248 | if (record == NULL) { | ||
249 | fclose(filep); | ||
250 | return 1; | ||
251 | } | ||
252 | continue; | ||
253 | } | ||
254 | break; | ||
255 | } | ||
256 | kvp_file_info[i].fd = fd; | ||
257 | kvp_file_info[i].num_blocks = num_blocks; | ||
258 | kvp_file_info[i].records = record; | ||
259 | kvp_file_info[i].num_records = records_read; | ||
260 | fclose(filep); | ||
261 | |||
262 | } | ||
263 | |||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | static int kvp_key_delete(int pool, __u8 *key, int key_size) | ||
268 | { | ||
269 | int i; | ||
270 | int j, k; | ||
271 | int num_records; | ||
272 | struct kvp_record *record; | ||
273 | |||
274 | /* | ||
275 | * First update the in-memory state. | ||
276 | */ | ||
277 | kvp_update_mem_state(pool); | ||
278 | |||
279 | num_records = kvp_file_info[pool].num_records; | ||
280 | record = kvp_file_info[pool].records; | ||
281 | |||
282 | for (i = 0; i < num_records; i++) { | ||
283 | if (memcmp(key, record[i].key, key_size)) | ||
284 | continue; | ||
285 | /* | ||
286 | * Found a match; just move the remaining | ||
287 | * entries up. | ||
288 | */ | ||
289 | if (i == num_records) { | ||
290 | kvp_file_info[pool].num_records--; | ||
291 | kvp_update_file(pool); | ||
292 | return 0; | ||
293 | } | ||
294 | |||
295 | j = i; | ||
296 | k = j + 1; | ||
297 | for (; k < num_records; k++) { | ||
298 | strcpy(record[j].key, record[k].key); | ||
299 | strcpy(record[j].value, record[k].value); | ||
300 | j++; | ||
301 | } | ||
302 | |||
303 | kvp_file_info[pool].num_records--; | ||
304 | kvp_update_file(pool); | ||
305 | return 0; | ||
306 | } | ||
307 | return 1; | ||
308 | } | ||
309 | |||
310 | static int kvp_key_add_or_modify(int pool, __u8 *key, int key_size, __u8 *value, | ||
311 | int value_size) | ||
312 | { | ||
313 | int i; | ||
314 | int j, k; | ||
315 | int num_records; | ||
316 | struct kvp_record *record; | ||
317 | int num_blocks; | ||
318 | |||
319 | if ((key_size > HV_KVP_EXCHANGE_MAX_KEY_SIZE) || | ||
320 | (value_size > HV_KVP_EXCHANGE_MAX_VALUE_SIZE)) | ||
321 | return 1; | ||
322 | |||
323 | /* | ||
324 | * First update the in-memory state. | ||
325 | */ | ||
326 | kvp_update_mem_state(pool); | ||
327 | |||
328 | num_records = kvp_file_info[pool].num_records; | ||
329 | record = kvp_file_info[pool].records; | ||
330 | num_blocks = kvp_file_info[pool].num_blocks; | ||
331 | |||
332 | for (i = 0; i < num_records; i++) { | ||
333 | if (memcmp(key, record[i].key, key_size)) | ||
334 | continue; | ||
335 | /* | ||
336 | * Found a match; just update the value - | ||
337 | * this is the modify case. | ||
338 | */ | ||
339 | memcpy(record[i].value, value, value_size); | ||
340 | kvp_update_file(pool); | ||
341 | return 0; | ||
342 | } | ||
343 | |||
344 | /* | ||
345 | * Need to add a new entry; | ||
346 | */ | ||
347 | if (num_records == (ENTRIES_PER_BLOCK * num_blocks)) { | ||
348 | /* Need to allocate a larger array for reg entries. */ | ||
349 | record = realloc(record, sizeof(struct kvp_record) * | ||
350 | ENTRIES_PER_BLOCK * (num_blocks + 1)); | ||
351 | |||
352 | if (record == NULL) | ||
353 | return 1; | ||
354 | kvp_file_info[pool].num_blocks++; | ||
355 | |||
356 | } | ||
357 | memcpy(record[i].value, value, value_size); | ||
358 | memcpy(record[i].key, key, key_size); | ||
359 | kvp_file_info[pool].records = record; | ||
360 | kvp_file_info[pool].num_records++; | ||
361 | kvp_update_file(pool); | ||
362 | return 0; | ||
363 | } | ||
364 | |||
365 | static int kvp_get_value(int pool, __u8 *key, int key_size, __u8 *value, | ||
366 | int value_size) | ||
367 | { | ||
368 | int i; | ||
369 | int num_records; | ||
370 | struct kvp_record *record; | ||
371 | |||
372 | if ((key_size > HV_KVP_EXCHANGE_MAX_KEY_SIZE) || | ||
373 | (value_size > HV_KVP_EXCHANGE_MAX_VALUE_SIZE)) | ||
374 | return 1; | ||
375 | |||
376 | /* | ||
377 | * First update the in-memory state. | ||
378 | */ | ||
379 | kvp_update_mem_state(pool); | ||
380 | |||
381 | num_records = kvp_file_info[pool].num_records; | ||
382 | record = kvp_file_info[pool].records; | ||
383 | |||
384 | for (i = 0; i < num_records; i++) { | ||
385 | if (memcmp(key, record[i].key, key_size)) | ||
386 | continue; | ||
387 | /* | ||
388 | * Found a match; just copy the value out. | ||
389 | */ | ||
390 | memcpy(value, record[i].value, value_size); | ||
391 | return 0; | ||
392 | } | ||
393 | |||
394 | return 1; | ||
395 | } | ||
396 | |||
397 | static void kvp_pool_enumerate(int pool, int index, __u8 *key, int key_size, | ||
398 | __u8 *value, int value_size) | ||
399 | { | ||
400 | struct kvp_record *record; | ||
401 | |||
402 | /* | ||
403 | * First update our in-memory database. | ||
404 | */ | ||
405 | kvp_update_mem_state(pool); | ||
406 | record = kvp_file_info[pool].records; | ||
407 | |||
408 | if (index >= kvp_file_info[pool].num_records) { | ||
409 | /* | ||
410 | * This is an invalid index; terminate enumeration; | ||
411 | * - a NULL value will do the trick. | ||
412 | */ | ||
413 | strcpy(value, ""); | ||
414 | return; | ||
415 | } | ||
416 | |||
417 | memcpy(key, record[index].key, key_size); | ||
418 | memcpy(value, record[index].value, value_size); | ||
419 | } | ||
420 | |||
421 | |||
112 | void kvp_get_os_info(void) | 422 | void kvp_get_os_info(void) |
113 | { | 423 | { |
114 | FILE *file; | 424 | FILE *file; |
@@ -332,7 +642,7 @@ int main(void) | |||
332 | struct pollfd pfd; | 642 | struct pollfd pfd; |
333 | struct nlmsghdr *incoming_msg; | 643 | struct nlmsghdr *incoming_msg; |
334 | struct cn_msg *incoming_cn_msg; | 644 | struct cn_msg *incoming_cn_msg; |
335 | struct hv_ku_msg *hv_msg; | 645 | struct hv_kvp_msg *hv_msg; |
336 | char *p; | 646 | char *p; |
337 | char *key_value; | 647 | char *key_value; |
338 | char *key_name; | 648 | char *key_name; |
@@ -345,6 +655,11 @@ int main(void) | |||
345 | */ | 655 | */ |
346 | kvp_get_os_info(); | 656 | kvp_get_os_info(); |
347 | 657 | ||
658 | if (kvp_file_init()) { | ||
659 | syslog(LOG_ERR, "Failed to initialize the pools"); | ||
660 | exit(-1); | ||
661 | } | ||
662 | |||
348 | fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR); | 663 | fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR); |
349 | if (fd < 0) { | 664 | if (fd < 0) { |
350 | syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd); | 665 | syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd); |
@@ -370,9 +685,11 @@ int main(void) | |||
370 | message = (struct cn_msg *)kvp_send_buffer; | 685 | message = (struct cn_msg *)kvp_send_buffer; |
371 | message->id.idx = CN_KVP_IDX; | 686 | message->id.idx = CN_KVP_IDX; |
372 | message->id.val = CN_KVP_VAL; | 687 | message->id.val = CN_KVP_VAL; |
373 | message->seq = KVP_REGISTER; | 688 | |
689 | hv_msg = (struct hv_kvp_msg *)message->data; | ||
690 | hv_msg->kvp_hdr.operation = KVP_OP_REGISTER; | ||
374 | message->ack = 0; | 691 | message->ack = 0; |
375 | message->len = 0; | 692 | message->len = sizeof(struct hv_kvp_msg); |
376 | 693 | ||
377 | len = netlink_send(fd, message); | 694 | len = netlink_send(fd, message); |
378 | if (len < 0) { | 695 | if (len < 0) { |
@@ -398,14 +715,15 @@ int main(void) | |||
398 | 715 | ||
399 | incoming_msg = (struct nlmsghdr *)kvp_recv_buffer; | 716 | incoming_msg = (struct nlmsghdr *)kvp_recv_buffer; |
400 | incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg); | 717 | incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg); |
718 | hv_msg = (struct hv_kvp_msg *)incoming_cn_msg->data; | ||
401 | 719 | ||
402 | switch (incoming_cn_msg->seq) { | 720 | switch (hv_msg->kvp_hdr.operation) { |
403 | case KVP_REGISTER: | 721 | case KVP_OP_REGISTER: |
404 | /* | 722 | /* |
405 | * Driver is registering with us; stash away the version | 723 | * Driver is registering with us; stash away the version |
406 | * information. | 724 | * information. |
407 | */ | 725 | */ |
408 | p = (char *)incoming_cn_msg->data; | 726 | p = (char *)hv_msg->body.kvp_register.version; |
409 | lic_version = malloc(strlen(p) + 1); | 727 | lic_version = malloc(strlen(p) + 1); |
410 | if (lic_version) { | 728 | if (lic_version) { |
411 | strcpy(lic_version, p); | 729 | strcpy(lic_version, p); |
@@ -416,17 +734,65 @@ int main(void) | |||
416 | } | 734 | } |
417 | continue; | 735 | continue; |
418 | 736 | ||
419 | case KVP_KERNEL_GET: | 737 | /* |
738 | * The current protocol with the kernel component uses a | ||
739 | * NULL key name to pass an error condition. | ||
740 | * For the SET, GET and DELETE operations, | ||
741 | * use the existing protocol to pass back error. | ||
742 | */ | ||
743 | |||
744 | case KVP_OP_SET: | ||
745 | if (kvp_key_add_or_modify(hv_msg->kvp_hdr.pool, | ||
746 | hv_msg->body.kvp_set.data.key, | ||
747 | hv_msg->body.kvp_set.data.key_size, | ||
748 | hv_msg->body.kvp_set.data.value, | ||
749 | hv_msg->body.kvp_set.data.value_size)) | ||
750 | strcpy(hv_msg->body.kvp_set.data.key, ""); | ||
751 | break; | ||
752 | |||
753 | case KVP_OP_GET: | ||
754 | if (kvp_get_value(hv_msg->kvp_hdr.pool, | ||
755 | hv_msg->body.kvp_set.data.key, | ||
756 | hv_msg->body.kvp_set.data.key_size, | ||
757 | hv_msg->body.kvp_set.data.value, | ||
758 | hv_msg->body.kvp_set.data.value_size)) | ||
759 | strcpy(hv_msg->body.kvp_set.data.key, ""); | ||
760 | break; | ||
761 | |||
762 | case KVP_OP_DELETE: | ||
763 | if (kvp_key_delete(hv_msg->kvp_hdr.pool, | ||
764 | hv_msg->body.kvp_delete.key, | ||
765 | hv_msg->body.kvp_delete.key_size)) | ||
766 | strcpy(hv_msg->body.kvp_delete.key, ""); | ||
420 | break; | 767 | break; |
768 | |||
421 | default: | 769 | default: |
422 | continue; | 770 | break; |
771 | } | ||
772 | |||
773 | if (hv_msg->kvp_hdr.operation != KVP_OP_ENUMERATE) | ||
774 | goto kvp_done; | ||
775 | |||
776 | /* | ||
777 | * If the pool is KVP_POOL_AUTO, dynamically generate | ||
778 | * both the key and the value; if not read from the | ||
779 | * appropriate pool. | ||
780 | */ | ||
781 | if (hv_msg->kvp_hdr.pool != KVP_POOL_AUTO) { | ||
782 | kvp_pool_enumerate(hv_msg->kvp_hdr.pool, | ||
783 | hv_msg->body.kvp_enum_data.index, | ||
784 | hv_msg->body.kvp_enum_data.data.key, | ||
785 | HV_KVP_EXCHANGE_MAX_KEY_SIZE, | ||
786 | hv_msg->body.kvp_enum_data.data.value, | ||
787 | HV_KVP_EXCHANGE_MAX_VALUE_SIZE); | ||
788 | goto kvp_done; | ||
423 | } | 789 | } |
424 | 790 | ||
425 | hv_msg = (struct hv_ku_msg *)incoming_cn_msg->data; | 791 | hv_msg = (struct hv_kvp_msg *)incoming_cn_msg->data; |
426 | key_name = (char *)hv_msg->kvp_key; | 792 | key_name = (char *)hv_msg->body.kvp_enum_data.data.key; |
427 | key_value = (char *)hv_msg->kvp_value; | 793 | key_value = (char *)hv_msg->body.kvp_enum_data.data.value; |
428 | 794 | ||
429 | switch (hv_msg->kvp_index) { | 795 | switch (hv_msg->body.kvp_enum_data.index) { |
430 | case FullyQualifiedDomainName: | 796 | case FullyQualifiedDomainName: |
431 | kvp_get_domain_name(key_value, | 797 | kvp_get_domain_name(key_value, |
432 | HV_KVP_EXCHANGE_MAX_VALUE_SIZE); | 798 | HV_KVP_EXCHANGE_MAX_VALUE_SIZE); |
@@ -483,12 +849,12 @@ int main(void) | |||
483 | * already in the receive buffer. Update the cn_msg header to | 849 | * already in the receive buffer. Update the cn_msg header to |
484 | * reflect the key value that has been added to the message | 850 | * reflect the key value that has been added to the message |
485 | */ | 851 | */ |
852 | kvp_done: | ||
486 | 853 | ||
487 | incoming_cn_msg->id.idx = CN_KVP_IDX; | 854 | incoming_cn_msg->id.idx = CN_KVP_IDX; |
488 | incoming_cn_msg->id.val = CN_KVP_VAL; | 855 | incoming_cn_msg->id.val = CN_KVP_VAL; |
489 | incoming_cn_msg->seq = KVP_USER_SET; | ||
490 | incoming_cn_msg->ack = 0; | 856 | incoming_cn_msg->ack = 0; |
491 | incoming_cn_msg->len = sizeof(struct hv_ku_msg); | 857 | incoming_cn_msg->len = sizeof(struct hv_kvp_msg); |
492 | 858 | ||
493 | len = netlink_send(fd, incoming_cn_msg); | 859 | len = netlink_send(fd, incoming_cn_msg); |
494 | if (len < 0) { | 860 | if (len < 0) { |
diff --git a/tools/include/tools/be_byteshift.h b/tools/include/tools/be_byteshift.h new file mode 100644 index 000000000000..f4912e2668ba --- /dev/null +++ b/tools/include/tools/be_byteshift.h | |||
@@ -0,0 +1,70 @@ | |||
1 | #ifndef _TOOLS_BE_BYTESHIFT_H | ||
2 | #define _TOOLS_BE_BYTESHIFT_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | |||
6 | static inline __u16 __get_unaligned_be16(const __u8 *p) | ||
7 | { | ||
8 | return p[0] << 8 | p[1]; | ||
9 | } | ||
10 | |||
11 | static inline __u32 __get_unaligned_be32(const __u8 *p) | ||
12 | { | ||
13 | return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; | ||
14 | } | ||
15 | |||
16 | static inline __u64 __get_unaligned_be64(const __u8 *p) | ||
17 | { | ||
18 | return (__u64)__get_unaligned_be32(p) << 32 | | ||
19 | __get_unaligned_be32(p + 4); | ||
20 | } | ||
21 | |||
22 | static inline void __put_unaligned_be16(__u16 val, __u8 *p) | ||
23 | { | ||
24 | *p++ = val >> 8; | ||
25 | *p++ = val; | ||
26 | } | ||
27 | |||
28 | static inline void __put_unaligned_be32(__u32 val, __u8 *p) | ||
29 | { | ||
30 | __put_unaligned_be16(val >> 16, p); | ||
31 | __put_unaligned_be16(val, p + 2); | ||
32 | } | ||
33 | |||
34 | static inline void __put_unaligned_be64(__u64 val, __u8 *p) | ||
35 | { | ||
36 | __put_unaligned_be32(val >> 32, p); | ||
37 | __put_unaligned_be32(val, p + 4); | ||
38 | } | ||
39 | |||
40 | static inline __u16 get_unaligned_be16(const void *p) | ||
41 | { | ||
42 | return __get_unaligned_be16((const __u8 *)p); | ||
43 | } | ||
44 | |||
45 | static inline __u32 get_unaligned_be32(const void *p) | ||
46 | { | ||
47 | return __get_unaligned_be32((const __u8 *)p); | ||
48 | } | ||
49 | |||
50 | static inline __u64 get_unaligned_be64(const void *p) | ||
51 | { | ||
52 | return __get_unaligned_be64((const __u8 *)p); | ||
53 | } | ||
54 | |||
55 | static inline void put_unaligned_be16(__u16 val, void *p) | ||
56 | { | ||
57 | __put_unaligned_be16(val, p); | ||
58 | } | ||
59 | |||
60 | static inline void put_unaligned_be32(__u32 val, void *p) | ||
61 | { | ||
62 | __put_unaligned_be32(val, p); | ||
63 | } | ||
64 | |||
65 | static inline void put_unaligned_be64(__u64 val, void *p) | ||
66 | { | ||
67 | __put_unaligned_be64(val, p); | ||
68 | } | ||
69 | |||
70 | #endif /* _TOOLS_BE_BYTESHIFT_H */ | ||
diff --git a/tools/include/tools/le_byteshift.h b/tools/include/tools/le_byteshift.h new file mode 100644 index 000000000000..c99d45a68bda --- /dev/null +++ b/tools/include/tools/le_byteshift.h | |||
@@ -0,0 +1,70 @@ | |||
1 | #ifndef _TOOLS_LE_BYTESHIFT_H | ||
2 | #define _TOOLS_LE_BYTESHIFT_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | |||
6 | static inline __u16 __get_unaligned_le16(const __u8 *p) | ||
7 | { | ||
8 | return p[0] | p[1] << 8; | ||
9 | } | ||
10 | |||
11 | static inline __u32 __get_unaligned_le32(const __u8 *p) | ||
12 | { | ||
13 | return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; | ||
14 | } | ||
15 | |||
16 | static inline __u64 __get_unaligned_le64(const __u8 *p) | ||
17 | { | ||
18 | return (__u64)__get_unaligned_le32(p + 4) << 32 | | ||
19 | __get_unaligned_le32(p); | ||
20 | } | ||
21 | |||
22 | static inline void __put_unaligned_le16(__u16 val, __u8 *p) | ||
23 | { | ||
24 | *p++ = val; | ||
25 | *p++ = val >> 8; | ||
26 | } | ||
27 | |||
28 | static inline void __put_unaligned_le32(__u32 val, __u8 *p) | ||
29 | { | ||
30 | __put_unaligned_le16(val >> 16, p + 2); | ||
31 | __put_unaligned_le16(val, p); | ||
32 | } | ||
33 | |||
34 | static inline void __put_unaligned_le64(__u64 val, __u8 *p) | ||
35 | { | ||
36 | __put_unaligned_le32(val >> 32, p + 4); | ||
37 | __put_unaligned_le32(val, p); | ||
38 | } | ||
39 | |||
40 | static inline __u16 get_unaligned_le16(const void *p) | ||
41 | { | ||
42 | return __get_unaligned_le16((const __u8 *)p); | ||
43 | } | ||
44 | |||
45 | static inline __u32 get_unaligned_le32(const void *p) | ||
46 | { | ||
47 | return __get_unaligned_le32((const __u8 *)p); | ||
48 | } | ||
49 | |||
50 | static inline __u64 get_unaligned_le64(const void *p) | ||
51 | { | ||
52 | return __get_unaligned_le64((const __u8 *)p); | ||
53 | } | ||
54 | |||
55 | static inline void put_unaligned_le16(__u16 val, void *p) | ||
56 | { | ||
57 | __put_unaligned_le16(val, p); | ||
58 | } | ||
59 | |||
60 | static inline void put_unaligned_le32(__u32 val, void *p) | ||
61 | { | ||
62 | __put_unaligned_le32(val, p); | ||
63 | } | ||
64 | |||
65 | static inline void put_unaligned_le64(__u64 val, void *p) | ||
66 | { | ||
67 | __put_unaligned_le64(val, p); | ||
68 | } | ||
69 | |||
70 | #endif /* _TOOLS_LE_BYTESHIFT_H */ | ||
diff --git a/tools/perf/util/include/linux/bitops.h b/tools/perf/util/include/linux/bitops.h index 62cdee78db7b..f1584833bd22 100644 --- a/tools/perf/util/include/linux/bitops.h +++ b/tools/perf/util/include/linux/bitops.h | |||
@@ -15,7 +15,7 @@ | |||
15 | (bit) = find_next_bit((addr), (size), (bit) + 1)) | 15 | (bit) = find_next_bit((addr), (size), (bit) + 1)) |
16 | 16 | ||
17 | /* same as for_each_set_bit() but use bit as value to start with */ | 17 | /* same as for_each_set_bit() but use bit as value to start with */ |
18 | #define for_each_set_bit_cont(bit, addr, size) \ | 18 | #define for_each_set_bit_from(bit, addr, size) \ |
19 | for ((bit) = find_next_bit((addr), (size), (bit)); \ | 19 | for ((bit) = find_next_bit((addr), (size), (bit)); \ |
20 | (bit) < (size); \ | 20 | (bit) < (size); \ |
21 | (bit) = find_next_bit((addr), (size), (bit) + 1)) | 21 | (bit) = find_next_bit((addr), (size), (bit) + 1)) |
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 9507c4b251a8..95d6a6f7c33a 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -46,6 +46,7 @@ my %default = ( | |||
46 | "DIE_ON_FAILURE" => 1, | 46 | "DIE_ON_FAILURE" => 1, |
47 | "SSH_EXEC" => "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND", | 47 | "SSH_EXEC" => "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND", |
48 | "SCP_TO_TARGET" => "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE", | 48 | "SCP_TO_TARGET" => "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE", |
49 | "SCP_TO_TARGET_INSTALL" => "\${SCP_TO_TARGET}", | ||
49 | "REBOOT" => "ssh \$SSH_USER\@\$MACHINE reboot", | 50 | "REBOOT" => "ssh \$SSH_USER\@\$MACHINE reboot", |
50 | "STOP_AFTER_SUCCESS" => 10, | 51 | "STOP_AFTER_SUCCESS" => 10, |
51 | "STOP_AFTER_FAILURE" => 60, | 52 | "STOP_AFTER_FAILURE" => 60, |
@@ -86,11 +87,13 @@ my $reboot_on_error; | |||
86 | my $switch_to_good; | 87 | my $switch_to_good; |
87 | my $switch_to_test; | 88 | my $switch_to_test; |
88 | my $poweroff_on_error; | 89 | my $poweroff_on_error; |
90 | my $reboot_on_success; | ||
89 | my $die_on_failure; | 91 | my $die_on_failure; |
90 | my $powercycle_after_reboot; | 92 | my $powercycle_after_reboot; |
91 | my $poweroff_after_halt; | 93 | my $poweroff_after_halt; |
92 | my $ssh_exec; | 94 | my $ssh_exec; |
93 | my $scp_to_target; | 95 | my $scp_to_target; |
96 | my $scp_to_target_install; | ||
94 | my $power_off; | 97 | my $power_off; |
95 | my $grub_menu; | 98 | my $grub_menu; |
96 | my $grub_number; | 99 | my $grub_number; |
@@ -211,6 +214,7 @@ my %option_map = ( | |||
211 | "SWITCH_TO_GOOD" => \$switch_to_good, | 214 | "SWITCH_TO_GOOD" => \$switch_to_good, |
212 | "SWITCH_TO_TEST" => \$switch_to_test, | 215 | "SWITCH_TO_TEST" => \$switch_to_test, |
213 | "POWEROFF_ON_ERROR" => \$poweroff_on_error, | 216 | "POWEROFF_ON_ERROR" => \$poweroff_on_error, |
217 | "REBOOT_ON_SUCCESS" => \$reboot_on_success, | ||
214 | "DIE_ON_FAILURE" => \$die_on_failure, | 218 | "DIE_ON_FAILURE" => \$die_on_failure, |
215 | "POWER_OFF" => \$power_off, | 219 | "POWER_OFF" => \$power_off, |
216 | "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot, | 220 | "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot, |
@@ -243,6 +247,7 @@ my %option_map = ( | |||
243 | "BUILD_TARGET" => \$build_target, | 247 | "BUILD_TARGET" => \$build_target, |
244 | "SSH_EXEC" => \$ssh_exec, | 248 | "SSH_EXEC" => \$ssh_exec, |
245 | "SCP_TO_TARGET" => \$scp_to_target, | 249 | "SCP_TO_TARGET" => \$scp_to_target, |
250 | "SCP_TO_TARGET_INSTALL" => \$scp_to_target_install, | ||
246 | "CHECKOUT" => \$checkout, | 251 | "CHECKOUT" => \$checkout, |
247 | "TARGET_IMAGE" => \$target_image, | 252 | "TARGET_IMAGE" => \$target_image, |
248 | "LOCALVERSION" => \$localversion, | 253 | "LOCALVERSION" => \$localversion, |
@@ -1113,7 +1118,6 @@ sub reboot_to_good { | |||
1113 | 1118 | ||
1114 | if (defined($switch_to_good)) { | 1119 | if (defined($switch_to_good)) { |
1115 | run_command $switch_to_good; | 1120 | run_command $switch_to_good; |
1116 | return; | ||
1117 | } | 1121 | } |
1118 | 1122 | ||
1119 | reboot $time; | 1123 | reboot $time; |
@@ -1349,8 +1353,7 @@ sub run_ssh { | |||
1349 | } | 1353 | } |
1350 | 1354 | ||
1351 | sub run_scp { | 1355 | sub run_scp { |
1352 | my ($src, $dst) = @_; | 1356 | my ($src, $dst, $cp_scp) = @_; |
1353 | my $cp_scp = $scp_to_target; | ||
1354 | 1357 | ||
1355 | $cp_scp =~ s/\$SRC_FILE/$src/g; | 1358 | $cp_scp =~ s/\$SRC_FILE/$src/g; |
1356 | $cp_scp =~ s/\$DST_FILE/$dst/g; | 1359 | $cp_scp =~ s/\$DST_FILE/$dst/g; |
@@ -1358,6 +1361,22 @@ sub run_scp { | |||
1358 | return run_command "$cp_scp"; | 1361 | return run_command "$cp_scp"; |
1359 | } | 1362 | } |
1360 | 1363 | ||
1364 | sub run_scp_install { | ||
1365 | my ($src, $dst) = @_; | ||
1366 | |||
1367 | my $cp_scp = $scp_to_target_install; | ||
1368 | |||
1369 | return run_scp($src, $dst, $cp_scp); | ||
1370 | } | ||
1371 | |||
1372 | sub run_scp_mod { | ||
1373 | my ($src, $dst) = @_; | ||
1374 | |||
1375 | my $cp_scp = $scp_to_target; | ||
1376 | |||
1377 | return run_scp($src, $dst, $cp_scp); | ||
1378 | } | ||
1379 | |||
1361 | sub get_grub_index { | 1380 | sub get_grub_index { |
1362 | 1381 | ||
1363 | if ($reboot_type ne "grub") { | 1382 | if ($reboot_type ne "grub") { |
@@ -1460,6 +1479,7 @@ sub get_sha1 { | |||
1460 | sub monitor { | 1479 | sub monitor { |
1461 | my $booted = 0; | 1480 | my $booted = 0; |
1462 | my $bug = 0; | 1481 | my $bug = 0; |
1482 | my $bug_ignored = 0; | ||
1463 | my $skip_call_trace = 0; | 1483 | my $skip_call_trace = 0; |
1464 | my $loops; | 1484 | my $loops; |
1465 | 1485 | ||
@@ -1531,9 +1551,13 @@ sub monitor { | |||
1531 | } | 1551 | } |
1532 | 1552 | ||
1533 | if ($full_line =~ /call trace:/i) { | 1553 | if ($full_line =~ /call trace:/i) { |
1534 | if (!$ignore_errors && !$bug && !$skip_call_trace) { | 1554 | if (!$bug && !$skip_call_trace) { |
1535 | $bug = 1; | 1555 | if ($ignore_errors) { |
1536 | $failure_start = time; | 1556 | $bug_ignored = 1; |
1557 | } else { | ||
1558 | $bug = 1; | ||
1559 | $failure_start = time; | ||
1560 | } | ||
1537 | } | 1561 | } |
1538 | } | 1562 | } |
1539 | 1563 | ||
@@ -1595,6 +1619,10 @@ sub monitor { | |||
1595 | fail "failed - never got a boot prompt." and return 0; | 1619 | fail "failed - never got a boot prompt." and return 0; |
1596 | } | 1620 | } |
1597 | 1621 | ||
1622 | if ($bug_ignored) { | ||
1623 | doprint "WARNING: Call Trace detected but ignored due to IGNORE_ERRORS=1\n"; | ||
1624 | } | ||
1625 | |||
1598 | return 1; | 1626 | return 1; |
1599 | } | 1627 | } |
1600 | 1628 | ||
@@ -1621,7 +1649,7 @@ sub install { | |||
1621 | 1649 | ||
1622 | my $cp_target = eval_kernel_version $target_image; | 1650 | my $cp_target = eval_kernel_version $target_image; |
1623 | 1651 | ||
1624 | run_scp "$outputdir/$build_target", "$cp_target" or | 1652 | run_scp_install "$outputdir/$build_target", "$cp_target" or |
1625 | dodie "failed to copy image"; | 1653 | dodie "failed to copy image"; |
1626 | 1654 | ||
1627 | my $install_mods = 0; | 1655 | my $install_mods = 0; |
@@ -1643,7 +1671,7 @@ sub install { | |||
1643 | return; | 1671 | return; |
1644 | } | 1672 | } |
1645 | 1673 | ||
1646 | run_command "$make INSTALL_MOD_PATH=$tmpdir modules_install" or | 1674 | run_command "$make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$tmpdir modules_install" or |
1647 | dodie "Failed to install modules"; | 1675 | dodie "Failed to install modules"; |
1648 | 1676 | ||
1649 | my $modlib = "/lib/modules/$version"; | 1677 | my $modlib = "/lib/modules/$version"; |
@@ -1656,7 +1684,7 @@ sub install { | |||
1656 | run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or | 1684 | run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or |
1657 | dodie "making tarball"; | 1685 | dodie "making tarball"; |
1658 | 1686 | ||
1659 | run_scp "$tmpdir/$modtar", "/tmp" or | 1687 | run_scp_mod "$tmpdir/$modtar", "/tmp" or |
1660 | dodie "failed to copy modules"; | 1688 | dodie "failed to copy modules"; |
1661 | 1689 | ||
1662 | unlink "$tmpdir/$modtar"; | 1690 | unlink "$tmpdir/$modtar"; |
@@ -2601,7 +2629,7 @@ sub config_bisect { | |||
2601 | # read directly what we want to check | 2629 | # read directly what we want to check |
2602 | my %config_check; | 2630 | my %config_check; |
2603 | open (IN, $output_config) | 2631 | open (IN, $output_config) |
2604 | or dodie "faied to open $output_config"; | 2632 | or dodie "failed to open $output_config"; |
2605 | 2633 | ||
2606 | while (<IN>) { | 2634 | while (<IN>) { |
2607 | if (/^((CONFIG\S*)=.*)/) { | 2635 | if (/^((CONFIG\S*)=.*)/) { |
@@ -3526,8 +3554,10 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3526 | die "failed to checkout $checkout"; | 3554 | die "failed to checkout $checkout"; |
3527 | } | 3555 | } |
3528 | 3556 | ||
3529 | $no_reboot = 0; | 3557 | # A test may opt to not reboot the box |
3530 | 3558 | if ($reboot_on_success) { | |
3559 | $no_reboot = 0; | ||
3560 | } | ||
3531 | 3561 | ||
3532 | if ($test_type eq "bisect") { | 3562 | if ($test_type eq "bisect") { |
3533 | bisect $i; | 3563 | bisect $i; |
@@ -3572,8 +3602,12 @@ if ($opt{"POWEROFF_ON_SUCCESS"}) { | |||
3572 | halt; | 3602 | halt; |
3573 | } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) { | 3603 | } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) { |
3574 | reboot_to_good; | 3604 | reboot_to_good; |
3605 | } elsif (defined($switch_to_good)) { | ||
3606 | # still need to get to the good kernel | ||
3607 | run_command $switch_to_good; | ||
3575 | } | 3608 | } |
3576 | 3609 | ||
3610 | |||
3577 | doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n"; | 3611 | doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n"; |
3578 | 3612 | ||
3579 | exit 0; | 3613 | exit 0; |
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf index 5ea04c6a71bf..b682456afda8 100644 --- a/tools/testing/ktest/sample.conf +++ b/tools/testing/ktest/sample.conf | |||
@@ -710,10 +710,18 @@ | |||
710 | # The variables SSH_USER, MACHINE and SSH_COMMAND are defined | 710 | # The variables SSH_USER, MACHINE and SSH_COMMAND are defined |
711 | #SSH_EXEC = ssh $SSH_USER@$MACHINE $SSH_COMMAND"; | 711 | #SSH_EXEC = ssh $SSH_USER@$MACHINE $SSH_COMMAND"; |
712 | 712 | ||
713 | # The way to copy a file to the target | 713 | # The way to copy a file to the target (install and modules) |
714 | # (default scp $SRC_FILE $SSH_USER@$MACHINE:$DST_FILE) | 714 | # (default scp $SRC_FILE $SSH_USER@$MACHINE:$DST_FILE) |
715 | # The variables SSH_USER, MACHINE, SRC_FILE and DST_FILE are defined. | 715 | # The variables SSH_USER, MACHINE are defined by the config |
716 | #SCP_TO_TARGET = scp $SRC_FILE $SSH_USER@$MACHINE:$DST_FILE | 716 | # SRC_FILE and DST_FILE are ktest internal variables and |
717 | # should only have '$' and not the '${}' notation. | ||
718 | # (default scp $SRC_FILE ${SSH_USER}@${MACHINE}:$DST_FILE) | ||
719 | #SCP_TO_TARGET = echo skip scp for $SRC_FILE $DST_FILE | ||
720 | |||
721 | # If install needs to be different than modules, then this | ||
722 | # option will override the SCP_TO_TARGET for installation. | ||
723 | # (default ${SCP_TO_TARGET} ) | ||
724 | #SCP_TO_TARGET_INSTALL = scp $SRC_FILE tftp@tftpserver:$DST_FILE | ||
717 | 725 | ||
718 | # The nice way to reboot the target | 726 | # The nice way to reboot the target |
719 | # (default ssh $SSH_USER@$MACHINE reboot) | 727 | # (default ssh $SSH_USER@$MACHINE reboot) |
diff --git a/tools/usb/Makefile b/tools/usb/Makefile index 8b704af14349..396d6c44e9d7 100644 --- a/tools/usb/Makefile +++ b/tools/usb/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | CC = $(CROSS_COMPILE)gcc | 3 | CC = $(CROSS_COMPILE)gcc |
4 | PTHREAD_LIBS = -lpthread | 4 | PTHREAD_LIBS = -lpthread |
5 | WARNINGS = -Wall -Wextra | 5 | WARNINGS = -Wall -Wextra |
6 | CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) | 6 | CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) -I../include |
7 | 7 | ||
8 | all: testusb ffs-test | 8 | all: testusb ffs-test |
9 | %: %.c | 9 | %: %.c |
diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c index b9c798631699..4b107b5e623f 100644 --- a/tools/usb/ffs-test.c +++ b/tools/usb/ffs-test.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * ffs-test.c.c -- user mode filesystem api for usb composite function | 2 | * ffs-test.c.c -- user mode filesystem api for usb composite function |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Samsung Electronics | 4 | * Copyright (C) 2010 Samsung Electronics |
5 | * Author: Michal Nazarewicz <m.nazarewicz@samsung.com> | 5 | * Author: Michal Nazarewicz <mina86@mina86.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
@@ -36,6 +36,7 @@ | |||
36 | #include <sys/stat.h> | 36 | #include <sys/stat.h> |
37 | #include <sys/types.h> | 37 | #include <sys/types.h> |
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | #include <tools/le_byteshift.h> | ||
39 | 40 | ||
40 | #include "../../include/linux/usb/functionfs.h" | 41 | #include "../../include/linux/usb/functionfs.h" |
41 | 42 | ||
@@ -47,34 +48,6 @@ | |||
47 | #define le32_to_cpu(x) le32toh(x) | 48 | #define le32_to_cpu(x) le32toh(x) |
48 | #define le16_to_cpu(x) le16toh(x) | 49 | #define le16_to_cpu(x) le16toh(x) |
49 | 50 | ||
50 | static inline __u16 get_unaligned_le16(const void *_ptr) | ||
51 | { | ||
52 | const __u8 *ptr = _ptr; | ||
53 | return ptr[0] | (ptr[1] << 8); | ||
54 | } | ||
55 | |||
56 | static inline __u32 get_unaligned_le32(const void *_ptr) | ||
57 | { | ||
58 | const __u8 *ptr = _ptr; | ||
59 | return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); | ||
60 | } | ||
61 | |||
62 | static inline void put_unaligned_le16(__u16 val, void *_ptr) | ||
63 | { | ||
64 | __u8 *ptr = _ptr; | ||
65 | *ptr++ = val; | ||
66 | *ptr++ = val >> 8; | ||
67 | } | ||
68 | |||
69 | static inline void put_unaligned_le32(__u32 val, void *_ptr) | ||
70 | { | ||
71 | __u8 *ptr = _ptr; | ||
72 | *ptr++ = val; | ||
73 | *ptr++ = val >> 8; | ||
74 | *ptr++ = val >> 16; | ||
75 | *ptr++ = val >> 24; | ||
76 | } | ||
77 | |||
78 | 51 | ||
79 | /******************** Messages and Errors ***********************************/ | 52 | /******************** Messages and Errors ***********************************/ |
80 | 53 | ||
diff --git a/tools/usb/testusb.c b/tools/usb/testusb.c index f08e89463842..6e0f56701e44 100644 --- a/tools/usb/testusb.c +++ b/tools/usb/testusb.c | |||
@@ -3,7 +3,7 @@ | |||
3 | /* | 3 | /* |
4 | * Copyright (c) 2002 by David Brownell | 4 | * Copyright (c) 2002 by David Brownell |
5 | * Copyright (c) 2010 by Samsung Electronics | 5 | * Copyright (c) 2010 by Samsung Electronics |
6 | * Author: Michal Nazarewicz <m.nazarewicz@samsung.com> | 6 | * Author: Michal Nazarewicz <mina86@mina86.com> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms of the GNU General Public License as published by the | 9 | * under the terms of the GNU General Public License as published by the |