aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2010-11-30 02:24:47 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2010-12-13 14:39:14 -0500
commit5b06db166c4d38638980283505259fa165d4f369 (patch)
tree3384d55b420987325ffabf523ded740b1daac2c4 /drivers/firewire
parent8327b37b18addfc6f8cf41a2f1a4490b656377b9 (diff)
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>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/core-cdev.c7
-rw-r--r--drivers/firewire/core-transaction.c7
-rw-r--r--drivers/firewire/core.h4
-rw-r--r--drivers/firewire/ohci.c44
4 files changed, 33 insertions, 29 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 14bb7b7b5dd7..48ae712e2101 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -1501,9 +1501,10 @@ static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg)
1501 e->client = client; 1501 e->client = client;
1502 e->p.speed = SCODE_100; 1502 e->p.speed = SCODE_100;
1503 e->p.generation = a->generation; 1503 e->p.generation = a->generation;
1504 e->p.header[0] = a->data[0]; 1504 e->p.header[0] = TCODE_LINK_INTERNAL << 4;
1505 e->p.header[1] = a->data[1]; 1505 e->p.header[1] = a->data[0];
1506 e->p.header_length = 8; 1506 e->p.header[2] = a->data[1];
1507 e->p.header_length = 12;
1507 e->p.callback = outbound_phy_packet_callback; 1508 e->p.callback = outbound_phy_packet_callback;
1508 e->phy_packet.closure = a->closure; 1509 e->phy_packet.closure = a->closure;
1509 e->phy_packet.type = FW_CDEV_EVENT_PHY_PACKET_SENT; 1510 e->phy_packet.type = FW_CDEV_EVENT_PHY_PACKET_SENT;
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index ad864d8cd5e4..9e81cc54abd2 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -423,7 +423,8 @@ static void transmit_phy_packet_callback(struct fw_packet *packet,
423} 423}
424 424
425static struct fw_packet phy_config_packet = { 425static struct fw_packet phy_config_packet = {
426 .header_length = 8, 426 .header_length = 12,
427 .header[0] = TCODE_LINK_INTERNAL << 4,
427 .payload_length = 0, 428 .payload_length = 0,
428 .speed = SCODE_100, 429 .speed = SCODE_100,
429 .callback = transmit_phy_packet_callback, 430 .callback = transmit_phy_packet_callback,
@@ -451,8 +452,8 @@ void fw_send_phy_config(struct fw_card *card,
451 452
452 mutex_lock(&phy_config_mutex); 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 phy_config_packet.generation = generation; 457 phy_config_packet.generation = generation;
457 INIT_COMPLETION(phy_config_done); 458 INIT_COMPLETION(phy_config_done);
458 459
diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
index e6239f971be6..f8dfcf1c6cbe 100644
--- a/drivers/firewire/core.h
+++ b/drivers/firewire/core.h
@@ -215,9 +215,11 @@ static inline bool is_next_generation(int new_generation, int old_generation)
215 215
216/* -transaction */ 216/* -transaction */
217 217
218#define TCODE_LINK_INTERNAL 0xe
219
218#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) 220#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4)
219#define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0) 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#define TCODE_IS_REQUEST(tcode) (((tcode) & 2) == 0) 223#define TCODE_IS_REQUEST(tcode) (((tcode) & 2) == 0)
222#define TCODE_IS_RESPONSE(tcode) (((tcode) & 2) != 0) 224#define TCODE_IS_RESPONSE(tcode) (((tcode) & 2) != 0)
223#define TCODE_HAS_REQUEST_DATA(tcode) (((tcode) & 12) != 4) 225#define TCODE_HAS_REQUEST_DATA(tcode) (((tcode) & 12) != 4)
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 0031ec6e1f00..29259f3a30bb 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -418,10 +418,6 @@ static const char *tcodes[] = {
418 [0xc] = "-reserved-", [0xd] = "-reserved-", 418 [0xc] = "-reserved-", [0xd] = "-reserved-",
419 [0xe] = "link internal", [0xf] = "-reserved-", 419 [0xe] = "link internal", [0xf] = "-reserved-",
420}; 420};
421static const char *phys[] = {
422 [0x0] = "phy config packet", [0x1] = "link-on packet",
423 [0x2] = "self-id packet", [0x3] = "-reserved-",
424};
425 421
426static void log_ar_at_event(char dir, int speed, u32 *header, int evt) 422static void log_ar_at_event(char dir, int speed, u32 *header, int evt)
427{ 423{
@@ -440,12 +436,6 @@ static void log_ar_at_event(char dir, int speed, u32 *header, int evt)
440 return; 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 switch (tcode) { 439 switch (tcode) {
450 case 0x0: case 0x6: case 0x8: 440 case 0x0: case 0x6: case 0x8:
451 snprintf(specific, sizeof(specific), " = %08x", 441 snprintf(specific, sizeof(specific), " = %08x",
@@ -460,9 +450,13 @@ static void log_ar_at_event(char dir, int speed, u32 *header, int evt)
460 } 450 }
461 451
462 switch (tcode) { 452 switch (tcode) {
463 case 0xe: case 0xa: 453 case 0xa:
464 fw_notify("A%c %s, %s\n", dir, evts[evt], tcodes[tcode]); 454 fw_notify("A%c %s, %s\n", dir, evts[evt], tcodes[tcode]);
465 break; 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 case 0x0: case 0x1: case 0x4: case 0x5: case 0x9: 460 case 0x0: case 0x1: case 0x4: case 0x5: case 0x9:
467 fw_notify("A%c spd %x tl %02x, " 461 fw_notify("A%c spd %x tl %02x, "
468 "%04x -> %04x, %s, " 462 "%04x -> %04x, %s, "
@@ -1250,21 +1244,27 @@ static int at_context_queue_packet(struct context *ctx,
1250 /* 1244 /*
1251 * The DMA format for asyncronous link packets is different 1245 * The DMA format for asyncronous link packets is different
1252 * from the IEEE1394 layout, so shift the fields around 1246 * from the IEEE1394 layout, so shift the fields around
1253 * accordingly. If header_length is 8, it's a PHY packet, to 1247 * accordingly.
1254 * which we need to prepend an extra quadlet.
1255 */ 1248 */
1256 1249
1250 tcode = (packet->header[0] >> 4) & 0x0f;
1257 header = (__le32 *) &d[1]; 1251 header = (__le32 *) &d[1];
1258 switch (packet->header_length) { 1252 switch (tcode) {
1259 case 16: 1253 case TCODE_WRITE_QUADLET_REQUEST:
1260 case 12: 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 header[0] = cpu_to_le32((packet->header[0] & 0xffff) | 1262 header[0] = cpu_to_le32((packet->header[0] & 0xffff) |
1262 (packet->speed << 16)); 1263 (packet->speed << 16));
1263 header[1] = cpu_to_le32((packet->header[1] & 0xffff) | 1264 header[1] = cpu_to_le32((packet->header[1] & 0xffff) |
1264 (packet->header[0] & 0xffff0000)); 1265 (packet->header[0] & 0xffff0000));
1265 header[2] = cpu_to_le32(packet->header[2]); 1266 header[2] = cpu_to_le32(packet->header[2]);
1266 1267
1267 tcode = (packet->header[0] >> 4) & 0x0f;
1268 if (TCODE_IS_BLOCK_PACKET(tcode)) 1268 if (TCODE_IS_BLOCK_PACKET(tcode))
1269 header[3] = cpu_to_le32(packet->header[3]); 1269 header[3] = cpu_to_le32(packet->header[3]);
1270 else 1270 else
@@ -1273,18 +1273,18 @@ static int at_context_queue_packet(struct context *ctx,
1273 d[0].req_count = cpu_to_le16(packet->header_length); 1273 d[0].req_count = cpu_to_le16(packet->header_length);
1274 break; 1274 break;
1275 1275
1276 case 8: 1276 case TCODE_LINK_INTERNAL:
1277 header[0] = cpu_to_le32((OHCI1394_phy_tcode << 4) | 1277 header[0] = cpu_to_le32((OHCI1394_phy_tcode << 4) |
1278 (packet->speed << 16)); 1278 (packet->speed << 16));
1279 header[1] = cpu_to_le32(packet->header[0]); 1279 header[1] = cpu_to_le32(packet->header[1]);
1280 header[2] = cpu_to_le32(packet->header[1]); 1280 header[2] = cpu_to_le32(packet->header[2]);
1281 d[0].req_count = cpu_to_le16(12); 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 d[0].control |= cpu_to_le16(DESCRIPTOR_PING); 1284 d[0].control |= cpu_to_le16(DESCRIPTOR_PING);
1285 break; 1285 break;
1286 1286
1287 case 4: 1287 case TCODE_STREAM_DATA:
1288 header[0] = cpu_to_le32((packet->header[0] & 0xffff) | 1288 header[0] = cpu_to_le32((packet->header[0] & 0xffff) |
1289 (packet->speed << 16)); 1289 (packet->speed << 16));
1290 header[1] = cpu_to_le32(packet->header[0] & 0xffff0000); 1290 header[1] = cpu_to_le32(packet->header[0] & 0xffff0000);