]> sigrok.org Git - libsigrokdecode.git/blame - decoders/cfp/pd.py
cfp: Factor out self.putx().
[libsigrokdecode.git] / decoders / cfp / pd.py
CommitLineData
039b0db2
EO
1##
2## This file is part of the libsigrokdecode project.
3##
4## Copyright (C) 2018 Elias Oenal <sigrok@eliasoenal.com>
5## All rights reserved.
6##
7## Redistribution and use in source and binary forms, with or without
8## modification, are permitted provided that the following conditions are met:
9##
10## 1. Redistributions of source code must retain the above copyright notice,
11## this list of conditions and the following disclaimer.
12## 2. Redistributions in binary form must reproduce the above copyright notice,
13## this list of conditions and the following disclaimer in the documentation
14## and/or other materials provided with the distribution.
15##
16## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26## POSSIBILITY OF SUCH DAMAGE.
27##
28
29import sigrokdecode as srd
30
31MODULE_ID = {
32 0x00: 'Unknown or unspecified',
33 0x01: 'GBIC',
34 0x02: 'Module/connector soldered to motherboard',
35 0x03: 'SFP',
36 0x04: '300 pin XSBI',
37 0x05: 'XENPAK',
38 0x06: 'XFP',
39 0x07: 'XFF',
40 0x08: 'XFP-E',
41 0x09: 'XPAK',
42 0x0a: 'X2',
43 0x0B: 'DWDM-SFP',
44 0x0C: 'QSFP',
45 0x0D: 'QSFP+',
46 0x0E: 'CFP',
47 0x0F: 'CXP (TBD)',
48 0x11: 'CFP2',
49 0x12: 'CFP4',
50}
51
52class Decoder(srd.Decoder):
53 api_version = 3
54 id = 'cfp'
55 name = 'CFP'
6d1ad4ae
UH
56 longname = '100 Gigabit C form-factor pluggable'
57 desc = '100 Gigabit C form-factor pluggable (CFP) protocol.'
039b0db2
EO
58 license = 'BSD'
59 inputs = ['mdio']
60 outputs = ['cfp']
61 annotations = (
5b2c45db
UH
62 ('register', 'Register'),
63 ('decode', 'Decode'),
039b0db2
EO
64 )
65 annotation_rows = (
5b2c45db
UH
66 ('registers', 'Registers', (0,)),
67 ('decodes', 'Decodes', (1,)),
039b0db2
EO
68 )
69
70 def __init__(self):
71 pass
72
73 def start(self):
039b0db2
EO
74 self.out_ann = self.register(srd.OUTPUT_ANN)
75
0c16bc31
UH
76 def putx(self, data):
77 self.put(self.ss, self.es, self.out_ann, data)
78
039b0db2 79 def decode(self, ss, es, data):
0c16bc31 80 self.ss, self.es = ss, es
039b0db2 81 for (clause45, clause45_address, is_read, portad, devad, register) in data:
9a80e8a1
UH
82 if not is_read:
83 continue
84 if clause45_address >= 0x8000 and clause45_address <= 0x807F:
0c16bc31 85 self.putx([0, ['CFP NVR 1: Basic ID register', 'NVR1']])
9a80e8a1 86 if clause45_address == 0x8000:
0c16bc31 87 self.putx([1, ['Module identifier: %s' % MODULE_ID.get(register, 'Reserved')]])
9a80e8a1 88 elif clause45_address >= 0x8080 and clause45_address <= 0x80FF:
0c16bc31 89 self.putx([0, ['CFP NVR 2: Extended ID register', 'NVR2']])
9a80e8a1 90 elif clause45_address >= 0x8100 and clause45_address <= 0x817F:
0c16bc31 91 self.putx([0, ['CFP NVR 3: Network lane specific register', 'NVR3']])
9a80e8a1 92 elif clause45_address >= 0x8180 and clause45_address <= 0x81FF:
0c16bc31 93 self.putx([0, ['CFP NVR 4', 'NVR4']])
9a80e8a1 94 elif clause45_address >= 0x8400 and clause45_address <= 0x847F:
0c16bc31 95 self.putx([0, ['Vendor NVR 1: Vendor data register', 'V-NVR1']])
9a80e8a1 96 elif clause45_address >= 0x8480 and clause45_address <= 0x84FF:
0c16bc31 97 self.putx([0, ['Vendor NVR 2: Vendor data register', 'V-NVR2']])
9a80e8a1 98 elif clause45_address >= 0x8800 and clause45_address <= 0x887F:
0c16bc31 99 self.putx([0, ['User NVR 1: User data register', 'U-NVR1']])
9a80e8a1 100 elif clause45_address >= 0x8880 and clause45_address <= 0x88FF:
0c16bc31 101 self.putx([0, ['User NVR 2: User data register', 'U-NVR2']])
9a80e8a1 102 elif clause45_address >= 0xA000 and clause45_address <= 0xA07F:
0c16bc31 103 self.putx([0, ['CFP Module VR 1: CFP Module level control and DDM register', 'Mod-VR1']])
9a80e8a1 104 elif clause45_address >= 0xA080 and clause45_address <= 0xA0FF:
0c16bc31 105 self.putx([0, ['MLG VR 1: MLG Management Interface register', 'MLG-VR1']])