aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-transaction.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@localhost.localdomain>2007-01-26 00:37:57 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-03-09 16:02:45 -0500
commit2639a6fb268e1f2a7700fe3d31cbca9b39aa3ad9 (patch)
treed600dd5a4e1c66d4948bef268c11106197517e66 /drivers/firewire/fw-transaction.c
parent748086eb53cc5f467604c9b46ab48dc3cb771c89 (diff)
firewire: Use struct fw_packet for incoming packets too in controller interface.
Signed-off-by: Kristian Høgsberg <krh@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/fw-transaction.c')
-rw-r--r--drivers/firewire/fw-transaction.c99
1 files changed, 47 insertions, 52 deletions
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 57ecf95e5271..4ca39f09f58a 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -426,15 +426,15 @@ free_response_callback(struct fw_packet *packet,
426 426
427static void 427static void
428fw_fill_response(struct fw_packet *response, 428fw_fill_response(struct fw_packet *response,
429 u32 *request, u32 *data, size_t length) 429 struct fw_packet *request, void *data)
430{ 430{
431 int tcode, tlabel, extended_tcode, source, destination; 431 int tcode, tlabel, extended_tcode, source, destination;
432 432
433 tcode = header_get_tcode(request[0]); 433 tcode = header_get_tcode(request->header[0]);
434 tlabel = header_get_tlabel(request[0]); 434 tlabel = header_get_tlabel(request->header[0]);
435 source = header_get_destination(request[0]); 435 source = header_get_destination(request->header[0]);
436 destination = header_get_source(request[1]); 436 destination = header_get_source(request->header[1]);
437 extended_tcode = header_get_extended_tcode(request[3]); 437 extended_tcode = header_get_extended_tcode(request->header[3]);
438 438
439 response->header[0] = 439 response->header[0] =
440 header_retry(RETRY_1) | 440 header_retry(RETRY_1) |
@@ -463,11 +463,11 @@ fw_fill_response(struct fw_packet *response,
463 case TCODE_LOCK_REQUEST: 463 case TCODE_LOCK_REQUEST:
464 response->header[0] |= header_tcode(tcode + 2); 464 response->header[0] |= header_tcode(tcode + 2);
465 response->header[3] = 465 response->header[3] =
466 header_data_length(length) | 466 header_data_length(request->payload_length) |
467 header_extended_tcode(extended_tcode); 467 header_extended_tcode(extended_tcode);
468 response->header_length = 16; 468 response->header_length = 16;
469 response->payload = data; 469 response->payload = data;
470 response->payload_length = length; 470 response->payload_length = request->payload_length;
471 break; 471 break;
472 472
473 default: 473 default:
@@ -477,24 +477,23 @@ fw_fill_response(struct fw_packet *response,
477} 477}
478 478
479static struct fw_request * 479static struct fw_request *
480allocate_request(u32 *header, int ack, 480allocate_request(struct fw_packet *p)
481 int speed, int timestamp, int generation)
482{ 481{
483 struct fw_request *request; 482 struct fw_request *request;
484 u32 *data, length; 483 u32 *data, length;
485 int request_tcode; 484 int request_tcode, t;
486 485
487 request_tcode = header_get_tcode(header[0]); 486 request_tcode = header_get_tcode(p->header[0]);
488 switch (request_tcode) { 487 switch (request_tcode) {
489 case TCODE_WRITE_QUADLET_REQUEST: 488 case TCODE_WRITE_QUADLET_REQUEST:
490 data = &header[3]; 489 data = &p->header[3];
491 length = 4; 490 length = 4;
492 break; 491 break;
493 492
494 case TCODE_WRITE_BLOCK_REQUEST: 493 case TCODE_WRITE_BLOCK_REQUEST:
495 case TCODE_LOCK_REQUEST: 494 case TCODE_LOCK_REQUEST:
496 data = &header[4]; 495 data = p->payload;
497 length = header_get_data_length(header[3]); 496 length = header_get_data_length(p->header[3]);
498 break; 497 break;
499 498
500 case TCODE_READ_QUADLET_REQUEST: 499 case TCODE_READ_QUADLET_REQUEST:
@@ -504,7 +503,7 @@ allocate_request(u32 *header, int ack,
504 503
505 case TCODE_READ_BLOCK_REQUEST: 504 case TCODE_READ_BLOCK_REQUEST:
506 data = NULL; 505 data = NULL;
507 length = header_get_data_length(header[3]); 506 length = header_get_data_length(p->header[3]);
508 break; 507 break;
509 508
510 default: 509 default:
@@ -516,16 +515,22 @@ allocate_request(u32 *header, int ack,
516 if (request == NULL) 515 if (request == NULL)
517 return NULL; 516 return NULL;
518 517
519 request->response.speed = speed; 518 t = (p->timestamp & 0x1fff) + 4000;
520 request->response.timestamp = timestamp; 519 if (t >= 8000)
521 request->response.generation = generation; 520 t = (p->timestamp & ~0x1fff) + 0x2000 + t - 8000;
521 else
522 t = (p->timestamp & ~0x1fff) + t;
523
524 request->response.speed = p->speed;
525 request->response.timestamp = t;
526 request->response.generation = p->generation;
522 request->response.callback = free_response_callback; 527 request->response.callback = free_response_callback;
523 request->ack = ack; 528 request->ack = p->ack;
524 request->length = length; 529 request->length = p->payload_length;
525 if (data) 530 if (data)
526 memcpy(request->data, data, length); 531 memcpy(request->data, p->payload, p->payload_length);
527 532
528 fw_fill_response(&request->response, header, request->data, length); 533 fw_fill_response(&request->response, p, request->data);
529 534
530 return request; 535 return request;
531} 536}
@@ -554,31 +559,23 @@ fw_send_response(struct fw_card *card, struct fw_request *request, int rcode)
554EXPORT_SYMBOL(fw_send_response); 559EXPORT_SYMBOL(fw_send_response);
555 560
556void 561void
557fw_core_handle_request(struct fw_card *card, 562fw_core_handle_request(struct fw_card *card, struct fw_packet *p)
558 int speed, int ack, int timestamp,
559 int generation, u32 length, u32 *header)
560{ 563{
561 struct fw_address_handler *handler; 564 struct fw_address_handler *handler;
562 struct fw_request *request; 565 struct fw_request *request;
563 unsigned long long offset; 566 unsigned long long offset;
564 unsigned long flags; 567 unsigned long flags;
565 int tcode, destination, source, t; 568 int tcode, destination, source;
566 569
567 if (length > 2048) { 570 if (p->payload_length > 2048) {
568 /* FIXME: send error response. */ 571 /* FIXME: send error response. */
569 return; 572 return;
570 } 573 }
571 574
572 if (ack != ACK_PENDING && ack != ACK_COMPLETE) 575 if (p->ack != ACK_PENDING && p->ack != ACK_COMPLETE)
573 return; 576 return;
574 577
575 t = (timestamp & 0x1fff) + 4000; 578 request = allocate_request(p);
576 if (t >= 8000)
577 t = (timestamp & ~0x1fff) + 0x2000 + t - 8000;
578 else
579 t = (timestamp & ~0x1fff) + t;
580
581 request = allocate_request(header, ack, speed, t, generation);
582 if (request == NULL) { 579 if (request == NULL) {
583 /* FIXME: send statically allocated busy packet. */ 580 /* FIXME: send statically allocated busy packet. */
584 return; 581 return;
@@ -586,10 +583,10 @@ fw_core_handle_request(struct fw_card *card,
586 583
587 offset = 584 offset =
588 ((unsigned long long) 585 ((unsigned long long)
589 header_get_offset_high(header[1]) << 32) | header[2]; 586 header_get_offset_high(p->header[1]) << 32) | p->header[2];
590 tcode = header_get_tcode(header[0]); 587 tcode = header_get_tcode(p->header[0]);
591 destination = header_get_destination(header[0]); 588 destination = header_get_destination(p->header[0]);
592 source = header_get_source(header[0]); 589 source = header_get_source(p->header[0]);
593 590
594 spin_lock_irqsave(&address_handler_lock, flags); 591 spin_lock_irqsave(&address_handler_lock, flags);
595 handler = lookup_enclosing_address_handler(&address_handler_list, 592 handler = lookup_enclosing_address_handler(&address_handler_list,
@@ -607,16 +604,14 @@ fw_core_handle_request(struct fw_card *card,
607 else 604 else
608 handler->address_callback(card, request, 605 handler->address_callback(card, request,
609 tcode, destination, source, 606 tcode, destination, source,
610 generation, speed, offset, 607 p->generation, p->speed, offset,
611 request->data, request->length, 608 request->data, request->length,
612 handler->callback_data); 609 handler->callback_data);
613} 610}
614EXPORT_SYMBOL(fw_core_handle_request); 611EXPORT_SYMBOL(fw_core_handle_request);
615 612
616void 613void
617fw_core_handle_response(struct fw_card *card, 614fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
618 int speed, int ack, int timestamp,
619 u32 length, u32 *header)
620{ 615{
621 struct fw_transaction *t; 616 struct fw_transaction *t;
622 unsigned long flags; 617 unsigned long flags;
@@ -624,11 +619,11 @@ fw_core_handle_response(struct fw_card *card,
624 size_t data_length; 619 size_t data_length;
625 int tcode, tlabel, destination, source, rcode; 620 int tcode, tlabel, destination, source, rcode;
626 621
627 tcode = header_get_tcode(header[0]); 622 tcode = header_get_tcode(p->header[0]);
628 tlabel = header_get_tlabel(header[0]); 623 tlabel = header_get_tlabel(p->header[0]);
629 destination = header_get_destination(header[0]); 624 destination = header_get_destination(p->header[0]);
630 source = header_get_source(header[1]); 625 source = header_get_source(p->header[1]);
631 rcode = header_get_rcode(header[1]); 626 rcode = header_get_rcode(p->header[1]);
632 627
633 spin_lock_irqsave(&card->lock, flags); 628 spin_lock_irqsave(&card->lock, flags);
634 list_for_each_entry(t, &card->transaction_list, link) { 629 list_for_each_entry(t, &card->transaction_list, link) {
@@ -650,7 +645,7 @@ fw_core_handle_response(struct fw_card *card,
650 645
651 switch (tcode) { 646 switch (tcode) {
652 case TCODE_READ_QUADLET_RESPONSE: 647 case TCODE_READ_QUADLET_RESPONSE:
653 data = (u32 *) &header[3]; 648 data = (u32 *) &p->header[3];
654 data_length = 4; 649 data_length = 4;
655 break; 650 break;
656 651
@@ -661,8 +656,8 @@ fw_core_handle_response(struct fw_card *card,
661 656
662 case TCODE_READ_BLOCK_RESPONSE: 657 case TCODE_READ_BLOCK_RESPONSE:
663 case TCODE_LOCK_RESPONSE: 658 case TCODE_LOCK_RESPONSE:
664 data = &header[4]; 659 data = &p->header[4];
665 data_length = header_get_data_length(header[3]); 660 data_length = header_get_data_length(p->header[3]);
666 break; 661 break;
667 662
668 default: 663 default: