summaryrefslogtreecommitdiff
path: root/decoders/cfp/pd.py
blob: 58668c5990cf386be5841a2d12a392e3a3421c1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2018 Elias Oenal <sigrok@eliasoenal.com>
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
##
## 1. Redistributions of source code must retain the above copyright notice,
##    this list of conditions and the following disclaimer.
## 2. Redistributions in binary form must reproduce the above copyright notice,
##    this list of conditions and the following disclaimer in the documentation
##    and/or other materials provided with the distribution.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
## POSSIBILITY OF SUCH DAMAGE.
##

import sigrokdecode as srd

MODULE_ID = {
    0x00: 'Unknown or unspecified',
    0x01: 'GBIC',
    0x02: 'Module/connector soldered to motherboard',
    0x03: 'SFP',
    0x04: '300 pin XSBI',
    0x05: 'XENPAK',
    0x06: 'XFP',
    0x07: 'XFF',
    0x08: 'XFP-E',
    0x09: 'XPAK',
    0x0a: 'X2',
    0x0B: 'DWDM-SFP',
    0x0C: 'QSFP',
    0x0D: 'QSFP+',
    0x0E: 'CFP',
    0x0F: 'CXP (TBD)',
    0x11: 'CFP2',
    0x12: 'CFP4',
}

class Decoder(srd.Decoder):
    api_version = 3
    id = 'cfp'
    name = 'CFP'
    longname = '100 Gigabit C form-factor pluggable'
    desc = '100 Gigabit C form-factor pluggable (CFP) protocol.'
    license = 'BSD'
    inputs = ['mdio']
    outputs = ['cfp']
    annotations = (
        ('register', 'Register'),
        ('decode', 'Decode'),
    )
    annotation_rows = (
        ('registers', 'Registers', (0,)),
        ('decodes', 'Decodes', (1,)),
    )

    def __init__(self):
        pass

    def start(self):
        self.out_ann = self.register(srd.OUTPUT_ANN)

    def putx(self, data):
        self.put(self.ss, self.es, self.out_ann, data)

    def decode(self, ss, es, data):
        self.ss, self.es = ss, es
        for (clause45, clause45_address, is_read, portad, devad, register) in data:
            if not is_read:
                continue
            if clause45_address >= 0x8000 and clause45_address <= 0x807F:
                self.putx([0, ['CFP NVR 1: Basic ID register', 'NVR1']])
                if clause45_address == 0x8000:
                    self.putx([1, ['Module identifier: %s' % MODULE_ID.get(register, 'Reserved')]])
            elif clause45_address >= 0x8080 and clause45_address <= 0x80FF:
                self.putx([0, ['CFP NVR 2: Extended ID register', 'NVR2']])
            elif clause45_address >= 0x8100 and clause45_address <= 0x817F:
                self.putx([0, ['CFP NVR 3: Network lane specific register', 'NVR3']])
            elif clause45_address >= 0x8180 and clause45_address <= 0x81FF:
                self.putx([0, ['CFP NVR 4', 'NVR4']])
            elif clause45_address >= 0x8400 and clause45_address <= 0x847F:
                self.putx([0, ['Vendor NVR 1: Vendor data register', 'V-NVR1']])
            elif clause45_address >= 0x8480 and clause45_address <= 0x84FF:
                self.putx([0, ['Vendor NVR 2: Vendor data register', 'V-NVR2']])
            elif clause45_address >= 0x8800 and clause45_address <= 0x887F:
                self.putx([0, ['User NVR 1: User data register', 'U-NVR1']])
            elif clause45_address >= 0x8880 and clause45_address <= 0x88FF:
                self.putx([0, ['User NVR 2: User data register', 'U-NVR2']])
            elif clause45_address >= 0xA000 and clause45_address <= 0xA07F:
                self.putx([0, ['CFP Module VR 1: CFP Module level control and DDM register', 'Mod-VR1']])
            elif clause45_address >= 0xA080 and clause45_address <= 0xA0FF:
                self.putx([0, ['MLG VR 1: MLG Management Interface register', 'MLG-VR1']])