Example #1
0
class PowerPolicyDescriptor(FruAreaBase):
    ''' PICMG Specification MTCA.0 R1.0, Table 3-24 '''

    _schema = [
        ('site_no', fixed_field('u8')),
        ('max_current_override', fixed_field('u16', div=0.1)),
        ('pm_role', fixed_field('u8', constants={
            'primary': 0x00,
            'redundant': 0x01,
            'unspecified': 0xff
        })),
        ('_channel_count', fixed_field('u8')),
        ('_channels', bytearray_field(num_elems_field='_channel_count')),
    ]

    def to_dict(self):
        ''' Convert _channels from bytearray to list of ints '''
        result = super().to_dict()
        result['channels'] = list(self._dict['_channels']._value)
        return result
    
    def update(self, val):
        ''' Convert channels from list of ints to bytearray '''
        self._dict['_channels']._value = bytearray(val['channels'])
        del val['channels']
        super().update(val)
Example #2
0
class PartitionDescriptor(FruAreaBase):
    ''' PICMG Specification MTCA.0 R1.0, Table 3-11 '''

    _schema = [
        ('offset', fixed_field('u16', div=0x10)),
        ('length', fixed_field('u16')),
    ]
Example #3
0
class BoardInfo(FruAreaSized):
    ''' Platform Management FRU Information Storage Definition, Table 11-1 '''

    _schema = [
        ('language_code', fixed_field('u8', default=_language_code)),
        ('mfg_date_time', fixed_field('u24', default=0)),
        ('manufacturer', string_field()),
        ('product_name', string_field()),
        ('serial_number', string_field()),
        ('part_number', string_field()),
        ('fru_file_id', string_field()),
        ('custom_info_fields', custom_string_array()),
    ]

    _time_ref = datetime(1996, 1, 1)

    def _set_mfg_date_time(self, timestamp):
        if timestamp is not None:
            td = timestamp - BoardInfo._time_ref
            minutes = td.seconds // 60 + td.days * (60 * 24)
            self._set('mfg_date_time', minutes)
        else:
            self._set('mfg_date_time', 0)

    def _get_mfg_date_time(self):
        minutes = self._get('mfg_date_time')
        if minutes != 0:
            timestamp = BoardInfo._time_ref + timedelta(minutes=minutes)
            return timestamp
        else:
            return None
Example #4
0
class ArrayTest(FruAreaBase):
    _schema = [
        ('first_byte', fixed_field('u8', default=0)),
        ('second_byte', fixed_field('u8', default=0)),
        ('bits1', fixed_field('u4', default=0)),
        ('bits2', fixed_field('u4', default=0)),
    ]
Example #5
0
class foo(FruAreaBase):
    _schema = [
        ('first2', fixed_field('u2', default=0)),
        ('second2', fixed_field('u2', default=0)),
        ('then4', fixed_field('u4', default=0)),
        ('lastone', fixed_field('u8', default=0)),
    ]
Example #6
0
class MtcaCarrierActivationPm(PicmgEntry):
    ''' PICMG Specification MTCA.0 R1.0, Table 3-25 '''

    _schema = [
        ('readiness_allowance', fixed_field('u8')),
        ('_num_descriptors', fixed_field('u8', default=0)),
        ('descriptors', array_field(MtcaCarrierActivCurrDescriptor, num_elems_field='_num_descriptors')),
    ]
Example #7
0
class ClockConfig(PicmgEntry):
    ''' PICMG AMC.0 Specification R2.0, Table 3-35 '''

    _schema = [
        ('resource_type', fixed_field('u2', constants=_resource_type_constants)),
        ('_reserved', fixed_field('u2', default=0)),
        ('dev_id', fixed_field('u4')),
        ('_conf_desc_count', fixed_field('u8', default=0)),
        ('conf_desc', array_field(ClockConfigDescriptor, num_elems_field='_conf_desc_count')),
    ]
Example #8
0
class ClockP2pResourceDescriptor(FruAreaBase):
    ''' PICMG AMC.0 Specification R2.0, Table 3-30 '''

    _schema = [
        ('resource_type', fixed_field('u2', constants=_resource_type_constants)),
        ('_reserved', fixed_field('u2', default=0)),
        ('dev_id', fixed_field('u4')),
        ('_p2p_clk_conn_count', fixed_field('u8', default=0)),
        ('p2p_clk_conn_descriptors', array_field(P2pClockConnectionDescriptor, num_elems_field='_p2p_clk_conn_count'))
    ]
Example #9
0
class P2pClockConnectionDescriptor(FruAreaBase):
    ''' PICMG AMC.0 Specification R2.0, Table 3-32 '''

    _schema = [
        ('local_clock_id', fixed_field('u8', constants=_clock_id_constants)),
        ('remote_clock_id', fixed_field('u8', constants=_clock_id_constants)),
        ('resource_type', fixed_field('u2', constants=_resource_type_constants)),
        ('_reserved', fixed_field('u2', default=0)),
        ('dev_id', fixed_field('u4')),
    ]
Example #10
0
class IndirectClockDescriptor(FruAreaBase):
    ''' PICMG AMC.0 Specification R2.0, Table 3-37 '''

    _schema = [
        ('_reserved', fixed_field('u6', default=0)),
        ('pll_connect', fixed_field('u1')),
        ('asymm_match', fixed_field('u1', constants={
            'clk_src': 1,
            'clk_recv': 0
        })),
        ('dep_clk_id', fixed_field('u8')),
    ]
Example #11
0
class MtcaCarrierInformation(PicmgEntry):
    ''' PICMG Specification MTCA.0 R1.0, Table 3-16 '''

    _schema = [
        ('number', fixed_field('u8', default=0xff)),
        ('orientation', fixed_field('u1', constants={
            'l2r': 0,
            'b2t': 1
        })),
        ('_slot_entry_count', fixed_field('u7', default=0)),
        ('slot_entries', array_field(SlotEntry, num_elems_field='_slot_entry_count')),
    ]
Example #12
0
class P2pAmcResourceDescriptor(FruAreaBase):
    ''' PICMG AMC.0 Specification R2.0, Table 3-14 '''

    _schema = [
        ('resource_type', fixed_field('u1', constants={
            'amc': 1,
            'carrier': 0
        })),
        ('_reserved', fixed_field('u3', default=0)),
        ('site_no', fixed_field('u4')),
        ('_port_count', fixed_field('u8')),
        ('port_descriptors', array_field(P2pPortDescriptor, num_elems_field='_port_count')),
    ]
Example #13
0
class ClockConfigDescriptor(FruAreaBase):
    ''' PICMG AMC.0 Specification R2.0, Table 3-36 '''
    
    _schema = [
        ('clk_id', fixed_field('u8', constants=_clock_id_constants)),
        ('_reserved', fixed_field('u7', default=0)),
        ('activation', fixed_field('u1', constants={
            'by_carrier': 0,
            'by_application': 1
        })),
        ('_indirect_clk_desc_count', fixed_field('u8', default=0)),
        ('_direct_clk_desc_count', fixed_field('u8', default=0)),
        ('indirect_clk_desc', array_field(IndirectClockDescriptor, num_elems_field='_indirect_clk_desc_count')),
        ('direct_clk_desc', array_field(DirectClockDescriptor, num_elems_field='_direct_clk_desc_count')),
    ]
Example #14
0
class AmcLinkDescriptor(FruAreaBase):
    ''' PICMG AMC.0 Specification R2.0, Table 3-19 '''

    _lane_flag_names = [f'_lane{n}_flag' for n in range(4)]

    _link_type_standard_constants = {
            'pcie': 0x02,
            'pcie_advanced': 0x03,
            'pci_advanced_1': 0x04,
            'ethernet': 0x05,
            'serial_rapidio': 0x06,
            'storage': 0x07
    }
    _link_type_oem_constants = {
        f'oem_guid_{n}': n+0xf0 for n in range(15)
    }

    _schema = [
        ('_reserved', fixed_field('u6', default=0b111111)),
        ('asymm_match', fixed_field('u2', constants={
            'match_exact': 0b00,
            'match_10b': 0b01,
            'match_01b': 0b10
        })),
        ('grouping_id', fixed_field('u8')),
        ('link_type_ext', fixed_field('u4', default=0)),
        ('link_type', fixed_field('u8', constants={
            **_link_type_standard_constants,
            **_link_type_oem_constants
        })),
        ('_lane3_flag', fixed_field('u1')),
        ('_lane2_flag', fixed_field('u1')),
        ('_lane1_flag', fixed_field('u1')),
        ('_lane0_flag', fixed_field('u1')),
        ('channel_id', fixed_field('u8')),
    ]
    _mergeBitfield = True

    def to_dict(self):
        result = super().to_dict()
        result['lane_flags'] = [self[f] for f in self._lane_flag_names]
        return result
    
    def update(self, val):
        for n, f in enumerate(self._lane_flag_names):
            self[f] = val['lane_flags'][n]
        del val['lane_flags']
        super().update(val)
Example #15
0
class FruPartition(PicmgEntry):
    ''' PICMG Specification MTCA.0 R1.0, Table 3-10 '''

    _schema = [
        ('_desc_count', fixed_field('u8', default=0)),
        ('descriptors', array_field(PartitionDescriptor, num_elems_field='_desc_count')),
    ]
Example #16
0
class PowerPolicyRecord(PicmgEntry):
    ''' PICMG Specification MTCA.0 R1.0, Table 3-23 '''

    _schema = [
        ('_num_descriptors', fixed_field('u8', default=0)),
        ('descriptors', array_field(PowerPolicyDescriptor, num_elems_field='_num_descriptors')),
    ]
Example #17
0
class CarrierClkP2pConnectivity(PicmgEntry):
    ''' PICMG AMC.0 Specification R2.0, Table 3-29 '''

    _schema = [
        ('_clk_p2p_resource_desc_count', fixed_field('u8', default=0)),
        ('clk_p2p_resource_descriptors', array_field(ClockP2pResourceDescriptor, num_elems_field='_clk_p2p_resource_desc_count')),
    ]
Example #18
0
class PointToPointConnectivity(PicmgEntry):
    ''' PICMG AMC.0 Specification R2.0, Table 3-16 '''

    _schema = [
        ('_guid_count', fixed_field('u8', default=0)),
        ('guids', array_field(GuidField, num_elems_field='_guid_count')),
        ('record_type', fixed_field('u1', constants={
            'amc_module': 1,
            'on_carrier_device': 0
        })),
        ('_reserved', fixed_field('u3', default=0)),
        ('connected_dev_id', fixed_field('u4', default=0)),
        ('_channel_desc_count', fixed_field('u8', default=0)),
        ('channel_descriptors', array_field(AmcChannelDescriptor, num_elems_field='_channel_desc_count')),
        ('link_descriptors', array_field(AmcLinkDescriptor)),
    ]
Example #19
0
class DCOutput(MultirecordEntry):
    ''' Platform Management FRU Information Storage Definition, Table 18-2 '''

    _schema = [
        ('standby_enable', fixed_field('u1')),
        ('_reserved', fixed_field('u3', default=0)),
        ('output_number', fixed_field('u4', constants=fmc_output_constants)),
        ('nominal_voltage', fixed_field('u16', div=10)),  # 10mV
        ('max_neg_voltage', fixed_field('u16', div=10)),  # 10mV
        ('max_pos_voltage', fixed_field('u16', div=10)),  # 10mV
        ('max_noise_pk2pk', fixed_field('u16')),  # mV
        ('min_current_draw', fixed_field('u16')),  # mA
        ('max_current_draw', fixed_field('u16')),  # mA
    ]
Example #20
0
class ChassisInfo(FruAreaSized):
    ''' Platform Management FRU Information Storage Definition, Table 10-1 '''

    _schema = [
        ('type', fixed_field('u8')),
        ('part_number', string_field()),
        ('serial_number', string_field()),
        ('custom_info_fields', custom_string_array()),
    ]
Example #21
0
class AmcChannelDescriptor(FruAreaBase):
    ''' PICMG AMC.0 Specification R2.0, Table 3-17 '''

    _lanes = [f'_lane{n}_port' for n in range(4)]
    _lane_unused = 0b11111

    _schema = [
        ('_reserved', fixed_field('u4', default=0b1111)),
        ('_lane3_port', fixed_field('u5', default=_lane_unused)),
        ('_lane2_port', fixed_field('u5', default=_lane_unused)),
        ('_lane1_port', fixed_field('u5', default=_lane_unused)),
        ('_lane0_port', fixed_field('u5', default=_lane_unused)),
    ]
    _mergeBitfield = True
    
    def to_dict(self):
        return [self[l] for l in AmcChannelDescriptor._lanes if self[l] != AmcChannelDescriptor._lane_unused]
    
    def update(self, val):
        for i, l in enumerate(AmcChannelDescriptor._lanes):
            self[l] = val[i] if i < len(val) else AmcChannelDescriptor._lane_unused
Example #22
0
class CommonHeader(FruAreaVersioned):
    ''' Platform Management FRU Information Storage Definition, Table 8-1 '''

    _schema = [
        ('internal_use_offs', fixed_field('u8', default=0)),
        ('chassis_info_offs', fixed_field('u8', default=0)),
        ('board_info_offs', fixed_field('u8', default=0)),
        ('product_info_offs', fixed_field('u8', default=0)),
        ('multirecord_offs', fixed_field('u8', default=0)),
    ]

    def __getitem__(self, key):
        return self._get(key) * 8

    def __setitem__(self, key, value):
        if value % 8 != 0:
            raise RuntimeError("Offset not aligned to 64 bit")
        self._set(key, value // 8)

    def reset(self):
        for item in self._dict:
            self._set(item, 0)
Example #23
0
class ProductInfo(FruAreaSized):
    ''' Platform Management FRU Information Storage Definition, Table 12-1 '''

    _schema = [
        ('language_code', fixed_field('u8', default=_language_code)),
        ('manufacturer', string_field()),
        ('product_name', string_field()),
        ('part_number', string_field()),
        ('version', string_field()),
        ('serial_number', string_field()),
        ('asset_tag', string_field()),
        ('fru_file_id', string_field()),
        ('custom_info_fields', custom_string_array()),
    ]
Example #24
0
class Zone3InterfaceCompatibility(PicmgEntry):
    ''' PICMG MicroTCA.4 Enhancements for Rear I/O and Timing R1.0, Table 3-3 '''
    ''' The identifier body is represented as transparent bytearray '''

    _schema = [
        ('identifier_type', fixed_field('u8', constants={
            'PICMG_IRTM0_REP': 0,
            'PICMG_OTHER': 1,
            'GUID': 2,
            'OEM': 3,
            'MTCA4_REP': 4
        })),
        # "format depends on the type" so we assume it's a binary blob
        ('identifier_body', bytearray_field(hex=True)),
    ]
Example #25
0
class SlotEntry(FruAreaBase):
    ''' PICMG Specification MTCA.0 R1.0, Table 3-17 '''

    _schema = [
        ('site_no', fixed_field('u8')),
        ('site_type', fixed_field('u8', constants=_site_type_constants)),
        ('slot_no', fixed_field('u8')),
        ('tier_no', fixed_field('u8')),
        ('slot_org_y', fixed_field('u16')),
        ('slot_org_x', fixed_field('u16')),
    ]
Example #26
0
class MtcaCarrierActivCurrDescriptor(FruAreaBase):
    ''' PICMG Specification MTCA.0 R1.0, Table 3-26 '''

    _mgr_constants={
        'reserved': 0b11,
        'shelf_mgr': 0b10,
        'carrier_mgr': 0b01,
        'system_mgr': 0b00
    }
    _schema = [
        ('site_type', fixed_field('u8', constants=_site_type_constants)),
        ('site_no', fixed_field('u8')),
        ('pwr_ch', fixed_field('u8')),
        ('max_current', fixed_field('u8', div=0.1)),
        ('activation_ctrl', fixed_field('u2', constants=_mgr_constants)),
        ('pwr_delay', fixed_field('u6', div=0.1)),
        ('deactivation_ctrl', fixed_field('u2', constants=_mgr_constants)),
        ('_reserved', fixed_field('u6', default=0))
    ]
Example #27
0
class DirectClockDescriptor(FruAreaBase):
    ''' PICMG AMC.0 Specification R2.0, Table 3-38 '''

    _schema = [
        ('_reserved', fixed_field('u6', default=0)),
        ('pll_connect', fixed_field('u1')),
        ('asymm_match', fixed_field('u1', constants={
            'clk_source': 1,
            'clk_receiver': 0
        })),
        ('family', fixed_field('u8', constants={
            'unspecified': 0,
            'sonet_sdh_pdh': 1,
            'pcie_reserved': 2
        })),
        ('accuracy', fixed_field('u8')),
        ('frequency', fixed_field('u32')),
        ('freq_min', fixed_field('u32')),
        ('freq_max', fixed_field('u32')),
    ]
Example #28
0
class MgmtAccessRecord(MultirecordEntry):
    ''' Platform Management FRU Information Storage Definition, Table 18-6 '''

    _schema = [
        ('id',
         fixed_field('u8',
                     constants={
                         'sys_mgmt_url': 1,
                         'sys_name': 2,
                         'sys_ping_addr': 3,
                         'comp_mgmt_url': 4,
                         'comp_name': 5,
                         'comp_ping_addr': 6,
                         'sys_unique_id': 7
                     })),
        # TODO: edge case 'sys_unique_id' (GUID) needs conversion between string and GUID
        # For now we assume the blob is always a string
        ('blob', bytearray_field(hex=False)),
    ]
Example #29
0
class P2pPortDescriptor(FruAreaBase):
    ''' PICMG AMC.0 Specification R2.0, Table 3-15 '''

    _mergeBitfield = True

    _schema = [
        ('_reserved0', fixed_field('u6', default=0)),
        ('local_port', fixed_field('u5')),
        ('remote_port', fixed_field('u5')),
        ('resource_type', fixed_field('u1', constants={
            'amc': 1,
            'carrier': 0
        })),
        ('_reserved1', fixed_field('u3', default=0)),
        ('site_no', fixed_field('u4')),
    ]
Example #30
0
class FmcMainDefinition(FmcEntry):
    ''' ANSI/VITA 57.1 FMC Standard, Table 7 '''

    _schema = [('module_size',
                fixed_field('u2',
                            constants={
                                'single_width': 0b00,
                                'double_width': 0b01
                            })),
               ('p1_connector_size',
                fixed_field('u2', constants={
                    'lpc': 0b00,
                    'hpc': 0b01
                })),
               ('p2_connector_size',
                fixed_field('u2',
                            constants={
                                'lpc': 0b00,
                                'hpc': 0b01,
                                'not_fitted': 0b11,
                            })),
               ('clock_direction',
                fixed_field('u1', constants={
                    'm2c': 0b0,
                    'c2m': 0b1,
                })), ('_reserved', fixed_field('u1', default=0)),
               ('p1_a_num_signals', fixed_field('u8')),
               ('p1_b_num_signals', fixed_field('u8')),
               ('p2_a_num_signals', fixed_field('u8')),
               ('p2_b_num_signals', fixed_field('u8')),
               ('p1_gbt_num_trcv', fixed_field('u4')),
               ('p2_gbt_num_trcv', fixed_field('u4')),
               ('tck_max_clock', fixed_field('u8'))]