^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __nosy_dump_h__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __nosy_dump_h__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #define array_length(array) (sizeof(array) / sizeof(array[0]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define ACK_NO_ACK 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define ACK_DONE(a) ((a >> 2) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define ACK_BUSY(a) ((a >> 2) == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define ACK_ERROR(a) ((a >> 2) == 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <stdint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct phy_packet {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) uint32_t timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) uint32_t zero:24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) uint32_t phy_id:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) uint32_t identifier:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) } common, link_on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) uint32_t zero:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) uint32_t gap_count:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) uint32_t set_gap_count:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) uint32_t set_root:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) uint32_t root_id:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) uint32_t identifier:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) } phy_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) uint32_t more_packets:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) uint32_t initiated_reset:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) uint32_t port2:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) uint32_t port1:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) uint32_t port0:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) uint32_t power_class:3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) uint32_t contender:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) uint32_t phy_delay:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) uint32_t phy_speed:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) uint32_t gap_count:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) uint32_t link_active:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) uint32_t extended:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) uint32_t phy_id:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) uint32_t identifier:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) } self_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) uint32_t more_packets:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) uint32_t reserved1:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) uint32_t porth:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) uint32_t portg:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) uint32_t portf:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) uint32_t porte:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) uint32_t portd:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) uint32_t portc:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) uint32_t portb:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) uint32_t porta:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) uint32_t reserved0:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) uint32_t sequence:3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) uint32_t extended:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) uint32_t phy_id:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) uint32_t identifier:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) } ext_self_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) uint32_t inverted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) uint32_t ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define TCODE_PHY_PACKET 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define PHY_PACKET_CONFIGURATION 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define PHY_PACKET_LINK_ON 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define PHY_PACKET_SELF_ID 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct link_packet {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) uint32_t timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) uint32_t priority:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) uint32_t tcode:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) uint32_t rt:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) uint32_t tlabel:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) uint32_t destination:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) uint32_t offset_high:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) uint32_t source:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) uint32_t offset_low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) } common;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) uint32_t common[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) uint32_t crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) } read_quadlet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) uint32_t common[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) uint32_t data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) uint32_t crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) } read_quadlet_response;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) uint32_t common[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) uint32_t extended_tcode:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) uint32_t data_length:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) uint32_t crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) } read_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) uint32_t common[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) uint32_t extended_tcode:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) uint32_t data_length:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) uint32_t crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) uint32_t data[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /* crc and ack follows. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) } read_block_response;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) uint32_t common[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) uint32_t data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) uint32_t crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) } write_quadlet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) uint32_t common[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) uint32_t extended_tcode:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) uint32_t data_length:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) uint32_t crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) uint32_t data[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /* crc and ack follows. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) } write_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) uint32_t common[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) uint32_t crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) } write_response;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) uint32_t common[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) uint32_t data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) uint32_t crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) } cycle_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) uint32_t sy:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) uint32_t tcode:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) uint32_t channel:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) uint32_t tag:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) uint32_t data_length:16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) uint32_t crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) } iso_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct subaction {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) uint32_t ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) size_t length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct list link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct link_packet packet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct link_transaction {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int request_node, response_node, tlabel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct subaction *request, *response;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct list request_list, response_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct list link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) int decode_fcp(struct link_transaction *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) #endif /* __nosy_dump_h__ */