ngscopeclient 0.1-dev+51fbda87c
PCIeDataLinkDecoder.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopeprotocols *
4* *
5* Copyright (c) 2012-2022 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
36#ifndef PCIeDataLinkDecoder_h
37#define PCIeDataLinkDecoder_h
38
39#include "../scopehal/PacketDecoder.h"
40
42{
43public:
44
45 //Data link symbols
46 enum SymbolType
47 {
48 TYPE_DLLP_TYPE,
49 TYPE_DLLP_VC,
50 TYPE_DLLP_DATA,
51 TYPE_DLLP_CRC_OK,
52 TYPE_DLLP_CRC_BAD,
53
54 TYPE_DLLP_SEQUENCE,
55 TYPE_DLLP_HEADER_CREDITS,
56 TYPE_DLLP_DATA_CREDITS,
57
58 TYPE_TLP_SEQUENCE,
59 TYPE_TLP_CRC_OK,
60 TYPE_TLP_CRC_BAD,
61 TYPE_TLP_DATA,
62
63 TYPE_ERROR
64 } m_type;
65
66 //DLLP byte 0 type fields (PCIe 2.0 Base Spec table 3-1)
67 enum DLLPType
68 {
69 DLLP_TYPE_ACK = 0x00,
70 DLLP_TYPE_NAK = 0x10,
71 DLLP_TYPE_PM_ENTER_L1 = 0x20,
72 DLLP_TYPE_PM_ENTER_L23 = 0x21,
73 DLLP_TYPE_PM_ACTIVE_STATE_REQUEST_L1 = 0x23,
74 DLLP_TYPE_PM_REQUEST_ACK = 0x24,
75 DLLP_TYPE_VENDOR_SPECIFIC = 0x30,
76
77 DLLP_TYPE_INITFC1_P = 0x40,
78 DLLP_TYPE_INITFC1_NP = 0x50,
79 DLLP_TYPE_INITFC1_CPL = 0x60,
80 DLLP_TYPE_INITFC2_P = 0xc0,
81 DLLP_TYPE_INITFC2_NP = 0xd0,
82 DLLP_TYPE_INITFC2_CPL = 0xe0,
83 DLLP_TYPE_UPDATEFC_P = 0x80,
84 DLLP_TYPE_UPDATEFC_NP = 0x90,
85 DLLP_TYPE_UPDATEFC_CPL = 0xa0
86 };
87
88 uint32_t m_data;
89
91 {}
92
93 PCIeDataLinkSymbol(SymbolType type, uint32_t data = 0)
94 : m_type(type)
95 , m_data(data)
96 {}
97
98
99 bool operator==(const PCIeDataLinkSymbol& s) const
100 {
101 return (m_type == s.m_type) && (m_data == s.m_data);
102 }
103};
104
105class PCIeDataLinkWaveform : public SparseWaveform<PCIeDataLinkSymbol>
106{
107public:
109 virtual std::string GetText(size_t) override;
110 virtual std::string GetColor(size_t) override;
111};
112
117{
118public:
119 PCIeDataLinkDecoder(const std::string& color);
120 virtual ~PCIeDataLinkDecoder();
121
122 virtual void Refresh() override;
123
124 static std::string GetProtocolName();
125
126 virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
127
128 virtual std::vector<std::string> GetHeaders() override;
129
130 enum FramingMode
131 {
132 MODE_GEN12,
133 MODE_GEN345
134 };
135
136 PROTOCOL_DECODER_INITPROC(PCIeDataLinkDecoder)
137
138protected:
139 uint16_t CalculateDllpCRC(uint8_t type, uint8_t* data);
140 uint32_t CalculateTlpCRC(Packet* pack);
141
142 std::string m_framingMode;
143};
144
145#endif
Decoder for PCIe data link layer.
Definition: PCIeDataLinkDecoder.h:117
uint32_t CalculateTlpCRC(Packet *pack)
PCIe TLP CRC32.
Definition: PCIeDataLinkDecoder.cpp:665
virtual void Refresh() override
Evaluates a filter graph node.
Definition: PCIeDataLinkDecoder.cpp:84
uint16_t CalculateDllpCRC(uint8_t type, uint8_t *data)
PCIe DLLP CRC.
Definition: PCIeDataLinkDecoder.cpp:638
Definition: PCIeDataLinkDecoder.h:42
Definition: PCIeDataLinkDecoder.h:106
virtual std::string GetText(size_t) override
Returns the text representation of a given protocol sample.
Definition: PCIeDataLinkDecoder.cpp:708
virtual std::string GetColor(size_t) override
Returns the displayed color (in HTML #rrggbb or #rrggbbaa notation) of a given protocol sample.
Definition: PCIeDataLinkDecoder.cpp:674
Definition: PacketDecoder.h:85
Definition: PacketDecoder.h:40
A waveform sampled at irregular intervals.
Definition: Waveform.h:460
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46