[devices] add new accton platform minipack (#2670)
[devices] add new accton platform minipack. Add support for new platform, minipack. It has CPU: Broadwell DE – D1527 MAC: Tomahawk3(BCM56980). PHY:Broadcom BCM81724, 4 pcs, Gearbox for PIM-16Q BMC:AST2520 8 hot-swappable Port-Interface-Modules, each of them has 16*100G QSFP. - What I did Add device and platform files for minipack. - How I did it Add as SONiC Porting Guide. - How to verify it decode-syseeprom sensors psuutil sfputil thermal monitor bcmsh on port status (port LEDs may not working)
This commit is contained in:
parent
383d52956e
commit
802d5ef55a
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
129
device/accton/x86_64-accton_minipack-r0/Accton-MINIPACK/port_config.ini
Executable file
129
device/accton/x86_64-accton_minipack-r0/Accton-MINIPACK/port_config.ini
Executable file
@ -0,0 +1,129 @@
|
|||||||
|
# name lanes alias index
|
||||||
|
Ethernet1 5,6 onehundredGigE1 0
|
||||||
|
Ethernet2 7,8 onehundredGigE2 1
|
||||||
|
Ethernet3 1,2 onehundredGigE3 2
|
||||||
|
Ethernet4 3,4 onehundredGigE4 3
|
||||||
|
Ethernet5 37,38 onehundredGigE5 4
|
||||||
|
Ethernet6 39,40 onehundredGigE6 5
|
||||||
|
Ethernet7 33,34 onehundredGigE7 6
|
||||||
|
Ethernet8 35,36 onehundredGigE8 7
|
||||||
|
Ethernet9 69,70 onehundredGigE9 8
|
||||||
|
Ethernet10 71,72 onehundredGigE10 9
|
||||||
|
Ethernet11 65,66 onehundredGigE11 10
|
||||||
|
Ethernet12 67,68 onehundredGigE12 11
|
||||||
|
Ethernet13 101,102 onehundredGigE13 12
|
||||||
|
Ethernet14 103,104 onehundredGigE14 13
|
||||||
|
Ethernet15 97,98 onehundredGigE15 14
|
||||||
|
Ethernet16 99,100 onehundredGigE16 15
|
||||||
|
Ethernet17 13,14 onehundredGigE17 16
|
||||||
|
Ethernet18 15,16 onehundredGigE18 17
|
||||||
|
Ethernet19 9,10 onehundredGigE19 18
|
||||||
|
Ethernet20 11,12 onehundredGigE20 19
|
||||||
|
Ethernet21 45,46 onehundredGigE21 20
|
||||||
|
Ethernet22 47,48 onehundredGigE22 21
|
||||||
|
Ethernet23 41,42 onehundredGigE23 22
|
||||||
|
Ethernet24 43,44 onehundredGigE24 23
|
||||||
|
Ethernet25 77,78 onehundredGigE25 24
|
||||||
|
Ethernet26 79,80 onehundredGigE26 25
|
||||||
|
Ethernet27 73,74 onehundredGigE27 26
|
||||||
|
Ethernet28 75,76 onehundredGigE28 27
|
||||||
|
Ethernet29 109,110 onehundredGigE29 28
|
||||||
|
Ethernet30 111,112 onehundredGigE30 29
|
||||||
|
Ethernet31 105,106 onehundredGigE31 30
|
||||||
|
Ethernet32 107,108 onehundredGigE32 31
|
||||||
|
Ethernet33 21,22 onehundredGigE33 32
|
||||||
|
Ethernet34 23,24 onehundredGigE34 33
|
||||||
|
Ethernet35 17,18 onehundredGigE35 34
|
||||||
|
Ethernet36 19,20 onehundredGigE36 35
|
||||||
|
Ethernet37 53,54 onehundredGigE37 36
|
||||||
|
Ethernet38 55,56 onehundredGigE38 37
|
||||||
|
Ethernet39 49,50 onehundredGigE39 38
|
||||||
|
Ethernet40 51,52 onehundredGigE40 39
|
||||||
|
Ethernet41 85,86 onehundredGigE41 40
|
||||||
|
Ethernet42 87,88 onehundredGigE42 41
|
||||||
|
Ethernet43 81,82 onehundredGigE43 42
|
||||||
|
Ethernet44 83,84 onehundredGigE44 43
|
||||||
|
Ethernet45 117,118 onehundredGigE45 44
|
||||||
|
Ethernet46 119,120 onehundredGigE46 45
|
||||||
|
Ethernet47 113,114 onehundredGigE47 46
|
||||||
|
Ethernet48 115,116 onehundredGigE48 47
|
||||||
|
Ethernet49 29,30 onehundredGigE49 48
|
||||||
|
Ethernet50 31,32 onehundredGigE50 49
|
||||||
|
Ethernet51 25,26 onehundredGigE51 50
|
||||||
|
Ethernet52 27,28 onehundredGigE52 51
|
||||||
|
Ethernet53 61,62 onehundredGigE53 52
|
||||||
|
Ethernet54 63,64 onehundredGigE54 53
|
||||||
|
Ethernet55 57,58 onehundredGigE55 54
|
||||||
|
Ethernet56 59,60 onehundredGigE56 55
|
||||||
|
Ethernet57 93,94 onehundredGigE57 56
|
||||||
|
Ethernet58 95,96 onehundredGigE58 57
|
||||||
|
Ethernet59 89,90 onehundredGigE59 58
|
||||||
|
Ethernet60 91,92 onehundredGigE60 59
|
||||||
|
Ethernet61 125,126 onehundredGigE61 60
|
||||||
|
Ethernet62 127,128 onehundredGigE62 61
|
||||||
|
Ethernet63 121,122 onehundredGigE63 62
|
||||||
|
Ethernet64 123,124 onehundredGigE64 63
|
||||||
|
Ethernet65 133,134 onehundredGigE65 64
|
||||||
|
Ethernet66 135,136 onehundredGigE66 65
|
||||||
|
Ethernet67 129,130 onehundredGigE67 66
|
||||||
|
Ethernet68 131,132 onehundredGigE68 67
|
||||||
|
Ethernet69 165,166 onehundredGigE69 68
|
||||||
|
Ethernet70 167,168 onehundredGigE70 69
|
||||||
|
Ethernet71 161,162 onehundredGigE71 70
|
||||||
|
Ethernet72 163,164 onehundredGigE72 71
|
||||||
|
Ethernet73 197,198 onehundredGigE73 72
|
||||||
|
Ethernet74 199,200 onehundredGigE74 73
|
||||||
|
Ethernet75 193,194 onehundredGigE75 74
|
||||||
|
Ethernet76 195,196 onehundredGigE76 75
|
||||||
|
Ethernet77 229,230 onehundredGigE77 76
|
||||||
|
Ethernet78 231,232 onehundredGigE78 77
|
||||||
|
Ethernet79 225,226 onehundredGigE79 78
|
||||||
|
Ethernet80 227,228 onehundredGigE80 79
|
||||||
|
Ethernet81 141,142 onehundredGigE81 80
|
||||||
|
Ethernet82 143,144 onehundredGigE82 81
|
||||||
|
Ethernet83 137,138 onehundredGigE83 82
|
||||||
|
Ethernet84 139,140 onehundredGigE84 83
|
||||||
|
Ethernet85 173,174 onehundredGigE85 84
|
||||||
|
Ethernet86 175,176 onehundredGigE86 85
|
||||||
|
Ethernet87 169,170 onehundredGigE87 86
|
||||||
|
Ethernet88 171,172 onehundredGigE88 87
|
||||||
|
Ethernet89 205,206 onehundredGigE89 88
|
||||||
|
Ethernet90 207,208 onehundredGigE90 89
|
||||||
|
Ethernet91 201,202 onehundredGigE91 90
|
||||||
|
Ethernet92 203,204 onehundredGigE92 91
|
||||||
|
Ethernet93 237,238 onehundredGigE93 92
|
||||||
|
Ethernet94 239,240 onehundredGigE94 93
|
||||||
|
Ethernet95 233,234 onehundredGigE95 94
|
||||||
|
Ethernet96 235,236 onehundredGigE96 95
|
||||||
|
Ethernet97 149,150 onehundredGigE97 96
|
||||||
|
Ethernet98 151,152 onehundredGigE98 97
|
||||||
|
Ethernet99 145,146 onehundredGigE99 98
|
||||||
|
Ethernet100 147,148 onehundredGigE100 99
|
||||||
|
Ethernet101 181,182 onehundredGigE101 100
|
||||||
|
Ethernet102 183,184 onehundredGigE102 101
|
||||||
|
Ethernet103 177,178 onehundredGigE103 102
|
||||||
|
Ethernet104 179,180 onehundredGigE104 103
|
||||||
|
Ethernet105 213,214 onehundredGigE105 104
|
||||||
|
Ethernet106 215,216 onehundredGigE106 105
|
||||||
|
Ethernet107 209,210 onehundredGigE107 106
|
||||||
|
Ethernet108 211,212 onehundredGigE108 107
|
||||||
|
Ethernet109 245,246 onehundredGigE109 108
|
||||||
|
Ethernet110 247,248 onehundredGigE110 109
|
||||||
|
Ethernet111 241,242 onehundredGigE111 110
|
||||||
|
Ethernet112 243,244 onehundredGigE112 111
|
||||||
|
Ethernet113 157,158 onehundredGigE113 112
|
||||||
|
Ethernet114 159,160 onehundredGigE114 113
|
||||||
|
Ethernet115 153,154 onehundredGigE115 114
|
||||||
|
Ethernet116 155,156 onehundredGigE116 115
|
||||||
|
Ethernet117 189,190 onehundredGigE117 116
|
||||||
|
Ethernet118 191,192 onehundredGigE118 117
|
||||||
|
Ethernet119 185,186 onehundredGigE119 118
|
||||||
|
Ethernet120 187,188 onehundredGigE120 119
|
||||||
|
Ethernet121 221,222 onehundredGigE121 120
|
||||||
|
Ethernet122 223,224 onehundredGigE122 121
|
||||||
|
Ethernet123 217,218 onehundredGigE123 122
|
||||||
|
Ethernet124 219,220 onehundredGigE124 123
|
||||||
|
Ethernet125 253,254 onehundredGigE125 124
|
||||||
|
Ethernet126 255,256 onehundredGigE126 125
|
||||||
|
Ethernet127 249,250 onehundredGigE127 126
|
||||||
|
Ethernet128 251,252 onehundredGigE128 127
|
1
device/accton/x86_64-accton_minipack-r0/Accton-MINIPACK/sai.profile
Executable file
1
device/accton/x86_64-accton_minipack-r0/Accton-MINIPACK/sai.profile
Executable file
@ -0,0 +1 @@
|
|||||||
|
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/config_16Q_FEC544_EVTB_100G.bcm
|
1
device/accton/x86_64-accton_minipack-r0/default_sku
Normal file
1
device/accton/x86_64-accton_minipack-r0/default_sku
Normal file
@ -0,0 +1 @@
|
|||||||
|
Accton-MINIPACK t1
|
4
device/accton/x86_64-accton_minipack-r0/installer.conf
Executable file
4
device/accton/x86_64-accton_minipack-r0/installer.conf
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
CONSOLE_PORT=0x3f8
|
||||||
|
CONSOLE_DEV=0
|
||||||
|
CONSOLE_SPEED=57600
|
||||||
|
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="pcie_aspm=off"
|
1
device/accton/x86_64-accton_minipack-r0/led_proc_init.soc
Executable file
1
device/accton/x86_64-accton_minipack-r0/led_proc_init.soc
Executable file
@ -0,0 +1 @@
|
|||||||
|
|
21
device/accton/x86_64-accton_minipack-r0/plugins/eeprom.py
Normal file
21
device/accton/x86_64-accton_minipack-r0/plugins/eeprom.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
try:
|
||||||
|
import exceptions
|
||||||
|
import binascii
|
||||||
|
import time
|
||||||
|
import optparse
|
||||||
|
import warnings
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from sonic_eeprom import eeprom_base
|
||||||
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
|
import subprocess
|
||||||
|
except ImportError, e:
|
||||||
|
raise ImportError (str(e) + "- required module not found")
|
||||||
|
|
||||||
|
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||||
|
_TLV_INFO_MAX_LEN = 256
|
||||||
|
def __init__(self, name, path, cpld_root, ro):
|
||||||
|
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||||
|
super(board, self).__init__(self.eeprom_path, 0x200, '', True)
|
57
device/accton/x86_64-accton_minipack-r0/plugins/psuutil.py
Normal file
57
device/accton/x86_64-accton_minipack-r0/plugins/psuutil.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# Accton
|
||||||
|
#
|
||||||
|
# Module contains an implementation of SONiC PSU Base API and
|
||||||
|
# provides the PSUs status which are available in the platform
|
||||||
|
#
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
try:
|
||||||
|
from sonic_psu.psu_base import PsuBase
|
||||||
|
except ImportError as e:
|
||||||
|
raise ImportError (str(e) + "- required module not found")
|
||||||
|
|
||||||
|
class PsuUtil(PsuBase):
|
||||||
|
"""Platform-specific PSUutil class"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
PsuBase.__init__(self)
|
||||||
|
|
||||||
|
self.num = 4
|
||||||
|
self.psu_path = "/sys/bus/platform/devices/minipack_psensor/"
|
||||||
|
self.psu_voltage = "/in{0}_input"
|
||||||
|
|
||||||
|
def get_num_psus(self):
|
||||||
|
return self.num
|
||||||
|
|
||||||
|
def get_psu_status(self, index):
|
||||||
|
if index is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
status = 0
|
||||||
|
node = self.psu_path + self.psu_voltage.format(index*2-1)
|
||||||
|
try:
|
||||||
|
with open(node, 'r') as power_status:
|
||||||
|
status = int(power_status.read())
|
||||||
|
except IOError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return status > 0
|
||||||
|
|
||||||
|
def get_psu_presence(self, index):
|
||||||
|
if index is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
status = 0
|
||||||
|
node = self.psu_path + self.psu_voltage.format(index*2)
|
||||||
|
try:
|
||||||
|
with open(node, 'r') as presence_status:
|
||||||
|
status = int(presence_status.read())
|
||||||
|
except IOError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return status > 0
|
94
device/accton/x86_64-accton_minipack-r0/plugins/sfputil.py
Normal file
94
device/accton/x86_64-accton_minipack-r0/plugins/sfputil.py
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
# sfputil.py
|
||||||
|
#
|
||||||
|
# Platform-specific SFP transceiver interface for SONiC
|
||||||
|
#
|
||||||
|
|
||||||
|
try:
|
||||||
|
import time
|
||||||
|
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||||
|
except ImportError as e:
|
||||||
|
raise ImportError("%s - required module not found" % str(e))
|
||||||
|
|
||||||
|
|
||||||
|
class SfpUtil(SfpUtilBase):
|
||||||
|
"""Platform-specific SfpUtil class"""
|
||||||
|
|
||||||
|
PORT_START = 0
|
||||||
|
PORT_END = 128
|
||||||
|
|
||||||
|
BASE_OOM_PATH = "/sys/bus/i2c/devices/{0}-0050/"
|
||||||
|
|
||||||
|
_port_to_is_present = {}
|
||||||
|
_port_to_lp_mode = {}
|
||||||
|
|
||||||
|
_port_to_eeprom_mapping = {}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def port_start(self):
|
||||||
|
return self.PORT_START
|
||||||
|
|
||||||
|
@property
|
||||||
|
def port_end(self):
|
||||||
|
return self.PORT_END
|
||||||
|
|
||||||
|
@property
|
||||||
|
def qsfp_ports(self):
|
||||||
|
return range(self.PORT_START, self.PORT_END + 1)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def port_to_eeprom_mapping(self):
|
||||||
|
return self._port_to_eeprom_mapping
|
||||||
|
|
||||||
|
def sfp_map(self, index):
|
||||||
|
port = index + 1
|
||||||
|
base = ((port-1)/8*8) + 10
|
||||||
|
index = (port - 1) % 8
|
||||||
|
index = 7 - index
|
||||||
|
if (index%2):
|
||||||
|
index = index -1
|
||||||
|
else:
|
||||||
|
index = index +1
|
||||||
|
bus = base + index
|
||||||
|
return bus
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
eeprom_path = self.BASE_OOM_PATH + "eeprom"
|
||||||
|
|
||||||
|
for x in range(0, self.port_end+1):
|
||||||
|
bus = self.sfp_map(x)
|
||||||
|
self.port_to_eeprom_mapping[x] = eeprom_path.format(
|
||||||
|
bus)
|
||||||
|
|
||||||
|
SfpUtilBase.__init__(self)
|
||||||
|
|
||||||
|
def get_presence(self, port_num):
|
||||||
|
# Check for invalid port_num
|
||||||
|
if port_num < self.port_start or port_num > self.port_end:
|
||||||
|
return False
|
||||||
|
|
||||||
|
eeprom_path = self.port_to_eeprom_mapping[port_num]
|
||||||
|
with open(eeprom_path) as f:
|
||||||
|
try:
|
||||||
|
content = f.read(1)
|
||||||
|
except IOError as e:
|
||||||
|
#Not print any error, for if any, treat as Not present.
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def get_low_power_mode(self, port_num):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def set_low_power_mode(self, port_num, lpmode):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def reset(self, port_num):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def get_transceiver_change_event(self):
|
||||||
|
"""
|
||||||
|
TODO: This function need to be implemented
|
||||||
|
when decide to support monitoring SFP(Xcvrd)
|
||||||
|
on this platform.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
3
device/accton/x86_64-accton_minipack-r0/sensors.conf
Executable file
3
device/accton/x86_64-accton_minipack-r0/sensors.conf
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
# libsensors configuration file
|
||||||
|
# ------------------------------------------------
|
||||||
|
|
@ -22,6 +22,7 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \
|
|||||||
$(ACCTON_AS7716_32XB_PLATFORM_MODULE) \
|
$(ACCTON_AS7716_32XB_PLATFORM_MODULE) \
|
||||||
$(ACCTON_AS6712_32X_PLATFORM_MODULE) \
|
$(ACCTON_AS6712_32X_PLATFORM_MODULE) \
|
||||||
$(ACCTON_AS7726_32X_PLATFORM_MODULE) \
|
$(ACCTON_AS7726_32X_PLATFORM_MODULE) \
|
||||||
|
$(ACCTON_MINIPACK_PLATFORM_MODULE) \
|
||||||
$(INVENTEC_D7032Q28B_PLATFORM_MODULE) \
|
$(INVENTEC_D7032Q28B_PLATFORM_MODULE) \
|
||||||
$(INVENTEC_D7054Q28B_PLATFORM_MODULE) \
|
$(INVENTEC_D7054Q28B_PLATFORM_MODULE) \
|
||||||
$(INVENTEC_D7264Q28B_PLATFORM_MODULE) \
|
$(INVENTEC_D7264Q28B_PLATFORM_MODULE) \
|
||||||
|
@ -9,6 +9,7 @@ ACCTON_AS7326_56X_PLATFORM_MODULE_VERSION = 1.1
|
|||||||
ACCTON_AS7716_32XB_PLATFORM_MODULE_VERSION = 1.1
|
ACCTON_AS7716_32XB_PLATFORM_MODULE_VERSION = 1.1
|
||||||
ACCTON_AS6712_32X_PLATFORM_MODULE_VERSION = 1.1
|
ACCTON_AS6712_32X_PLATFORM_MODULE_VERSION = 1.1
|
||||||
ACCTON_AS7726_32X_PLATFORM_MODULE_VERSION = 1.1
|
ACCTON_AS7726_32X_PLATFORM_MODULE_VERSION = 1.1
|
||||||
|
ACCTON_MINIPACK_PLATFORM_MODULE_VERSION = 1.1
|
||||||
|
|
||||||
export ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION
|
export ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION
|
||||||
export ACCTON_AS5712_54X_PLATFORM_MODULE_VERSION
|
export ACCTON_AS5712_54X_PLATFORM_MODULE_VERSION
|
||||||
@ -19,6 +20,7 @@ export ACCTON_AS7326_56X_PLATFORM_MODULE_VERSION
|
|||||||
export ACCTON_AS7716_32XB_PLATFORM_MODULE_VERSION
|
export ACCTON_AS7716_32XB_PLATFORM_MODULE_VERSION
|
||||||
export ACCTON_AS6712_32X_PLATFORM_MODULE_VERSION
|
export ACCTON_AS6712_32X_PLATFORM_MODULE_VERSION
|
||||||
export ACCTON_AS7726_32X_PLATFORM_MODULE_VERSION
|
export ACCTON_AS7726_32X_PLATFORM_MODULE_VERSION
|
||||||
|
export ACCTON_MINIPACK_PLATFORM_MODULE_VERSION
|
||||||
|
|
||||||
ACCTON_AS7712_32X_PLATFORM_MODULE = sonic-platform-accton-as7712-32x_$(ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION)_amd64.deb
|
ACCTON_AS7712_32X_PLATFORM_MODULE = sonic-platform-accton-as7712-32x_$(ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||||
$(ACCTON_AS7712_32X_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-accton
|
$(ACCTON_AS7712_32X_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-accton
|
||||||
@ -58,4 +60,8 @@ ACCTON_AS7726_32X_PLATFORM_MODULE = sonic-platform-accton-as7726-32x_$(ACCTON_AS
|
|||||||
$(ACCTON_AS7726_32X_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as7726_32x-r0
|
$(ACCTON_AS7726_32X_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as7726_32x-r0
|
||||||
$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS7726_32X_PLATFORM_MODULE)))
|
$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS7726_32X_PLATFORM_MODULE)))
|
||||||
|
|
||||||
|
ACCTON_MINIPACK_PLATFORM_MODULE = sonic-platform-accton-minipack_$(ACCTON_MINIPACK_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||||
|
$(ACCTON_MINIPACK_PLATFORM_MODULE)_PLATFORM = x86_64-accton_minipack-r0
|
||||||
|
$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_MINIPACK_PLATFORM_MODULE)))
|
||||||
|
|
||||||
SONIC_STRETCH_DEBS += $(ACCTON_AS7712_32X_PLATFORM_MODULE)
|
SONIC_STRETCH_DEBS += $(ACCTON_AS7712_32X_PLATFORM_MODULE)
|
||||||
|
@ -41,3 +41,7 @@ Package: sonic-platform-accton-as7726-32x
|
|||||||
Architecture: amd64
|
Architecture: amd64
|
||||||
Description: kernel modules for platform devices such as fan, led, sfp
|
Description: kernel modules for platform devices such as fan, led, sfp
|
||||||
|
|
||||||
|
Package: sonic-platform-accton-minipack
|
||||||
|
Architecture: amd64
|
||||||
|
Description: kernel modules for platform devices such as fan, led, sfp
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ PACKAGE_PRE_NAME := sonic-platform-accton
|
|||||||
KVERSION ?= $(shell uname -r)
|
KVERSION ?= $(shell uname -r)
|
||||||
KERNEL_SRC := /lib/modules/$(KVERSION)
|
KERNEL_SRC := /lib/modules/$(KVERSION)
|
||||||
MOD_SRC_DIR:= $(shell pwd)
|
MOD_SRC_DIR:= $(shell pwd)
|
||||||
MODULE_DIRS:= as7712-32x as5712-54x as7816-64x as7716-32x as7716-32xb as7312-54x as7326-56x as6712-32x as7726-32x
|
MODULE_DIRS:= as7712-32x as5712-54x as7816-64x as7716-32x as7716-32xb as7312-54x as7326-56x as6712-32x as7726-32x minipack
|
||||||
MODULE_DIR := modules
|
MODULE_DIR := modules
|
||||||
UTILS_DIR := utils
|
UTILS_DIR := utils
|
||||||
SERVICE_DIR := service
|
SERVICE_DIR := service
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
obj-m:= minipack_psensor.o
|
1097
platform/broadcom/sonic-platform-modules-accton/minipack/modules/minipack_psensor.c
Executable file
1097
platform/broadcom/sonic-platform-modules-accton/minipack/modules/minipack_psensor.c
Executable file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Accton MiniPack Platform Monitoring service
|
||||||
|
Before=pmon.service
|
||||||
|
After=sysinit.target
|
||||||
|
DefaultDependencies=no
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/local/bin/accton_minipack_util.py install
|
||||||
|
ExecStop=/usr/local/bin/accton_minipack_util.py clean
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from setuptools import setup
|
||||||
|
os.listdir
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='minipack',
|
||||||
|
version='1.0',
|
||||||
|
description='Module to initialize Accton MiniPack platforms',
|
||||||
|
|
||||||
|
packages=['minipack'],
|
||||||
|
package_dir={'minipack': 'minipack/classes'},
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,48 @@
|
|||||||
|
Copyright (C) 2019 Accton Networks, Inc.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
It under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Contents of this package:
|
||||||
|
module - Contains source code of kernel driver modules.
|
||||||
|
util - operational scripts.
|
||||||
|
|
||||||
|
Sonic creates a docker container and run building process under it.
|
||||||
|
If user tries to built new drivers, please get into that docker and
|
||||||
|
dpkg-buildpackage for them.
|
||||||
|
|
||||||
|
All Linux kernel code is licensed under the GPLv1. All other code is
|
||||||
|
licensed under the GPLv3. Please see the LICENSE file for copies of
|
||||||
|
both licenses.
|
||||||
|
|
||||||
|
====================================================================
|
||||||
|
The most of peripherals are accessed through BMC.
|
||||||
|
Only system eeprom and QSFP are directly accessed by CPU.
|
||||||
|
|
||||||
|
System LED:
|
||||||
|
There are 2 system LEDs at the upper-left corner of front panel.
|
||||||
|
|
||||||
|
Fan Control:
|
||||||
|
There are 16 fans inside 8 fan modules.
|
||||||
|
|
||||||
|
Thermal sensers:
|
||||||
|
8 temperature sensors are controlled by the lm75 kernel modules.
|
||||||
|
|
||||||
|
PSUs:
|
||||||
|
There r42 power supplies slot at the back.
|
||||||
|
Once if a PSU is not plugged, the data of it is shown all 0's.
|
||||||
|
|
||||||
|
There are 128 QSFP modules are equipped.
|
||||||
|
Before operating on PSU and QSFP+, please make sure it is well plugged.
|
||||||
|
Otherwise, operation is going to fail.
|
||||||
|
|
@ -0,0 +1,512 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Copyright (C) 2016 Accton Networks, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Description:
|
||||||
|
# Due to adoption of optoe drivers, sideband signals of SFPs are moved
|
||||||
|
# into cpld drivers. Add a new dict, cpld_of_module, for mapping this
|
||||||
|
# attributes to corresponding cpld nodes.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Usage: %(scriptName)s [options] command object
|
||||||
|
|
||||||
|
options:
|
||||||
|
-h | --help : this help message
|
||||||
|
-d | --debug : run with debug mode
|
||||||
|
-f | --force : ignore error during installation or clean
|
||||||
|
command:
|
||||||
|
install : install drivers and generate related sysfs nodes
|
||||||
|
clean : uninstall drivers and remove related sysfs nodes
|
||||||
|
show : show all systen status
|
||||||
|
sff : dump SFP eeprom
|
||||||
|
set : change board setting with led|sfp
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import commands
|
||||||
|
import sys, getopt
|
||||||
|
import logging
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
PROJECT_NAME = 'minipack'
|
||||||
|
version = '0.2.0'
|
||||||
|
verbose = False
|
||||||
|
DEBUG = False
|
||||||
|
args = []
|
||||||
|
ALL_DEVICE = {}
|
||||||
|
DEVICE_NO = {'led':5, 'psu':2, 'sfp':32}
|
||||||
|
|
||||||
|
|
||||||
|
led_prefix =''
|
||||||
|
hwmon_types = {'led': ['diag','loc'],
|
||||||
|
}
|
||||||
|
hwmon_nodes = {'led': ['brightness'] ,
|
||||||
|
}
|
||||||
|
hwmon_prefix ={'led': led_prefix,
|
||||||
|
}
|
||||||
|
|
||||||
|
i2c_prefix = '/sys/bus/i2c/devices/'
|
||||||
|
i2c_bus = {
|
||||||
|
'psu': ['35-0038','36-003b'],
|
||||||
|
'sfp': ['-0050']}
|
||||||
|
i2c_nodes = {
|
||||||
|
'psu': ['psu_present ', 'psu_power_good'] ,
|
||||||
|
'sfp': ['module_present_', 'sfp_tx_disable']}
|
||||||
|
|
||||||
|
NO_QSFP = 128
|
||||||
|
|
||||||
|
#For sideband signals of SFP/QSFP modules.
|
||||||
|
cpld_of_module = {'-0062': list(range(0,16)),
|
||||||
|
'-0064': list(range(16,32)) }
|
||||||
|
|
||||||
|
|
||||||
|
mknod =[
|
||||||
|
'echo pca9548 0x70 > /sys/bus/i2c/devices/i2c-1/new_device',
|
||||||
|
'echo 24c64 0x57 > /sys/bus/i2c/devices/i2c-1/new_device',
|
||||||
|
]
|
||||||
|
|
||||||
|
FORCE = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if DEBUG == True:
|
||||||
|
print sys.argv[0]
|
||||||
|
print 'ARGV :', sys.argv[1:]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
global DEBUG
|
||||||
|
global args
|
||||||
|
global FORCE
|
||||||
|
|
||||||
|
if len(sys.argv)<2:
|
||||||
|
show_help()
|
||||||
|
|
||||||
|
options, args = getopt.getopt(sys.argv[1:], 'hdf', ['help',
|
||||||
|
'debug',
|
||||||
|
'force',
|
||||||
|
])
|
||||||
|
if DEBUG == True:
|
||||||
|
print options
|
||||||
|
print args
|
||||||
|
print len(sys.argv)
|
||||||
|
|
||||||
|
for opt, arg in options:
|
||||||
|
if opt in ('-h', '--help'):
|
||||||
|
show_help()
|
||||||
|
elif opt in ('-d', '--debug'):
|
||||||
|
DEBUG = True
|
||||||
|
logging.basicConfig(filename= PROJECT_NAME+'.log', filemode='w',level=logging.DEBUG)
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
elif opt in ('-f', '--force'):
|
||||||
|
FORCE = 1
|
||||||
|
else:
|
||||||
|
logging.info('no option')
|
||||||
|
for arg in args:
|
||||||
|
if arg == 'install':
|
||||||
|
do_install()
|
||||||
|
elif arg == 'clean':
|
||||||
|
do_uninstall()
|
||||||
|
elif arg == 'show':
|
||||||
|
device_traversal()
|
||||||
|
elif arg == 'sff':
|
||||||
|
if len(args)!=2:
|
||||||
|
show_eeprom_help()
|
||||||
|
elif int(args[1]) ==0 or int(args[1]) > DEVICE_NO['sfp']:
|
||||||
|
show_eeprom_help()
|
||||||
|
else:
|
||||||
|
show_eeprom(args[1])
|
||||||
|
return
|
||||||
|
elif arg == 'set':
|
||||||
|
if len(args)<3:
|
||||||
|
show_set_help()
|
||||||
|
else:
|
||||||
|
set_device(args[1:])
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
show_help()
|
||||||
|
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def show_help():
|
||||||
|
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
def show_set_help():
|
||||||
|
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||||
|
print cmd +" [led|sfp]"
|
||||||
|
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||||
|
print " use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
def show_eeprom_help():
|
||||||
|
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||||
|
print " use \""+ cmd + " 1-54 \" to dump sfp# eeprom"
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
def my_log(txt):
|
||||||
|
if DEBUG == True:
|
||||||
|
print "[ACCTON DBG]: "+txt
|
||||||
|
return
|
||||||
|
|
||||||
|
def log_os_system(cmd, show):
|
||||||
|
logging.info('Run :'+cmd)
|
||||||
|
status = 1
|
||||||
|
output = ""
|
||||||
|
status, output = commands.getstatusoutput(cmd)
|
||||||
|
my_log (cmd +"with result:" + str(status))
|
||||||
|
my_log ("cmd:" + cmd)
|
||||||
|
my_log (" output:"+output)
|
||||||
|
if status:
|
||||||
|
logging.info('Failed :'+cmd)
|
||||||
|
if show:
|
||||||
|
print('Failed :'+cmd)
|
||||||
|
return status, output
|
||||||
|
|
||||||
|
def driver_inserted():
|
||||||
|
ret, lsmod = log_os_system("lsmod| grep accton", 0)
|
||||||
|
logging.info('mods:'+lsmod)
|
||||||
|
if len(lsmod) ==0:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
kos = [
|
||||||
|
'depmod -ae',
|
||||||
|
'modprobe i2c_dev',
|
||||||
|
'modprobe i2c_mux_pca954x force_deselect_on_exit=1',
|
||||||
|
#'modprobe i2c_mux_pca954x',
|
||||||
|
'modprobe optoe',
|
||||||
|
'modprobe minipack_psensor']
|
||||||
|
|
||||||
|
def driver_install():
|
||||||
|
for i in range(0,len(kos)):
|
||||||
|
status, output = log_os_system(kos[i], 1)
|
||||||
|
if status:
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def driver_uninstall():
|
||||||
|
for i in range(0,len(kos)):
|
||||||
|
rm = kos[-(i+1)].replace("modprobe", "modprobe -rq")
|
||||||
|
rm = rm.replace("insmod", "rmmod")
|
||||||
|
status, output = log_os_system(rm, 1)
|
||||||
|
if status:
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def sfp_map(index):
|
||||||
|
port = index + 1
|
||||||
|
base = ((port-1)/8*8) + 10
|
||||||
|
index = (port - 1) % 8
|
||||||
|
index = 7 - index
|
||||||
|
if (index%2):
|
||||||
|
index = index -1
|
||||||
|
else:
|
||||||
|
index = index +1
|
||||||
|
bus = base + index
|
||||||
|
return bus
|
||||||
|
|
||||||
|
def device_install():
|
||||||
|
for i in range(0,len(mknod)):
|
||||||
|
#for pca932x need times to built new i2c buses
|
||||||
|
if mknod[i].find('pca954') != -1:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
status, output = log_os_system(mknod[i], 1)
|
||||||
|
if status:
|
||||||
|
print output
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
|
||||||
|
# initialize multiplexer for 8 PIMs
|
||||||
|
cmdl = "echo pca9548 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device"
|
||||||
|
for pim in range(2, 10):
|
||||||
|
cmdm = cmdl % (0x72, pim)
|
||||||
|
status, output =log_os_system(cmdm, 1)
|
||||||
|
cmdm = cmdl % (0x71, pim)
|
||||||
|
status, output =log_os_system(cmdm, 1)
|
||||||
|
|
||||||
|
for i in range(0, NO_QSFP):
|
||||||
|
bus = sfp_map(i)
|
||||||
|
status, output =log_os_system(
|
||||||
|
"echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(bus)+"/new_device", 1)
|
||||||
|
if status:
|
||||||
|
print output
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
status, output =log_os_system(
|
||||||
|
"echo port"+str(i+1)+" > /sys/bus/i2c/devices/"+str(bus)+"-0050/port_name", 1)
|
||||||
|
if status:
|
||||||
|
print output
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def device_uninstall():
|
||||||
|
for i in range(0,NO_QSFP):
|
||||||
|
bus = sfp_map(i)
|
||||||
|
target = "/sys/bus/i2c/devices/i2c-"+str(bus)+"/delete_device"
|
||||||
|
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||||
|
if status:
|
||||||
|
print output
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
|
||||||
|
# Multiplexer for 8 PIMs
|
||||||
|
cmdl = "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device"
|
||||||
|
for pim in range(2, 10):
|
||||||
|
cmdm = cmdl % (0x72, pim)
|
||||||
|
status, output =log_os_system(cmdm, 1)
|
||||||
|
cmdm = cmdl % (0x71, pim)
|
||||||
|
status, output =log_os_system(cmdm, 1)
|
||||||
|
|
||||||
|
nodelist = mknod
|
||||||
|
for i in range(len(nodelist)):
|
||||||
|
target = nodelist[-(i+1)]
|
||||||
|
temp = target.split()
|
||||||
|
del temp[1]
|
||||||
|
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||||
|
status, output = log_os_system(" ".join(temp), 1)
|
||||||
|
if status:
|
||||||
|
print output
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def system_ready():
|
||||||
|
if driver_inserted() == False:
|
||||||
|
return False
|
||||||
|
if not device_exist():
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def do_install():
|
||||||
|
print "Checking system...."
|
||||||
|
if driver_inserted() == False:
|
||||||
|
print "No driver, installing...."
|
||||||
|
status = driver_install()
|
||||||
|
if status:
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
else:
|
||||||
|
print PROJECT_NAME.upper()+" drivers detected...."
|
||||||
|
if not device_exist():
|
||||||
|
print "No device, installing...."
|
||||||
|
status = device_install()
|
||||||
|
if status:
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
else:
|
||||||
|
print PROJECT_NAME.upper()+" devices detected...."
|
||||||
|
return
|
||||||
|
|
||||||
|
def do_uninstall():
|
||||||
|
print "Checking system...."
|
||||||
|
if not device_exist():
|
||||||
|
print PROJECT_NAME.upper() +" has no device installed...."
|
||||||
|
else:
|
||||||
|
print "Removing device...."
|
||||||
|
status = device_uninstall()
|
||||||
|
if status:
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
|
||||||
|
if driver_inserted()== False :
|
||||||
|
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||||
|
else:
|
||||||
|
print "Removing installed driver...."
|
||||||
|
status = driver_uninstall()
|
||||||
|
if status:
|
||||||
|
if FORCE == 0:
|
||||||
|
return status
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def devices_info():
|
||||||
|
global DEVICE_NO
|
||||||
|
global ALL_DEVICE
|
||||||
|
global i2c_bus, hwmon_types
|
||||||
|
for key in DEVICE_NO:
|
||||||
|
ALL_DEVICE[key]= {}
|
||||||
|
for i in range(0,DEVICE_NO[key]):
|
||||||
|
ALL_DEVICE[key][key+str(i+1)] = []
|
||||||
|
|
||||||
|
for key in i2c_bus:
|
||||||
|
buses = i2c_bus[key]
|
||||||
|
nodes = i2c_nodes[key]
|
||||||
|
for i in range(0,len(buses)):
|
||||||
|
for j in range(0,len(nodes)):
|
||||||
|
if 'sfp' == key:
|
||||||
|
for k in range(0,DEVICE_NO[key]):
|
||||||
|
bus = 1
|
||||||
|
node = key+str(k+1)
|
||||||
|
path = i2c_prefix + str(bus) + lk + "/"+ nodes[j] + str(k+1)
|
||||||
|
my_log(node+": "+ path)
|
||||||
|
ALL_DEVICE[key][node].append(path)
|
||||||
|
else:
|
||||||
|
node = key+str(i+1)
|
||||||
|
path = i2c_prefix+ buses[i]+"/"+ nodes[j]
|
||||||
|
my_log(node+": "+ path)
|
||||||
|
ALL_DEVICE[key][node].append(path)
|
||||||
|
|
||||||
|
for key in hwmon_types:
|
||||||
|
itypes = hwmon_types[key]
|
||||||
|
nodes = hwmon_nodes[key]
|
||||||
|
for i in range(0,len(itypes)):
|
||||||
|
for j in range(0,len(nodes)):
|
||||||
|
node = key+"_"+itypes[i]
|
||||||
|
path = hwmon_prefix[key]+ itypes[i]+"/"+ nodes[j]
|
||||||
|
my_log(node+": "+ path)
|
||||||
|
ALL_DEVICE[key][ key+str(i+1)].append(path)
|
||||||
|
|
||||||
|
#show dict all in the order
|
||||||
|
if DEBUG == True:
|
||||||
|
for i in sorted(ALL_DEVICE.keys()):
|
||||||
|
print(i+": ")
|
||||||
|
for j in sorted(ALL_DEVICE[i].keys()):
|
||||||
|
print(" "+j)
|
||||||
|
for k in (ALL_DEVICE[i][j]):
|
||||||
|
print(" "+" "+k)
|
||||||
|
return
|
||||||
|
|
||||||
|
def show_eeprom(index):
|
||||||
|
if system_ready()==False:
|
||||||
|
print("System's not ready.")
|
||||||
|
print("Please install first!")
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(ALL_DEVICE)==0:
|
||||||
|
devices_info()
|
||||||
|
node = ALL_DEVICE['sfp'] ['sfp'+str(index)][0]
|
||||||
|
node = node.replace(node.split("/")[-1], 'eeprom')
|
||||||
|
# check if got hexdump command in current environment
|
||||||
|
ret, log = log_os_system("which hexdump", 0)
|
||||||
|
ret, log2 = log_os_system("which busybox hexdump", 0)
|
||||||
|
if len(log):
|
||||||
|
hex_cmd = 'hexdump'
|
||||||
|
elif len(log2):
|
||||||
|
hex_cmd = ' busybox hexdump'
|
||||||
|
else:
|
||||||
|
log = 'Failed : no hexdump cmd!!'
|
||||||
|
logging.info(log)
|
||||||
|
print log
|
||||||
|
return 1
|
||||||
|
|
||||||
|
print node + ":"
|
||||||
|
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||||
|
if ret==0:
|
||||||
|
print log
|
||||||
|
else:
|
||||||
|
print "**********device no found**********"
|
||||||
|
return
|
||||||
|
|
||||||
|
def set_device(args):
|
||||||
|
global DEVICE_NO
|
||||||
|
global ALL_DEVICE
|
||||||
|
if system_ready()==False:
|
||||||
|
print("System's not ready.")
|
||||||
|
print("Please install first!")
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(ALL_DEVICE)==0:
|
||||||
|
devices_info()
|
||||||
|
|
||||||
|
if args[0]=='led':
|
||||||
|
if int(args[1])>4:
|
||||||
|
show_set_help()
|
||||||
|
return
|
||||||
|
#print ALL_DEVICE['led']
|
||||||
|
for i in range(0,len(ALL_DEVICE['led'])):
|
||||||
|
for k in (ALL_DEVICE['led']['led'+str(i+1)]):
|
||||||
|
ret, log = log_os_system("echo "+args[1]+" >"+k, 1)
|
||||||
|
if ret:
|
||||||
|
return ret
|
||||||
|
elif args[0]=='sfp':
|
||||||
|
if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||||
|
show_set_help()
|
||||||
|
return
|
||||||
|
if len(args)<2:
|
||||||
|
show_set_help()
|
||||||
|
return
|
||||||
|
|
||||||
|
if int(args[2])>1:
|
||||||
|
show_set_help()
|
||||||
|
return
|
||||||
|
|
||||||
|
#print ALL_DEVICE[args[0]]
|
||||||
|
for i in range(0,len(ALL_DEVICE[args[0]])):
|
||||||
|
for j in ALL_DEVICE[args[0]][args[0]+str(args[1])]:
|
||||||
|
if j.find('tx_disable')!= -1:
|
||||||
|
ret, log = log_os_system("echo "+args[2]+" >"+ j, 1)
|
||||||
|
if ret:
|
||||||
|
return ret
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
#get digits inside a string.
|
||||||
|
#Ex: 31 for "sfp31"
|
||||||
|
def get_value(input):
|
||||||
|
digit = re.findall('\d+', input)
|
||||||
|
return int(digit[0])
|
||||||
|
|
||||||
|
def device_traversal():
|
||||||
|
if system_ready()==False:
|
||||||
|
print("System's not ready.")
|
||||||
|
print("Please install first!")
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(ALL_DEVICE)==0:
|
||||||
|
devices_info()
|
||||||
|
for i in sorted(ALL_DEVICE.keys()):
|
||||||
|
print("============================================")
|
||||||
|
print(i.upper()+": ")
|
||||||
|
print("============================================")
|
||||||
|
|
||||||
|
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||||
|
print " "+j+":",
|
||||||
|
for k in (ALL_DEVICE[i][j]):
|
||||||
|
ret, log = log_os_system("cat "+k, 0)
|
||||||
|
func = k.split("/")[-1].strip()
|
||||||
|
func = re.sub(j+'_','',func,1)
|
||||||
|
func = re.sub(i.lower()+'_','',func,1)
|
||||||
|
if ret==0:
|
||||||
|
print func+"="+log+" ",
|
||||||
|
else:
|
||||||
|
print func+"="+"X"+" ",
|
||||||
|
print
|
||||||
|
print("----------------------------------------------------------------")
|
||||||
|
|
||||||
|
|
||||||
|
print
|
||||||
|
return
|
||||||
|
|
||||||
|
def device_exist():
|
||||||
|
ret1, log = log_os_system("ls "+i2c_prefix+"*0070", 0)
|
||||||
|
ret2, log = log_os_system("ls "+i2c_prefix+"i2c-2", 0)
|
||||||
|
return not(ret1 or ret2)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user