1 // SPDX-License-Identifier: GPL-2.0-or-later 2 // 3 // packet-serdes-test.c - An application of Kunit to check serialization/deserialization of packets 4 // defined by IEEE 1394. 5 // 6 // Copyright (c) 2024 Takashi Sakamoto 7 8 #include <kunit/test.h> 9 10 #include <linux/firewire-constants.h> 11 12 #include "packet-header-definitions.h" 13 14 static void serialize_async_header_common(u32 header[ASYNC_HEADER_QUADLET_COUNT], 15 unsigned int dst_id, unsigned int tlabel, 16 unsigned int retry, unsigned int tcode, 17 unsigned int priority, unsigned int src_id) 18 { 19 async_header_set_destination(header, dst_id); 20 async_header_set_tlabel(header, tlabel); 21 async_header_set_retry(header, retry); 22 async_header_set_tcode(header, tcode); 23 async_header_set_priority(header, priority); 24 async_header_set_source(header, src_id); 25 } 26 27 static void serialize_async_header_request(u32 header[ASYNC_HEADER_QUADLET_COUNT], 28 unsigned int dst_id, unsigned int tlabel, 29 unsigned int retry, unsigned int tcode, 30 unsigned int priority, unsigned int src_id, u64 offset) 31 { 32 serialize_async_header_common(header, dst_id, tlabel, retry, tcode, priority, src_id); 33 async_header_set_offset(header, offset); 34 } 35 36 static void serialize_async_header_quadlet_request(u32 header[ASYNC_HEADER_QUADLET_COUNT], 37 unsigned int dst_id, unsigned int tlabel, 38 unsigned int retry, unsigned int tcode, 39 unsigned int priority, unsigned int src_id, 40 u64 offset) 41 { 42 serialize_async_header_request(header, dst_id, tlabel, retry, tcode, priority, src_id, 43 offset); 44 } 45 46 static void serialize_async_header_block_request(u32 header[ASYNC_HEADER_QUADLET_COUNT], 47 unsigned int dst_id, unsigned int tlabel, 48 unsigned int retry, unsigned int tcode, 49 unsigned int priority, unsigned int src_id, 50 u64 offset, unsigned int data_length, 51 unsigned int extended_tcode) 52 { 53 serialize_async_header_request(header, dst_id, tlabel, retry, tcode, priority, src_id, 54 offset); 55 async_header_set_data_length(header, data_length); 56 async_header_set_extended_tcode(header, extended_tcode); 57 } 58 59 static void serialize_async_header_response(u32 header[ASYNC_HEADER_QUADLET_COUNT], 60 unsigned int dst_id, unsigned int tlabel, 61 unsigned int retry, unsigned int tcode, 62 unsigned int priority, unsigned int src_id, 63 unsigned int rcode) 64 { 65 serialize_async_header_common(header, dst_id, tlabel, retry, tcode, priority, src_id); 66 async_header_set_rcode(header, rcode); 67 } 68 69 static void serialize_async_header_quadlet_response(u32 header[ASYNC_HEADER_QUADLET_COUNT], 70 unsigned int dst_id, unsigned int tlabel, 71 unsigned int retry, unsigned int tcode, 72 unsigned int priority, unsigned int src_id, 73 unsigned int rcode) 74 { 75 serialize_async_header_response(header, dst_id, tlabel, retry, tcode, priority, src_id, 76 rcode); 77 } 78 79 static void serialize_async_header_block_response(u32 header[ASYNC_HEADER_QUADLET_COUNT], 80 unsigned int dst_id, unsigned int tlabel, 81 unsigned int retry, unsigned int tcode, 82 unsigned int priority, unsigned int src_id, 83 unsigned int rcode, unsigned int data_length, 84 unsigned int extended_tcode) 85 { 86 serialize_async_header_response(header, dst_id, tlabel, retry, tcode, priority, src_id, 87 rcode); 88 async_header_set_data_length(header, data_length); 89 async_header_set_extended_tcode(header, extended_tcode); 90 } 91 92 static void deserialize_async_header_common(const u32 header[ASYNC_HEADER_QUADLET_COUNT], 93 unsigned int *dst_id, unsigned int *tlabel, 94 unsigned int *retry, unsigned int *tcode, 95 unsigned int *priority, unsigned int *src_id) 96 { 97 *dst_id = async_header_get_destination(header); 98 *tlabel = async_header_get_tlabel(header); 99 *retry = async_header_get_retry(header); 100 *tcode = async_header_get_tcode(header); 101 *priority = async_header_get_priority(header); 102 *src_id = async_header_get_source(header); 103 } 104 105 static void deserialize_async_header_request(const u32 header[ASYNC_HEADER_QUADLET_COUNT], 106 unsigned int *dst_id, unsigned int *tlabel, 107 unsigned int *retry, unsigned int *tcode, 108 unsigned int *priority, unsigned int *src_id, 109 u64 *offset) 110 { 111 deserialize_async_header_common(header, dst_id, tlabel, retry, tcode, priority, src_id); 112 *offset = async_header_get_offset(header); 113 } 114 115 static void deserialize_async_header_quadlet_request(const u32 header[ASYNC_HEADER_QUADLET_COUNT], 116 unsigned int *dst_id, unsigned int *tlabel, 117 unsigned int *retry, unsigned int *tcode, 118 unsigned int *priority, unsigned int *src_id, 119 u64 *offset) 120 { 121 deserialize_async_header_request(header, dst_id, tlabel, retry, tcode, priority, src_id, 122 offset); 123 } 124 125 static void deserialize_async_header_block_request(const u32 header[ASYNC_HEADER_QUADLET_COUNT], 126 unsigned int *dst_id, unsigned int *tlabel, 127 unsigned int *retry, unsigned int *tcode, 128 unsigned int *priority, unsigned int *src_id, 129 u64 *offset, 130 unsigned int *data_length, 131 unsigned int *extended_tcode) 132 { 133 deserialize_async_header_request(header, dst_id, tlabel, retry, tcode, priority, src_id, 134 offset); 135 *data_length = async_header_get_data_length(header); 136 *extended_tcode = async_header_get_extended_tcode(header); 137 } 138 139 static void deserialize_async_header_response(const u32 header[ASYNC_HEADER_QUADLET_COUNT], 140 unsigned int *dst_id, unsigned int *tlabel, 141 unsigned int *retry, unsigned int *tcode, 142 unsigned int *priority, unsigned int *src_id, 143 unsigned int *rcode) 144 { 145 deserialize_async_header_common(header, dst_id, tlabel, retry, tcode, priority, src_id); 146 *rcode = async_header_get_rcode(header); 147 } 148 149 static void deserialize_async_header_quadlet_response(const u32 header[ASYNC_HEADER_QUADLET_COUNT], 150 unsigned int *dst_id, unsigned int *tlabel, 151 unsigned int *retry, unsigned int *tcode, 152 unsigned int *priority, unsigned int *src_id, 153 unsigned int *rcode) 154 { 155 deserialize_async_header_response(header, dst_id, tlabel, retry, tcode, priority, src_id, rcode); 156 } 157 158 static void deserialize_async_header_block_response(const u32 header[ASYNC_HEADER_QUADLET_COUNT], 159 unsigned int *dst_id, unsigned int *tlabel, 160 unsigned int *retry, unsigned int *tcode, 161 unsigned int *priority, unsigned int *src_id, 162 unsigned int *rcode, unsigned int *data_length, 163 unsigned int *extended_tcode) 164 { 165 deserialize_async_header_response(header, dst_id, tlabel, retry, tcode, priority, src_id, rcode); 166 *data_length = async_header_get_data_length(header); 167 *extended_tcode = async_header_get_extended_tcode(header); 168 } 169 170 static void serialize_isoc_header(u32 *header, unsigned int data_length, unsigned int tag, 171 unsigned int channel, unsigned int tcode, unsigned int sy) 172 { 173 isoc_header_set_data_length(header, data_length); 174 isoc_header_set_tag(header, tag); 175 isoc_header_set_channel(header, channel); 176 isoc_header_set_tcode(header, tcode); 177 isoc_header_set_sy(header, sy); 178 } 179 180 static void deserialize_isoc_header(u32 header, unsigned int *data_length, unsigned int *tag, 181 unsigned int *channel, unsigned int *tcode, unsigned int *sy) 182 { 183 *data_length = isoc_header_get_data_length(header); 184 *tag = isoc_header_get_tag(header); 185 *channel = isoc_header_get_channel(header); 186 *tcode = isoc_header_get_tcode(header); 187 *sy = isoc_header_get_sy(header); 188 } 189 190 static void test_async_header_write_quadlet_request(struct kunit *test) 191 { 192 static const u32 expected[ASYNC_HEADER_QUADLET_COUNT] = { 193 0xffc05100, 194 0xffc1ffff, 195 0xf0000234, 196 0x1f0000c0, 197 }; 198 u32 header[ASYNC_HEADER_QUADLET_COUNT] = {0, 0, 0, 0}; 199 200 unsigned int dst_id; 201 unsigned int tlabel; 202 unsigned int retry; 203 unsigned int tcode; 204 unsigned int priority; 205 unsigned int src_id; 206 u64 offset; 207 u32 quadlet_data; 208 209 deserialize_async_header_quadlet_request(expected, &dst_id, &tlabel, &retry, &tcode, 210 &priority, &src_id, &offset); 211 quadlet_data = async_header_get_quadlet_data(expected); 212 213 KUNIT_EXPECT_EQ(test, 0xffc0, dst_id); 214 KUNIT_EXPECT_EQ(test, 0x14, tlabel); 215 KUNIT_EXPECT_EQ(test, 0x01, retry); 216 KUNIT_EXPECT_EQ(test, TCODE_WRITE_QUADLET_REQUEST, tcode); 217 KUNIT_EXPECT_EQ(test, 0x00, priority); 218 KUNIT_EXPECT_EQ(test, 0xffc1, src_id); 219 KUNIT_EXPECT_EQ(test, 0xfffff0000234, offset); 220 KUNIT_EXPECT_EQ(test, 0x1f0000c0, quadlet_data); 221 222 serialize_async_header_quadlet_request(header, dst_id, tlabel, retry, tcode, priority, 223 src_id, offset); 224 async_header_set_quadlet_data(header, quadlet_data); 225 226 KUNIT_EXPECT_MEMEQ(test, header, expected, sizeof(expected)); 227 } 228 229 static void test_async_header_write_block_request(struct kunit *test) 230 { 231 static const u32 expected[ASYNC_HEADER_QUADLET_COUNT] = { 232 0xffc06510, 233 0xffc1ecc0, 234 0x00000000, 235 0x00180000, 236 }; 237 u32 header[ASYNC_HEADER_QUADLET_COUNT] = {0, 0, 0, 0}; 238 239 unsigned int dst_id; 240 unsigned int tlabel; 241 unsigned int retry; 242 unsigned int tcode; 243 unsigned int priority; 244 unsigned int src_id; 245 u64 offset; 246 unsigned int data_length; 247 unsigned int extended_tcode; 248 249 deserialize_async_header_block_request(expected, &dst_id, &tlabel, &retry, &tcode, 250 &priority, &src_id, &offset, &data_length, 251 &extended_tcode); 252 253 KUNIT_EXPECT_EQ(test, 0xffc0, dst_id); 254 KUNIT_EXPECT_EQ(test, 0x19, tlabel); 255 KUNIT_EXPECT_EQ(test, 0x01, retry); 256 KUNIT_EXPECT_EQ(test, TCODE_WRITE_BLOCK_REQUEST, tcode); 257 KUNIT_EXPECT_EQ(test, 0x00, priority); 258 KUNIT_EXPECT_EQ(test, 0xffc1, src_id); 259 KUNIT_EXPECT_EQ(test, 0xecc000000000, offset); 260 KUNIT_EXPECT_EQ(test, 0x0018, data_length); 261 KUNIT_EXPECT_EQ(test, 0x0000, extended_tcode); 262 263 serialize_async_header_block_request(header, dst_id, tlabel, retry, tcode, priority, src_id, 264 offset, data_length, extended_tcode); 265 266 KUNIT_EXPECT_MEMEQ(test, header, expected, sizeof(expected)); 267 } 268 269 static void test_async_header_write_response(struct kunit *test) 270 { 271 static const u32 expected[ASYNC_HEADER_QUADLET_COUNT] = { 272 0xffc15120, 273 0xffc00000, 274 0x00000000, 275 0x00000000, 276 }; 277 u32 header[ASYNC_HEADER_QUADLET_COUNT] = {0, 0, 0, 0}; 278 279 unsigned int dst_id; 280 unsigned int tlabel; 281 unsigned int retry; 282 unsigned int tcode; 283 unsigned int priority; 284 unsigned int src_id; 285 unsigned int rcode; 286 287 deserialize_async_header_quadlet_response(expected, &dst_id, &tlabel, &retry, &tcode, 288 &priority, &src_id, &rcode); 289 290 KUNIT_EXPECT_EQ(test, 0xffc1, dst_id); 291 KUNIT_EXPECT_EQ(test, 0x14, tlabel); 292 KUNIT_EXPECT_EQ(test, 0x01, retry); 293 KUNIT_EXPECT_EQ(test, TCODE_WRITE_RESPONSE, tcode); 294 KUNIT_EXPECT_EQ(test, 0x00, priority); 295 KUNIT_EXPECT_EQ(test, 0xffc0, src_id); 296 KUNIT_EXPECT_EQ(test, RCODE_COMPLETE, rcode); 297 298 serialize_async_header_quadlet_response(header, dst_id, tlabel, retry, tcode, priority, 299 src_id, rcode); 300 301 KUNIT_EXPECT_MEMEQ(test, header, expected, sizeof(expected) - sizeof(expected[0])); 302 } 303 304 static void test_async_header_read_quadlet_request(struct kunit *test) 305 { 306 static const u32 expected[ASYNC_HEADER_QUADLET_COUNT] = { 307 0xffc0f140, 308 0xffc1ffff, 309 0xf0000984, 310 0x00000000, 311 }; 312 u32 header[ASYNC_HEADER_QUADLET_COUNT] = {0, 0, 0, 0}; 313 314 unsigned int dst_id; 315 unsigned int tlabel; 316 unsigned int retry; 317 unsigned int tcode; 318 unsigned int priority; 319 unsigned int src_id; 320 u64 offset; 321 322 deserialize_async_header_quadlet_request(expected, &dst_id, &tlabel, &retry, &tcode, 323 &priority, &src_id, &offset); 324 325 KUNIT_EXPECT_EQ(test, 0xffc0, dst_id); 326 KUNIT_EXPECT_EQ(test, 0x3c, tlabel); 327 KUNIT_EXPECT_EQ(test, 0x01, retry); 328 KUNIT_EXPECT_EQ(test, TCODE_READ_QUADLET_REQUEST, tcode); 329 KUNIT_EXPECT_EQ(test, 0x00, priority); 330 KUNIT_EXPECT_EQ(test, 0xffc1, src_id); 331 KUNIT_EXPECT_EQ(test, 0xfffff0000984, offset); 332 333 serialize_async_header_quadlet_request(header, dst_id, tlabel, retry, tcode, priority, 334 src_id, offset); 335 336 KUNIT_EXPECT_MEMEQ(test, header, expected, sizeof(expected)); 337 } 338 339 static void test_async_header_read_quadlet_response(struct kunit *test) 340 { 341 static const u32 expected[ASYNC_HEADER_QUADLET_COUNT] = { 342 0xffc1f160, 343 0xffc00000, 344 0x00000000, 345 0x00000180, 346 }; 347 u32 header[ASYNC_HEADER_QUADLET_COUNT] = {0, 0, 0, 0}; 348 349 unsigned int dst_id; 350 unsigned int tlabel; 351 unsigned int retry; 352 unsigned int tcode; 353 unsigned int priority; 354 unsigned int src_id; 355 unsigned int rcode; 356 u32 quadlet_data; 357 358 deserialize_async_header_quadlet_response(expected, &dst_id, &tlabel, &retry, &tcode, 359 &priority, &src_id, &rcode); 360 quadlet_data = async_header_get_quadlet_data(expected); 361 362 KUNIT_EXPECT_EQ(test, 0xffc1, dst_id); 363 KUNIT_EXPECT_EQ(test, 0x3c, tlabel); 364 KUNIT_EXPECT_EQ(test, 0x01, retry); 365 KUNIT_EXPECT_EQ(test, TCODE_READ_QUADLET_RESPONSE, tcode); 366 KUNIT_EXPECT_EQ(test, 0x00, priority); 367 KUNIT_EXPECT_EQ(test, 0xffc0, src_id); 368 KUNIT_EXPECT_EQ(test, RCODE_COMPLETE, rcode); 369 KUNIT_EXPECT_EQ(test, 0x00000180, quadlet_data); 370 371 serialize_async_header_quadlet_response(header, dst_id, tlabel, retry, tcode, priority, 372 src_id, rcode); 373 async_header_set_quadlet_data(header, quadlet_data); 374 375 KUNIT_EXPECT_MEMEQ(test, header, expected, sizeof(expected)); 376 } 377 378 static void test_async_header_read_block_request(struct kunit *test) 379 { 380 static const u32 expected[ASYNC_HEADER_QUADLET_COUNT] = { 381 0xffc0e150, 382 0xffc1ffff, 383 0xf0000400, 384 0x00200000, 385 }; 386 u32 header[ASYNC_HEADER_QUADLET_COUNT] = {0, 0, 0, 0}; 387 388 unsigned int dst_id; 389 unsigned int tlabel; 390 unsigned int retry; 391 unsigned int tcode; 392 unsigned int priority; 393 unsigned int src_id; 394 u64 offset; 395 unsigned int data_length; 396 unsigned int extended_tcode; 397 398 deserialize_async_header_block_request(expected, &dst_id, &tlabel, &retry, &tcode, 399 &priority, &src_id, &offset, &data_length, 400 &extended_tcode); 401 402 KUNIT_EXPECT_EQ(test, 0xffc0, dst_id); 403 KUNIT_EXPECT_EQ(test, 0x38, tlabel); 404 KUNIT_EXPECT_EQ(test, 0x01, retry); 405 KUNIT_EXPECT_EQ(test, TCODE_READ_BLOCK_REQUEST, tcode); 406 KUNIT_EXPECT_EQ(test, 0x00, priority); 407 KUNIT_EXPECT_EQ(test, 0xffc1, src_id); 408 KUNIT_EXPECT_EQ(test, 0xfffff0000400, offset); 409 KUNIT_EXPECT_EQ(test, 0x0020, data_length); 410 KUNIT_EXPECT_EQ(test, 0x0000, extended_tcode); 411 412 serialize_async_header_block_request(header, dst_id, tlabel, retry, tcode, priority, src_id, 413 offset, data_length, extended_tcode); 414 415 KUNIT_EXPECT_MEMEQ(test, header, expected, sizeof(expected)); 416 } 417 418 static void test_async_header_read_block_response(struct kunit *test) 419 { 420 static const u32 expected[ASYNC_HEADER_QUADLET_COUNT] = { 421 0xffc1e170, 422 0xffc00000, 423 0x00000000, 424 0x00200000, 425 }; 426 u32 header[ASYNC_HEADER_QUADLET_COUNT] = {0, 0, 0, 0}; 427 428 unsigned int dst_id; 429 unsigned int tlabel; 430 unsigned int retry; 431 unsigned int tcode; 432 unsigned int priority; 433 unsigned int src_id; 434 unsigned int rcode; 435 unsigned int data_length; 436 unsigned int extended_tcode; 437 438 deserialize_async_header_block_response(expected, &dst_id, &tlabel, &retry, &tcode, 439 &priority, &src_id, &rcode, &data_length, 440 &extended_tcode); 441 442 KUNIT_EXPECT_EQ(test, 0xffc1, dst_id); 443 KUNIT_EXPECT_EQ(test, 0x38, tlabel); 444 KUNIT_EXPECT_EQ(test, 0x01, retry); 445 KUNIT_EXPECT_EQ(test, TCODE_READ_BLOCK_RESPONSE, tcode); 446 KUNIT_EXPECT_EQ(test, 0x00, priority); 447 KUNIT_EXPECT_EQ(test, 0xffc0, src_id); 448 KUNIT_EXPECT_EQ(test, RCODE_COMPLETE, rcode); 449 KUNIT_EXPECT_EQ(test, 0x0020, data_length); 450 KUNIT_EXPECT_EQ(test, 0x0000, extended_tcode); 451 452 serialize_async_header_block_response(header, dst_id, tlabel, retry, tcode, priority, 453 src_id, rcode, data_length, extended_tcode); 454 455 KUNIT_EXPECT_MEMEQ(test, header, expected, sizeof(expected)); 456 } 457 458 static void test_async_header_lock_request(struct kunit *test) 459 { 460 static const u32 expected[ASYNC_HEADER_QUADLET_COUNT] = { 461 0xffc02d90, 462 0xffc1ffff, 463 0xf0000984, 464 0x00080002, 465 }; 466 u32 header[ASYNC_HEADER_QUADLET_COUNT] = {0, 0, 0, 0}; 467 468 unsigned int dst_id; 469 unsigned int tlabel; 470 unsigned int retry; 471 unsigned int tcode; 472 unsigned int priority; 473 unsigned int src_id; 474 u64 offset; 475 unsigned int data_length; 476 unsigned int extended_tcode; 477 478 deserialize_async_header_block_request(expected, &dst_id, &tlabel, &retry, &tcode, 479 &priority, &src_id, &offset, &data_length, 480 &extended_tcode); 481 482 KUNIT_EXPECT_EQ(test, 0xffc0, dst_id); 483 KUNIT_EXPECT_EQ(test, 0x0b, tlabel); 484 KUNIT_EXPECT_EQ(test, 0x01, retry); 485 KUNIT_EXPECT_EQ(test, TCODE_LOCK_REQUEST, tcode); 486 KUNIT_EXPECT_EQ(test, 0x00, priority); 487 KUNIT_EXPECT_EQ(test, 0xffc1, src_id); 488 KUNIT_EXPECT_EQ(test, 0xfffff0000984, offset); 489 KUNIT_EXPECT_EQ(test, 0x0008, data_length); 490 KUNIT_EXPECT_EQ(test, EXTCODE_COMPARE_SWAP, extended_tcode); 491 492 serialize_async_header_block_request(header, dst_id, tlabel, retry, tcode, priority, src_id, 493 offset, data_length, extended_tcode); 494 495 KUNIT_EXPECT_MEMEQ(test, header, expected, sizeof(expected)); 496 } 497 498 static void test_async_header_lock_response(struct kunit *test) 499 { 500 static const u32 expected[ASYNC_HEADER_QUADLET_COUNT] = { 501 0xffc12db0, 502 0xffc00000, 503 0x00000000, 504 0x00040002, 505 }; 506 u32 header[ASYNC_HEADER_QUADLET_COUNT] = {0, 0, 0, 0}; 507 508 unsigned int dst_id; 509 unsigned int tlabel; 510 unsigned int retry; 511 unsigned int tcode; 512 unsigned int priority; 513 unsigned int src_id; 514 unsigned int rcode; 515 unsigned int data_length; 516 unsigned int extended_tcode; 517 518 deserialize_async_header_block_response(expected, &dst_id, &tlabel, &retry, &tcode, 519 &priority, &src_id, &rcode, &data_length, 520 &extended_tcode); 521 522 KUNIT_EXPECT_EQ(test, 0xffc1, dst_id); 523 KUNIT_EXPECT_EQ(test, 0x0b, tlabel); 524 KUNIT_EXPECT_EQ(test, 0x01, retry); 525 KUNIT_EXPECT_EQ(test, TCODE_LOCK_RESPONSE, tcode); 526 KUNIT_EXPECT_EQ(test, 0x00, priority); 527 KUNIT_EXPECT_EQ(test, 0xffc0, src_id); 528 KUNIT_EXPECT_EQ(test, RCODE_COMPLETE, rcode); 529 KUNIT_EXPECT_EQ(test, 0x0004, data_length); 530 KUNIT_EXPECT_EQ(test, EXTCODE_COMPARE_SWAP, extended_tcode); 531 532 serialize_async_header_block_response(header, dst_id, tlabel, retry, tcode, priority, 533 src_id, rcode, data_length, extended_tcode); 534 535 KUNIT_EXPECT_MEMEQ(test, header, expected, sizeof(expected)); 536 } 537 538 static void test_isoc_header(struct kunit *test) 539 { 540 const u32 expected = 0x00d08dec; 541 u32 header = 0; 542 543 unsigned int data_length; 544 unsigned int tag; 545 unsigned int channel; 546 unsigned int tcode; 547 unsigned int sy; 548 549 deserialize_isoc_header(expected, &data_length, &tag, &channel, &tcode, &sy); 550 551 KUNIT_EXPECT_EQ(test, 0xd0, data_length); 552 KUNIT_EXPECT_EQ(test, 0x02, tag); 553 KUNIT_EXPECT_EQ(test, 0x0d, channel); 554 KUNIT_EXPECT_EQ(test, 0x0e, tcode); 555 KUNIT_EXPECT_EQ(test, 0x0c, sy); 556 557 serialize_isoc_header(&header, data_length, tag, channel, tcode, sy); 558 559 KUNIT_EXPECT_EQ(test, header, expected); 560 } 561 562 static struct kunit_case packet_serdes_test_cases[] = { 563 KUNIT_CASE(test_async_header_write_quadlet_request), 564 KUNIT_CASE(test_async_header_write_block_request), 565 KUNIT_CASE(test_async_header_write_response), 566 KUNIT_CASE(test_async_header_read_quadlet_request), 567 KUNIT_CASE(test_async_header_read_quadlet_response), 568 KUNIT_CASE(test_async_header_read_block_request), 569 KUNIT_CASE(test_async_header_read_block_response), 570 KUNIT_CASE(test_async_header_lock_request), 571 KUNIT_CASE(test_async_header_lock_response), 572 KUNIT_CASE(test_isoc_header), 573 {} 574 }; 575 576 static struct kunit_suite packet_serdes_test_suite = { 577 .name = "firewire-packet-serdes", 578 .test_cases = packet_serdes_test_cases, 579 }; 580 kunit_test_suite(packet_serdes_test_suite); 581 582 MODULE_DESCRIPTION("FireWire packet serialization/deserialization unit test suite"); 583 MODULE_LICENSE("GPL"); 584