Commit 5b06db166c4d38638980283505259fa165d4f369
Committed by
Stefan Richter
1 parent
8327b37b18
Exists in
master
and in
7 other branches
firewire: make PHY packet header format consistent
Change the header of PHY packets to be sent to include a pseudo transaction code. This makes the header consistent with that of received PHY packets, and allows at_context_queue_packet() and log_ar_at_event() to see the packet type directly instead of having to deduce it from the header length or even from the header contents. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Showing 4 changed files with 33 additions and 29 deletions Side-by-side Diff
drivers/firewire/core-cdev.c
... | ... | @@ -1501,9 +1501,10 @@ |
1501 | 1501 | e->client = client; |
1502 | 1502 | e->p.speed = SCODE_100; |
1503 | 1503 | e->p.generation = a->generation; |
1504 | - e->p.header[0] = a->data[0]; | |
1505 | - e->p.header[1] = a->data[1]; | |
1506 | - e->p.header_length = 8; | |
1504 | + e->p.header[0] = TCODE_LINK_INTERNAL << 4; | |
1505 | + e->p.header[1] = a->data[0]; | |
1506 | + e->p.header[2] = a->data[1]; | |
1507 | + e->p.header_length = 12; | |
1507 | 1508 | e->p.callback = outbound_phy_packet_callback; |
1508 | 1509 | e->phy_packet.closure = a->closure; |
1509 | 1510 | e->phy_packet.type = FW_CDEV_EVENT_PHY_PACKET_SENT; |
drivers/firewire/core-transaction.c
... | ... | @@ -423,7 +423,8 @@ |
423 | 423 | } |
424 | 424 | |
425 | 425 | static struct fw_packet phy_config_packet = { |
426 | - .header_length = 8, | |
426 | + .header_length = 12, | |
427 | + .header[0] = TCODE_LINK_INTERNAL << 4, | |
427 | 428 | .payload_length = 0, |
428 | 429 | .speed = SCODE_100, |
429 | 430 | .callback = transmit_phy_packet_callback, |
... | ... | @@ -451,8 +452,8 @@ |
451 | 452 | |
452 | 453 | mutex_lock(&phy_config_mutex); |
453 | 454 | |
454 | - phy_config_packet.header[0] = data; | |
455 | - phy_config_packet.header[1] = ~data; | |
455 | + phy_config_packet.header[1] = data; | |
456 | + phy_config_packet.header[2] = ~data; | |
456 | 457 | phy_config_packet.generation = generation; |
457 | 458 | INIT_COMPLETION(phy_config_done); |
458 | 459 |
drivers/firewire/core.h
... | ... | @@ -215,9 +215,11 @@ |
215 | 215 | |
216 | 216 | /* -transaction */ |
217 | 217 | |
218 | +#define TCODE_LINK_INTERNAL 0xe | |
219 | + | |
218 | 220 | #define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) |
219 | 221 | #define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0) |
220 | -#define TCODE_IS_LINK_INTERNAL(tcode) ((tcode) == 0xe) | |
222 | +#define TCODE_IS_LINK_INTERNAL(tcode) ((tcode) == TCODE_LINK_INTERNAL) | |
221 | 223 | #define TCODE_IS_REQUEST(tcode) (((tcode) & 2) == 0) |
222 | 224 | #define TCODE_IS_RESPONSE(tcode) (((tcode) & 2) != 0) |
223 | 225 | #define TCODE_HAS_REQUEST_DATA(tcode) (((tcode) & 12) != 4) |
drivers/firewire/ohci.c
... | ... | @@ -418,10 +418,6 @@ |
418 | 418 | [0xc] = "-reserved-", [0xd] = "-reserved-", |
419 | 419 | [0xe] = "link internal", [0xf] = "-reserved-", |
420 | 420 | }; |
421 | -static const char *phys[] = { | |
422 | - [0x0] = "phy config packet", [0x1] = "link-on packet", | |
423 | - [0x2] = "self-id packet", [0x3] = "-reserved-", | |
424 | -}; | |
425 | 421 | |
426 | 422 | static void log_ar_at_event(char dir, int speed, u32 *header, int evt) |
427 | 423 | { |
... | ... | @@ -440,12 +436,6 @@ |
440 | 436 | return; |
441 | 437 | } |
442 | 438 | |
443 | - if (header[0] == ~header[1]) { | |
444 | - fw_notify("A%c %s, %s, %08x\n", | |
445 | - dir, evts[evt], phys[header[0] >> 30 & 0x3], header[0]); | |
446 | - return; | |
447 | - } | |
448 | - | |
449 | 439 | switch (tcode) { |
450 | 440 | case 0x0: case 0x6: case 0x8: |
451 | 441 | snprintf(specific, sizeof(specific), " = %08x", |
452 | 442 | |
... | ... | @@ -460,9 +450,13 @@ |
460 | 450 | } |
461 | 451 | |
462 | 452 | switch (tcode) { |
463 | - case 0xe: case 0xa: | |
453 | + case 0xa: | |
464 | 454 | fw_notify("A%c %s, %s\n", dir, evts[evt], tcodes[tcode]); |
465 | 455 | break; |
456 | + case 0xe: | |
457 | + fw_notify("A%c %s, PHY %08x %08x\n", | |
458 | + dir, evts[evt], header[1], header[2]); | |
459 | + break; | |
466 | 460 | case 0x0: case 0x1: case 0x4: case 0x5: case 0x9: |
467 | 461 | fw_notify("A%c spd %x tl %02x, " |
468 | 462 | "%04x -> %04x, %s, " |
469 | 463 | |
470 | 464 | |
471 | 465 | |
... | ... | @@ -1250,21 +1244,27 @@ |
1250 | 1244 | /* |
1251 | 1245 | * The DMA format for asyncronous link packets is different |
1252 | 1246 | * from the IEEE1394 layout, so shift the fields around |
1253 | - * accordingly. If header_length is 8, it's a PHY packet, to | |
1254 | - * which we need to prepend an extra quadlet. | |
1247 | + * accordingly. | |
1255 | 1248 | */ |
1256 | 1249 | |
1250 | + tcode = (packet->header[0] >> 4) & 0x0f; | |
1257 | 1251 | header = (__le32 *) &d[1]; |
1258 | - switch (packet->header_length) { | |
1259 | - case 16: | |
1260 | - case 12: | |
1252 | + switch (tcode) { | |
1253 | + case TCODE_WRITE_QUADLET_REQUEST: | |
1254 | + case TCODE_WRITE_BLOCK_REQUEST: | |
1255 | + case TCODE_WRITE_RESPONSE: | |
1256 | + case TCODE_READ_QUADLET_REQUEST: | |
1257 | + case TCODE_READ_BLOCK_REQUEST: | |
1258 | + case TCODE_READ_QUADLET_RESPONSE: | |
1259 | + case TCODE_READ_BLOCK_RESPONSE: | |
1260 | + case TCODE_LOCK_REQUEST: | |
1261 | + case TCODE_LOCK_RESPONSE: | |
1261 | 1262 | header[0] = cpu_to_le32((packet->header[0] & 0xffff) | |
1262 | 1263 | (packet->speed << 16)); |
1263 | 1264 | header[1] = cpu_to_le32((packet->header[1] & 0xffff) | |
1264 | 1265 | (packet->header[0] & 0xffff0000)); |
1265 | 1266 | header[2] = cpu_to_le32(packet->header[2]); |
1266 | 1267 | |
1267 | - tcode = (packet->header[0] >> 4) & 0x0f; | |
1268 | 1268 | if (TCODE_IS_BLOCK_PACKET(tcode)) |
1269 | 1269 | header[3] = cpu_to_le32(packet->header[3]); |
1270 | 1270 | else |
1271 | 1271 | |
1272 | 1272 | |
1273 | 1273 | |
... | ... | @@ -1273,18 +1273,18 @@ |
1273 | 1273 | d[0].req_count = cpu_to_le16(packet->header_length); |
1274 | 1274 | break; |
1275 | 1275 | |
1276 | - case 8: | |
1276 | + case TCODE_LINK_INTERNAL: | |
1277 | 1277 | header[0] = cpu_to_le32((OHCI1394_phy_tcode << 4) | |
1278 | 1278 | (packet->speed << 16)); |
1279 | - header[1] = cpu_to_le32(packet->header[0]); | |
1280 | - header[2] = cpu_to_le32(packet->header[1]); | |
1279 | + header[1] = cpu_to_le32(packet->header[1]); | |
1280 | + header[2] = cpu_to_le32(packet->header[2]); | |
1281 | 1281 | d[0].req_count = cpu_to_le16(12); |
1282 | 1282 | |
1283 | - if (is_ping_packet(packet->header)) | |
1283 | + if (is_ping_packet(&packet->header[1])) | |
1284 | 1284 | d[0].control |= cpu_to_le16(DESCRIPTOR_PING); |
1285 | 1285 | break; |
1286 | 1286 | |
1287 | - case 4: | |
1287 | + case TCODE_STREAM_DATA: | |
1288 | 1288 | header[0] = cpu_to_le32((packet->header[0] & 0xffff) | |
1289 | 1289 | (packet->speed << 16)); |
1290 | 1290 | header[1] = cpu_to_le32(packet->header[0] & 0xffff0000); |