29
29
#include <asm/byteorder.h>
30
30
31
31
#include "core.h"
32
+ #include "packet-header-definitions.h"
32
33
33
- #define HEADER_PRI (pri ) ((pri) << 0)
34
34
#define HEADER_TCODE (tcode ) ((tcode) << 4)
35
- #define HEADER_RETRY (retry ) ((retry) << 8)
36
- #define HEADER_TLABEL (tlabel ) ((tlabel) << 10)
37
- #define HEADER_DESTINATION (destination ) ((destination) << 16)
38
- #define HEADER_SOURCE (source ) ((source) << 16)
39
- #define HEADER_RCODE (rcode ) ((rcode) << 12)
40
- #define HEADER_OFFSET_HIGH (offset_high ) ((offset_high) << 0)
41
35
#define HEADER_DATA_LENGTH (length ) ((length) << 16)
42
- #define HEADER_EXTENDED_TCODE (tcode ) ((tcode) << 0)
43
36
44
- #define HEADER_GET_TCODE (q ) (((q) >> 4) & 0x0f)
45
- #define HEADER_GET_TLABEL (q ) (((q) >> 10) & 0x3f)
46
- #define HEADER_GET_RCODE (q ) (((q) >> 12) & 0x0f)
47
- #define HEADER_GET_DESTINATION (q ) (((q) >> 16) & 0xffff)
48
- #define HEADER_GET_SOURCE (q ) (((q) >> 16) & 0xffff)
49
- #define HEADER_GET_OFFSET_HIGH (q ) (((q) >> 0) & 0xffff)
50
- #define HEADER_GET_DATA_LENGTH (q ) (((q) >> 16) & 0xffff)
51
- #define HEADER_GET_EXTENDED_TCODE (q ) (((q) >> 0) & 0xffff)
52
-
53
- #define HEADER_DESTINATION_IS_BROADCAST (q ) \
54
- (((q) & HEADER_DESTINATION(0x3f)) == HEADER_DESTINATION(0x3f))
37
+ #define HEADER_DESTINATION_IS_BROADCAST (header ) \
38
+ ((async_header_get_destination(header) & 0x3f) == 0x3f)
55
39
56
40
#define PHY_PACKET_CONFIG 0x0
57
41
#define PHY_PACKET_LINK_ON 0x1
@@ -248,28 +232,24 @@ static void fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
248
232
} else
249
233
ext_tcode = 0 ;
250
234
251
- packet -> header [0 ] =
252
- HEADER_RETRY (RETRY_X ) |
253
- HEADER_TLABEL (tlabel ) |
254
- HEADER_TCODE (tcode ) |
255
- HEADER_DESTINATION (destination_id );
256
- packet -> header [1 ] =
257
- HEADER_OFFSET_HIGH (offset >> 32 ) | HEADER_SOURCE (source_id );
258
- packet -> header [2 ] =
259
- offset ;
235
+ async_header_set_retry (packet -> header , RETRY_X );
236
+ async_header_set_tlabel (packet -> header , tlabel );
237
+ async_header_set_tcode (packet -> header , tcode );
238
+ async_header_set_destination (packet -> header , destination_id );
239
+ async_header_set_source (packet -> header , source_id );
240
+ async_header_set_offset (packet -> header , offset );
260
241
261
242
switch (tcode ) {
262
243
case TCODE_WRITE_QUADLET_REQUEST :
263
- packet -> header [ 3 ] = * (u32 * )payload ;
244
+ async_header_set_quadlet_data ( packet -> header , * (u32 * )payload ) ;
264
245
packet -> header_length = 16 ;
265
246
packet -> payload_length = 0 ;
266
247
break ;
267
248
268
249
case TCODE_LOCK_REQUEST :
269
250
case TCODE_WRITE_BLOCK_REQUEST :
270
- packet -> header [3 ] =
271
- HEADER_DATA_LENGTH (length ) |
272
- HEADER_EXTENDED_TCODE (ext_tcode );
251
+ async_header_set_data_length (packet -> header , length );
252
+ async_header_set_extended_tcode (packet -> header , ext_tcode );
273
253
packet -> header_length = 16 ;
274
254
packet -> payload = payload ;
275
255
packet -> payload_length = length ;
@@ -281,9 +261,8 @@ static void fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
281
261
break ;
282
262
283
263
case TCODE_READ_BLOCK_REQUEST :
284
- packet -> header [3 ] =
285
- HEADER_DATA_LENGTH (length ) |
286
- HEADER_EXTENDED_TCODE (ext_tcode );
264
+ async_header_set_data_length (packet -> header , length );
265
+ async_header_set_extended_tcode (packet -> header , ext_tcode );
287
266
packet -> header_length = 16 ;
288
267
packet -> payload_length = 0 ;
289
268
break ;
@@ -655,7 +634,7 @@ EXPORT_SYMBOL(fw_core_remove_address_handler);
655
634
struct fw_request {
656
635
struct kref kref ;
657
636
struct fw_packet response ;
658
- u32 request_header [4 ];
637
+ u32 request_header [ASYNC_HEADER_QUADLET_COUNT ];
659
638
int ack ;
660
639
u32 timestamp ;
661
640
u32 length ;
@@ -695,7 +674,7 @@ int fw_get_response_length(struct fw_request *r)
695
674
{
696
675
int tcode , ext_tcode , data_length ;
697
676
698
- tcode = HEADER_GET_TCODE (r -> request_header [ 0 ] );
677
+ tcode = async_header_get_tcode (r -> request_header );
699
678
700
679
switch (tcode ) {
701
680
case TCODE_WRITE_QUADLET_REQUEST :
@@ -706,12 +685,12 @@ int fw_get_response_length(struct fw_request *r)
706
685
return 4 ;
707
686
708
687
case TCODE_READ_BLOCK_REQUEST :
709
- data_length = HEADER_GET_DATA_LENGTH (r -> request_header [ 3 ] );
688
+ data_length = async_header_get_data_length (r -> request_header );
710
689
return data_length ;
711
690
712
691
case TCODE_LOCK_REQUEST :
713
- ext_tcode = HEADER_GET_EXTENDED_TCODE (r -> request_header [ 3 ] );
714
- data_length = HEADER_GET_DATA_LENGTH (r -> request_header [ 3 ] );
692
+ ext_tcode = async_header_get_extended_tcode (r -> request_header );
693
+ data_length = async_header_get_data_length (r -> request_header );
715
694
switch (ext_tcode ) {
716
695
case EXTCODE_FETCH_ADD :
717
696
case EXTCODE_LITTLE_ADD :
@@ -731,46 +710,42 @@ void fw_fill_response(struct fw_packet *response, u32 *request_header,
731
710
{
732
711
int tcode , tlabel , extended_tcode , source , destination ;
733
712
734
- tcode = HEADER_GET_TCODE (request_header [0 ]);
735
- tlabel = HEADER_GET_TLABEL (request_header [0 ]);
736
- source = HEADER_GET_DESTINATION (request_header [0 ]);
737
- destination = HEADER_GET_SOURCE (request_header [1 ]);
738
- extended_tcode = HEADER_GET_EXTENDED_TCODE (request_header [3 ]);
739
-
740
- response -> header [0 ] =
741
- HEADER_RETRY (RETRY_1 ) |
742
- HEADER_TLABEL (tlabel ) |
743
- HEADER_DESTINATION (destination );
744
- response -> header [1 ] =
745
- HEADER_SOURCE (source ) |
746
- HEADER_RCODE (rcode );
747
- response -> header [2 ] = 0 ;
713
+ tcode = async_header_get_tcode (request_header );
714
+ tlabel = async_header_get_tlabel (request_header );
715
+ source = async_header_get_destination (request_header ); // Exchange.
716
+ destination = async_header_get_source (request_header ); // Exchange.
717
+ extended_tcode = async_header_get_extended_tcode (request_header );
718
+
719
+ async_header_set_retry (response -> header , RETRY_1 );
720
+ async_header_set_tlabel (response -> header , tlabel );
721
+ async_header_set_destination (response -> header , destination );
722
+ async_header_set_source (response -> header , source );
723
+ async_header_set_rcode (response -> header , rcode );
724
+ response -> header [2 ] = 0 ; // The field is reserved.
748
725
749
726
switch (tcode ) {
750
727
case TCODE_WRITE_QUADLET_REQUEST :
751
728
case TCODE_WRITE_BLOCK_REQUEST :
752
- response -> header [ 0 ] |= HEADER_TCODE ( TCODE_WRITE_RESPONSE );
729
+ async_header_set_tcode ( response -> header , TCODE_WRITE_RESPONSE );
753
730
response -> header_length = 12 ;
754
731
response -> payload_length = 0 ;
755
732
break ;
756
733
757
734
case TCODE_READ_QUADLET_REQUEST :
758
- response -> header [0 ] |=
759
- HEADER_TCODE (TCODE_READ_QUADLET_RESPONSE );
735
+ async_header_set_tcode (response -> header , TCODE_READ_QUADLET_RESPONSE );
760
736
if (payload != NULL )
761
- response -> header [ 3 ] = * (u32 * )payload ;
737
+ async_header_set_quadlet_data ( response -> header , * (u32 * )payload ) ;
762
738
else
763
- response -> header [ 3 ] = 0 ;
739
+ async_header_set_quadlet_data ( response -> header , 0 ) ;
764
740
response -> header_length = 16 ;
765
741
response -> payload_length = 0 ;
766
742
break ;
767
743
768
744
case TCODE_READ_BLOCK_REQUEST :
769
745
case TCODE_LOCK_REQUEST :
770
- response -> header [0 ] |= HEADER_TCODE (tcode + 2 );
771
- response -> header [3 ] =
772
- HEADER_DATA_LENGTH (length ) |
773
- HEADER_EXTENDED_TCODE (extended_tcode );
746
+ async_header_set_tcode (response -> header , tcode + 2 );
747
+ async_header_set_data_length (response -> header , length );
748
+ async_header_set_extended_tcode (response -> header , extended_tcode );
774
749
response -> header_length = 16 ;
775
750
response -> payload = payload ;
776
751
response -> payload_length = length ;
@@ -807,7 +782,7 @@ static struct fw_request *allocate_request(struct fw_card *card,
807
782
u32 * data , length ;
808
783
int request_tcode ;
809
784
810
- request_tcode = HEADER_GET_TCODE (p -> header [ 0 ] );
785
+ request_tcode = async_header_get_tcode (p -> header );
811
786
switch (request_tcode ) {
812
787
case TCODE_WRITE_QUADLET_REQUEST :
813
788
data = & p -> header [3 ];
@@ -817,7 +792,7 @@ static struct fw_request *allocate_request(struct fw_card *card,
817
792
case TCODE_WRITE_BLOCK_REQUEST :
818
793
case TCODE_LOCK_REQUEST :
819
794
data = p -> payload ;
820
- length = HEADER_GET_DATA_LENGTH (p -> header [ 3 ] );
795
+ length = async_header_get_data_length (p -> header );
821
796
break ;
822
797
823
798
case TCODE_READ_QUADLET_REQUEST :
@@ -827,7 +802,7 @@ static struct fw_request *allocate_request(struct fw_card *card,
827
802
828
803
case TCODE_READ_BLOCK_REQUEST :
829
804
data = NULL ;
830
- length = HEADER_GET_DATA_LENGTH (p -> header [ 3 ] );
805
+ length = async_header_get_data_length (p -> header );
831
806
break ;
832
807
833
808
default :
@@ -872,7 +847,7 @@ void fw_send_response(struct fw_card *card,
872
847
{
873
848
/* unified transaction or broadcast transaction: don't respond */
874
849
if (request -> ack != ACK_PENDING ||
875
- HEADER_DESTINATION_IS_BROADCAST (request -> request_header [ 0 ] )) {
850
+ HEADER_DESTINATION_IS_BROADCAST (request -> request_header )) {
876
851
fw_request_put (request );
877
852
return ;
878
853
}
@@ -926,11 +901,11 @@ static void handle_exclusive_region_request(struct fw_card *card,
926
901
struct fw_address_handler * handler ;
927
902
int tcode , destination , source ;
928
903
929
- destination = HEADER_GET_DESTINATION (p -> header [ 0 ] );
930
- source = HEADER_GET_SOURCE (p -> header [ 1 ] );
931
- tcode = HEADER_GET_TCODE (p -> header [ 0 ] );
904
+ destination = async_header_get_destination (p -> header );
905
+ source = async_header_get_source (p -> header );
906
+ tcode = async_header_get_tcode (p -> header );
932
907
if (tcode == TCODE_LOCK_REQUEST )
933
- tcode = 0x10 + HEADER_GET_EXTENDED_TCODE (p -> header [ 3 ] );
908
+ tcode = 0x10 + async_header_get_extended_tcode (p -> header );
934
909
935
910
rcu_read_lock ();
936
911
handler = lookup_enclosing_address_handler (& address_handler_list ,
@@ -963,9 +938,9 @@ static void handle_fcp_region_request(struct fw_card *card,
963
938
return ;
964
939
}
965
940
966
- tcode = HEADER_GET_TCODE (p -> header [ 0 ] );
967
- destination = HEADER_GET_DESTINATION (p -> header [ 0 ] );
968
- source = HEADER_GET_SOURCE (p -> header [ 1 ] );
941
+ tcode = async_header_get_tcode (p -> header );
942
+ destination = async_header_get_destination (p -> header );
943
+ source = async_header_get_source (p -> header );
969
944
970
945
if (tcode != TCODE_WRITE_QUADLET_REQUEST &&
971
946
tcode != TCODE_WRITE_BLOCK_REQUEST ) {
@@ -997,7 +972,7 @@ void fw_core_handle_request(struct fw_card *card, struct fw_packet *p)
997
972
if (p -> ack != ACK_PENDING && p -> ack != ACK_COMPLETE )
998
973
return ;
999
974
1000
- if (TCODE_IS_LINK_INTERNAL (HEADER_GET_TCODE (p -> header [ 0 ] ))) {
975
+ if (TCODE_IS_LINK_INTERNAL (async_header_get_tcode (p -> header ))) {
1001
976
fw_cdev_handle_phy_packet (card , p );
1002
977
return ;
1003
978
}
@@ -1008,8 +983,7 @@ void fw_core_handle_request(struct fw_card *card, struct fw_packet *p)
1008
983
return ;
1009
984
}
1010
985
1011
- offset = ((u64 )HEADER_GET_OFFSET_HIGH (p -> header [1 ]) << 32 ) |
1012
- p -> header [2 ];
986
+ offset = async_header_get_offset (p -> header );
1013
987
1014
988
if (!is_in_fcp_region (offset , request -> length ))
1015
989
handle_exclusive_region_request (card , p , request , offset );
@@ -1027,10 +1001,10 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
1027
1001
size_t data_length ;
1028
1002
int tcode , tlabel , source , rcode ;
1029
1003
1030
- tcode = HEADER_GET_TCODE (p -> header [ 0 ] );
1031
- tlabel = HEADER_GET_TLABEL (p -> header [ 0 ] );
1032
- source = HEADER_GET_SOURCE (p -> header [ 1 ] );
1033
- rcode = HEADER_GET_RCODE (p -> header [ 1 ] );
1004
+ tcode = async_header_get_tcode (p -> header );
1005
+ tlabel = async_header_get_tlabel (p -> header );
1006
+ source = async_header_get_source (p -> header );
1007
+ rcode = async_header_get_rcode (p -> header );
1034
1008
1035
1009
spin_lock_irqsave (& card -> lock , flags );
1036
1010
list_for_each_entry (iter , & card -> transaction_list , link ) {
@@ -1073,7 +1047,7 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
1073
1047
case TCODE_READ_BLOCK_RESPONSE :
1074
1048
case TCODE_LOCK_RESPONSE :
1075
1049
data = p -> payload ;
1076
- data_length = HEADER_GET_DATA_LENGTH (p -> header [ 3 ] );
1050
+ data_length = async_header_get_data_length (p -> header );
1077
1051
break ;
1078
1052
1079
1053
default :
0 commit comments