[centec]update centec e582 platform drivers and libsai (#2043)
* update centec e582 platform drivers and libsai * delete minigraph.xml * remove minigraph * update psuutil.py comments * update device qos config file and clean minigraph
This commit is contained in:
parent
3b4d85239f
commit
0b3a885e39
@ -0,0 +1,70 @@
|
||||
{# Default values which will be used if no actual configura available #}
|
||||
{% set default_cable = '40m' %}
|
||||
{% set default_ports_num = 54 -%}
|
||||
|
||||
{# Port configuration to cable length look-up table #}
|
||||
{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #}
|
||||
{# Roles described in the minigraph #}
|
||||
{% set ports2cable = {
|
||||
'torrouter_server' : '5m',
|
||||
'leafrouter_torrouter' : '40m',
|
||||
'spinerouter_leafrouter' : '300m'
|
||||
}
|
||||
%}
|
||||
|
||||
{%- macro cable_length(port_name) -%}
|
||||
{%- set cable_len = [] -%}
|
||||
{%- for local_port in DEVICE_NEIGHBOR -%}
|
||||
{%- if local_port == port_name -%}
|
||||
{%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
|
||||
{%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
|
||||
{%- set neighbor_role = neighbor.type -%}
|
||||
{%- set roles1 = switch_role + '_' + neighbor_role %}
|
||||
{%- set roles2 = neighbor_role + '_' + switch_role -%}
|
||||
{%- set roles1 = roles1 | lower -%}
|
||||
{%- set roles2 = roles2 | lower -%}
|
||||
{%- if roles1 in ports2cable -%}
|
||||
{%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%}
|
||||
{%- elif roles2 in ports2cable -%}
|
||||
{%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- if cable_len -%}
|
||||
{{ cable_len.0 }}
|
||||
{%- else -%}
|
||||
{{ default_cable }}
|
||||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
|
||||
{%- if DEVICE_METADATA is defined %}
|
||||
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
|
||||
{%- endif -%}
|
||||
|
||||
{# Generate list of ports if not defined #}
|
||||
{% if PORT is not defined %}
|
||||
{% set PORT = [] %}
|
||||
{% for port_idx in range(1,default_ports_num+1) %}
|
||||
{% if PORT.append("Ethernet%d" % (port_idx)) %}{% endif %}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
|
||||
{% set port_names_list = [] %}
|
||||
{% for port in PORT %}
|
||||
{%- if port_names_list.append(port) %}{% endif %}
|
||||
{% endfor %}
|
||||
{% set port_names = port_names_list | join(',') -%}
|
||||
|
||||
{
|
||||
"CABLE_LENGTH": {
|
||||
"AZURE": {
|
||||
{% for port in PORT %}
|
||||
{% set cable = cable_length(port) -%}
|
||||
"{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
# PG lossless profiles.
|
||||
# speed cable size xon xoff threshold
|
||||
1000 5m 34816 18432 16384 0
|
||||
10000 5m 34816 18432 16384 0
|
||||
25000 5m 34816 18432 16384 0
|
||||
40000 5m 34816 18432 16384 0
|
||||
50000 5m 34816 18432 16384 0
|
||||
100000 5m 36864 18432 18432 0
|
||||
1000 40m 36864 18432 18432 0
|
||||
10000 40m 36864 18432 18432 0
|
||||
25000 40m 39936 18432 21504 0
|
||||
40000 40m 41984 18432 23552 0
|
||||
50000 40m 41984 18432 23552 0
|
||||
100000 40m 54272 18432 35840 0
|
||||
1000 300m 49152 18432 30720 0
|
||||
10000 300m 49152 18432 30720 0
|
||||
25000 300m 71680 18432 53248 0
|
||||
40000 300m 94208 18432 75776 0
|
||||
50000 300m 94208 18432 75776 0
|
||||
100000 300m 184320 18432 165888 0
|
||||
|
@ -0,0 +1,55 @@
|
||||
# name lanes alias speed
|
||||
Ethernet1 75 eth-0-1 1000
|
||||
Ethernet2 73 eth-0-2 1000
|
||||
Ethernet3 72 eth-0-3 1000
|
||||
Ethernet4 70 eth-0-4 1000
|
||||
Ethernet5 69 eth-0-5 1000
|
||||
Ethernet6 67 eth-0-6 1000
|
||||
Ethernet7 66 eth-0-7 1000
|
||||
Ethernet8 64 eth-0-8 1000
|
||||
Ethernet9 63 eth-0-9 1000
|
||||
Ethernet10 61 eth-0-10 1000
|
||||
Ethernet11 60 eth-0-11 1000
|
||||
Ethernet12 58 eth-0-12 1000
|
||||
Ethernet13 57 eth-0-13 10000
|
||||
Ethernet14 56 eth-0-14 10000
|
||||
Ethernet15 55 eth-0-15 10000
|
||||
Ethernet16 53 eth-0-16 10000
|
||||
Ethernet17 52 eth-0-17 10000
|
||||
Ethernet18 50 eth-0-18 10000
|
||||
Ethernet19 49 eth-0-19 10000
|
||||
Ethernet20 48 eth-0-20 10000
|
||||
Ethernet21 0 eth-0-21 10000
|
||||
Ethernet22 1 eth-0-22 10000
|
||||
Ethernet23 3 eth-0-23 10000
|
||||
Ethernet24 2 eth-0-24 10000
|
||||
Ethernet25 4 eth-0-25 10000
|
||||
Ethernet26 5 eth-0-26 10000
|
||||
Ethernet27 6 eth-0-27 10000
|
||||
Ethernet28 7 eth-0-28 10000
|
||||
Ethernet29 8 eth-0-29 10000
|
||||
Ethernet30 9 eth-0-30 10000
|
||||
Ethernet31 10 eth-0-31 10000
|
||||
Ethernet32 12 eth-0-32 10000
|
||||
Ethernet33 13 eth-0-33 10000
|
||||
Ethernet34 15 eth-0-34 10000
|
||||
Ethernet35 16 eth-0-35 10000
|
||||
Ethernet36 18 eth-0-36 10000
|
||||
Ethernet37 19 eth-0-37 10000
|
||||
Ethernet38 21 eth-0-38 10000
|
||||
Ethernet39 22 eth-0-39 10000
|
||||
Ethernet40 24 eth-0-40 10000
|
||||
Ethernet41 25 eth-0-41 10000
|
||||
Ethernet42 27 eth-0-42 10000
|
||||
Ethernet43 28 eth-0-43 10000
|
||||
Ethernet44 30 eth-0-44 10000
|
||||
Ethernet45 31 eth-0-45 10000
|
||||
Ethernet46 33 eth-0-46 10000
|
||||
Ethernet47 34 eth-0-47 10000
|
||||
Ethernet48 36 eth-0-48 10000
|
||||
Ethernet49 42,41,43,40 eth-0-49 40000
|
||||
Ethernet50 45,46,44,47 eth-0-50 40000
|
||||
Ethernet51 94,93,95,92 eth-0-51 100000
|
||||
Ethernet52 89,90,88,91 eth-0-52 100000
|
||||
Ethernet53 85,86,84,87 eth-0-53 100000
|
||||
Ethernet54 81,82,80,83 eth-0-54 100000
|
@ -0,0 +1 @@
|
||||
{%- include 'qos_config.j2' %}
|
@ -0,0 +1,2 @@
|
||||
SAI_INIT_CONFIG_FILE=/etc/centec/E582-48x2q4z-chip-profile.txt
|
||||
SAI_HW_PORT_PROFILE_ID_CONFIG_FILE=/etc/centec/E582-48x2q4z-datapath-cfg.txt
|
1
device/centec/x86_64-centec_e582_48x2q4z-r0/default_sku
Normal file
1
device/centec/x86_64-centec_e582_48x2q4z-r0/default_sku
Normal file
@ -0,0 +1 @@
|
||||
E582-48x2q4z t1
|
10
device/centec/x86_64-centec_e582_48x2q4z-r0/fancontrol
Normal file
10
device/centec/x86_64-centec_e582_48x2q4z-r0/fancontrol
Normal file
@ -0,0 +1,10 @@
|
||||
# Configuration file generated by pwmconfig, changes will be lost
|
||||
INTERVAL=10
|
||||
DEVPATH=hwmon1=devices/platform/coretemp.0 hwmon5=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-15/15-002f
|
||||
DEVNAME=hwmon1=coretemp hwmon5=adt7470
|
||||
FCTEMPS=hwmon5/pwm4=hwmon1/temp1_input hwmon5/pwm3=hwmon1/temp1_input hwmon5/pwm2=hwmon1/temp1_input hwmon5/pwm1=hwmon1/temp1_input
|
||||
FCFANS=hwmon5/pwm4=hwmon5/fan4_input hwmon5/pwm3=hwmon5/fan3_input hwmon5/pwm2=hwmon5/fan2_input hwmon5/pwm1=hwmon5/fan1_input
|
||||
MINTEMP=hwmon5/pwm4=20 hwmon5/pwm3=20 hwmon5/pwm2=20 hwmon5/pwm1=20
|
||||
MAXTEMP=hwmon5/pwm4=60 hwmon5/pwm3=60 hwmon5/pwm2=60 hwmon5/pwm1=60
|
||||
MINSTART=hwmon5/pwm4=150 hwmon5/pwm3=150 hwmon5/pwm2=150 hwmon5/pwm1=150
|
||||
MINSTOP=hwmon5/pwm4=0 hwmon5/pwm3=0 hwmon5/pwm2=0 hwmon5/pwm1=100
|
@ -0,0 +1,2 @@
|
||||
CONSOLE_SPEED=115200
|
||||
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="acpi_enforce_resources=no"
|
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Centec E582-48X6Q
|
||||
#
|
||||
# Platform and model specific eeprom subclass, inherits from the base class,
|
||||
# and provides the followings:
|
||||
# - the eeprom format definition
|
||||
# - specific encoder/decoder if there is special need
|
||||
#############################################################################
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
import warnings
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/class/i2c-adapter/i2c-0/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
@ -0,0 +1,153 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# led_control.py
|
||||
#
|
||||
# Platform-specific LED control functionality for SONiC
|
||||
#
|
||||
|
||||
try:
|
||||
from sonic_led.led_control_base import LedControlBase
|
||||
import swsssdk
|
||||
import threading
|
||||
import os
|
||||
import logging
|
||||
import struct
|
||||
import time
|
||||
import syslog
|
||||
from socket import *
|
||||
from select import *
|
||||
except ImportError, e:
|
||||
raise ImportError(str(e) + " - required module not found")
|
||||
|
||||
|
||||
def DBG_PRINT(str):
|
||||
syslog.openlog("centec-led")
|
||||
syslog.syslog(syslog.LOG_INFO, str)
|
||||
syslog.closelog()
|
||||
|
||||
class LedControl(LedControlBase):
|
||||
"""Platform specific LED control class"""
|
||||
SONIC_PORT_NAME_PREFIX = "Ethernet"
|
||||
LED_MODE_UP = [11, 1]
|
||||
LED_MODE_DOWN = [7, 2]
|
||||
|
||||
def _initSystemLed(self):
|
||||
try:
|
||||
with open(self.f_led.format("system"), 'w') as led_file:
|
||||
led_file.write("5")
|
||||
DBG_PRINT("init system led to normal")
|
||||
with open(self.f_led.format("idn"), 'w') as led_file:
|
||||
led_file.write("1")
|
||||
DBG_PRINT("init idn led to off")
|
||||
except IOError as e:
|
||||
DBG_PRINT(str(e))
|
||||
|
||||
def _initPanelLed(self):
|
||||
with open(self.f_led.format("port1"), 'r') as led_file:
|
||||
shouldInit = (int(led_file.read()) == 0)
|
||||
|
||||
if shouldInit == True:
|
||||
for (port, ctlid, defmode) in self.led_mapping[1:59]:
|
||||
data = struct.pack('=HHHBBH', 0, 7, 4, ctlid, defmode, port)
|
||||
self.udpClient.sendto(data, ('localhost', 8101))
|
||||
|
||||
data = struct.pack('=HHHBB30B', 0, 3, 32, 30, 0, *[x[0] for x in self.led_mapping[21:51]])
|
||||
self.udpClient.sendto(data, ('localhost', 8101))
|
||||
data = struct.pack('=HHHBB28B', 0, 3, 30, 28, 1, *[x[0] for x in (self.led_mapping[1:21]+self.led_mapping[51:59])])
|
||||
self.udpClient.sendto(data, ('localhost', 8101))
|
||||
|
||||
data = struct.pack('=HHHB', 0, 5, 1, 1)
|
||||
self.udpClient.sendto(data, ('localhost', 8101))
|
||||
|
||||
for idx in range(1, 55):
|
||||
(port, ctlid, defmode) = self.led_mapping[idx]
|
||||
with open(self.f_led.format("port{}".format(idx)), 'w') as led_file:
|
||||
led_file.write(str(defmode))
|
||||
DBG_PRINT("init port{} led to mode={}".format(idx, defmode))
|
||||
|
||||
for idx in range(1, 55):
|
||||
(port, ctlid, defmode) = self.led_mapping[idx]
|
||||
with open(self.f_led.format("port{}".format(idx)), 'r') as led_file:
|
||||
defmode = int(led_file.read())
|
||||
data = struct.pack('=HHHBBH', 0, 7, 4, ctlid, defmode, port)
|
||||
self.udpClient.sendto(data, ('localhost', 8101))
|
||||
DBG_PRINT("init port{} led to mode={}".format(idx, defmode))
|
||||
|
||||
def _initDefaultConfig(self):
|
||||
DBG_PRINT("start init led")
|
||||
while True:
|
||||
try:
|
||||
r_sel = [self.udpClient]
|
||||
echo_req = struct.pack('=HHH', 0, 1, 0)
|
||||
self.udpClient.sendto(echo_req, ('localhost', 8101))
|
||||
result = select(r_sel, [], [], 1)
|
||||
if self.udpClient in result[0]:
|
||||
echo_rsp, srv_addr = self.udpClient.recvfrom(1024)
|
||||
if echo_rsp:
|
||||
break
|
||||
DBG_PRINT("connect to sdk rpc server timeout, try again.")
|
||||
except IOError as e:
|
||||
DBG_PRINT(str(e))
|
||||
|
||||
DBG_PRINT("connect to sdk rpc server success.")
|
||||
|
||||
self._initSystemLed()
|
||||
self._initPanelLed()
|
||||
|
||||
DBG_PRINT("init led done")
|
||||
|
||||
|
||||
# Helper method to map SONiC port name to index
|
||||
def _port_name_to_index(self, port_name):
|
||||
# Strip "Ethernet" off port name
|
||||
if not port_name.startswith(self.SONIC_PORT_NAME_PREFIX):
|
||||
return -1
|
||||
|
||||
port_idx = int(port_name[len(self.SONIC_PORT_NAME_PREFIX):])
|
||||
return port_idx
|
||||
|
||||
def _port_state_to_mode(self, port_idx, state):
|
||||
if state == "up":
|
||||
return self.LED_MODE_UP[0] if (port_idx < 49) else self.LED_MODE_UP[1]
|
||||
else:
|
||||
return self.LED_MODE_DOWN[0] if (port_idx < 49) else self.LED_MODE_DOWN[1]
|
||||
|
||||
def _port_led_mode_update(self, port_idx, ledMode):
|
||||
with open(self.f_led.format("port{}".format(port_idx)), 'w') as led_file:
|
||||
led_file.write(str(ledMode))
|
||||
(port, ctlid) = (self.led_mapping[port_idx][0], self.led_mapping[port_idx][1])
|
||||
data = struct.pack('=HHHBBH', 0, 7, 4, ctlid, ledMode, port)
|
||||
self.udpClient.sendto(data, ('localhost', 8101))
|
||||
|
||||
# Concrete implementation of port_link_state_change() method
|
||||
def port_link_state_change(self, portname, state):
|
||||
port_idx = self._port_name_to_index(portname)
|
||||
ledMode = self._port_state_to_mode(port_idx, state)
|
||||
with open(self.f_led.format("port{}".format(port_idx)), 'r') as led_file:
|
||||
saveMode = int(led_file.read())
|
||||
|
||||
if ledMode == saveMode:
|
||||
return
|
||||
|
||||
self._port_led_mode_update(port_idx, ledMode)
|
||||
DBG_PRINT("update {} led mode from {} to {}".format(portname, saveMode, ledMode))
|
||||
|
||||
# Constructor
|
||||
def __init__(self):
|
||||
# [macid, ctlid, defaultmode]
|
||||
self.led_mapping = [(0, 0, 0)] # resv
|
||||
self.led_mapping.extend([(27, 1, 7), (25, 1, 7), (24, 1, 7), (22, 1, 7), (21, 1, 7), (19, 1, 7), (18, 1, 7), (16, 1, 7)]) # panel port 1~8
|
||||
self.led_mapping.extend([(15, 1, 7), (13, 1, 7), (12, 1, 7), (10, 1, 7), (9, 1, 7), (8, 1, 7), (7, 1, 7), (5, 1, 7)]) # panel port 9~16
|
||||
self.led_mapping.extend([(4, 1, 7), (2, 1, 7), (1, 1, 7), (0, 1, 7), (0, 0, 7), (1, 0, 7), (3, 0, 7), (2, 0, 7)]) # panel port 17~24
|
||||
self.led_mapping.extend([(4, 0, 7), (5, 0, 7), (6, 0, 7), (7, 0, 7), (8, 0, 7), (9, 0, 7), (10, 0, 7), (12, 0, 7)]) # panel port 25~32
|
||||
self.led_mapping.extend([(13, 0, 7), (15, 0, 7), (16, 0, 7), (18, 0, 7), (19, 0, 7), (21, 0, 7), (22, 0, 7), (24, 0, 7)]) # panel port 33~40
|
||||
self.led_mapping.extend([(25, 0, 7), (27, 0, 7), (28, 0, 7), (30, 0, 7), (31, 0, 7), (33, 0, 7), (34, 0, 7), (48, 0, 7)]) # panel port 41~48
|
||||
self.led_mapping.extend([(36, 0, 2), (52, 0, 2), (52, 1, 2), (36, 1, 2), (48, 1, 2), (32, 1, 2)]) # panel port 49~54
|
||||
self.led_mapping.extend([(11, 1, 2), (11, 1, 2), (11, 1, 2), (11, 1, 2), (11, 1, 2), (11, 1, 2)])
|
||||
|
||||
self.f_led = "/sys/class/leds/{}/brightness"
|
||||
|
||||
self.udpClient = socket(AF_INET, SOCK_DGRAM)
|
||||
|
||||
self._initDefaultConfig()
|
||||
|
@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Centec
|
||||
#
|
||||
# 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.psu_path = "/sys/class/psu/psu{}/"
|
||||
self.psu_presence = "psu_presence"
|
||||
self.psu_oper_status = "psu_status"
|
||||
|
||||
def get_num_psus(self):
|
||||
"""
|
||||
Retrieves the number of PSUs available on the device
|
||||
|
||||
:return: An integer, the number of PSUs available on the device
|
||||
"""
|
||||
return 2
|
||||
|
||||
def get_psu_status(self, index):
|
||||
"""
|
||||
Retrieves the oprational status of power supply unit (PSU) defined
|
||||
by 1-based index <index>
|
||||
|
||||
:param index: An integer, 1-based index of the PSU of which to query status
|
||||
:return: Boolean, True if PSU is operating properly, False if PSU is faulty
|
||||
"""
|
||||
if index is None:
|
||||
return False
|
||||
|
||||
status = 0
|
||||
try:
|
||||
with open(self.psu_path.format(index) + self.psu_oper_status, 'r') as power_status:
|
||||
status = int(power_status.read())
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
return status == 0
|
||||
|
||||
def get_psu_presence(self, index):
|
||||
"""
|
||||
Retrieves the presence status of power supply unit (PSU) defined
|
||||
by 1-based index <index>
|
||||
|
||||
:param index: An integer, 1-based index of the PSU of which to query status
|
||||
:return: Boolean, True if PSU is plugged, False if not
|
||||
"""
|
||||
if index is None:
|
||||
return False
|
||||
|
||||
status = 0
|
||||
try:
|
||||
with open(self.psu_path.format(index) + self.psu_presence, 'r') as presence_status:
|
||||
status = int(presence_status.read())
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
return status == 0
|
162
device/centec/x86_64-centec_e582_48x2q4z-r0/plugins/sfputil.py
Normal file
162
device/centec/x86_64-centec_e582_48x2q4z-r0/plugins/sfputil.py
Normal file
@ -0,0 +1,162 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# sfputil.py
|
||||
#
|
||||
# Platform-specific SFP transceiver interface for SONiC
|
||||
#
|
||||
|
||||
try:
|
||||
import time
|
||||
import os
|
||||
import logging
|
||||
import struct
|
||||
import syslog
|
||||
from socket import *
|
||||
from select import *
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
|
||||
|
||||
def DBG_PRINT(str):
|
||||
print str + "\n"
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
SONIC_PORT_NAME_PREFIX = "Ethernet"
|
||||
PORT_START = 1
|
||||
PORT_END = 54
|
||||
PORTS_IN_BLOCK = 54
|
||||
|
||||
@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(49, self.PORTS_IN_BLOCK + 1)
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
return self.eeprom_mapping
|
||||
|
||||
def is_logical_port(self, port_name):
|
||||
return True
|
||||
|
||||
def get_logical_to_physical(self, port_name):
|
||||
if not port_name.startswith(self.SONIC_PORT_NAME_PREFIX):
|
||||
return None
|
||||
|
||||
port_idx = int(port_name[len(self.SONIC_PORT_NAME_PREFIX):])
|
||||
|
||||
return [port_idx]
|
||||
|
||||
def get_eeprom_data(self, port):
|
||||
(ctlid, devid) = self.fiber_mapping[port]
|
||||
offset = (128 if port in self.qsfp_ports else 0)
|
||||
r_sel = [self.udpClient]
|
||||
req = struct.pack('=HHHBBHIBBBBI',
|
||||
0, 9, 16, # lchip/msgtype/msglen
|
||||
ctlid, # uint8 ctl_id
|
||||
devid, # uint8 slave_dev_id
|
||||
0x50, # uint16 dev_addr
|
||||
(1<<devid), # uint32 slave_bitmap
|
||||
offset, # uint8 offset
|
||||
95, # uint8 length
|
||||
0xf, # uint8 i2c_switch_id
|
||||
0, # uint8 access_switch
|
||||
95 # uint32 buf_length
|
||||
)
|
||||
self.udpClient.sendto(req, ('localhost', 8101))
|
||||
result = select(r_sel, [], [], 1)
|
||||
if self.udpClient in result[0]:
|
||||
rsp, addr = self.udpClient.recvfrom(1024)
|
||||
if rsp:
|
||||
rsp_data = struct.unpack('=HHHBBHIBBBBIi512B', rsp)
|
||||
if rsp_data[12] != 0:
|
||||
return None
|
||||
if port in self.qsfp_ports:
|
||||
return buffer(bytearray([0]*128), 0, 128) + buffer(rsp, 26, 512)
|
||||
return buffer(rsp, 26, 512)
|
||||
return None
|
||||
|
||||
def __init__(self):
|
||||
"""[ctlid, slavedevid]"""
|
||||
self.fiber_mapping = [(0, 0)] # res
|
||||
self.fiber_mapping.extend([(1, 7), (1, 6), (1, 5), (1, 4), (1, 3), (1, 2), (1, 1), (1, 0)]) # panel port 1~8
|
||||
self.fiber_mapping.extend([(1, 15), (1, 14), (1, 13), (1, 12), (1, 11), (1, 10), (1, 9), (1, 8)]) # panel port 9~16
|
||||
self.fiber_mapping.extend([(1, 19), (1, 17), (1, 16), (1, 18), (0, 7), (0, 6), (0, 5), (0, 4)]) # panel port 17~24
|
||||
self.fiber_mapping.extend([(0, 3), (0, 2), (0, 1), (0, 0), (0, 15), (0, 14), (0, 13), (0, 12)]) # panel port 25~32
|
||||
self.fiber_mapping.extend([(0, 11), (0, 10), (0, 9), (0, 8), (0, 23), (0, 22), (0, 21), (0, 20)]) # panel port 33~40
|
||||
self.fiber_mapping.extend([(0, 19), (0, 18), (0, 17), (0, 16), (0, 31), (0, 26), (0, 29), (0, 27)]) # panel port 41~48
|
||||
self.fiber_mapping.extend([(0, 24), (0, 25), (1, 23), (1, 22), (1, 21), (1, 20)]) # panel port 49~54
|
||||
|
||||
self.udpClient = socket(AF_INET, SOCK_DGRAM)
|
||||
self.eeprom_mapping = {}
|
||||
self.f_sfp_present = "/sys/class/sfp/sfp{}/sfp_presence"
|
||||
self.f_sfp_enable = "/sys/class/sfp/sfp{}/sfp_enable"
|
||||
|
||||
for x in range(1, self.port_end + 1):
|
||||
self.eeprom_mapping[x] = "/var/cache/sonic/sfp/sfp{}_eeprom".format(x)
|
||||
|
||||
try:
|
||||
if not os.path.exists("/var/cache/sonic/sfp"):
|
||||
os.makedirs("/var/cache/sonic/sfp", 0777)
|
||||
for x in range(1, self.port_end + 1):
|
||||
if not self.get_presence(x):
|
||||
if os.path.exists(self.eeprom_mapping[x]):
|
||||
os.remove(self.eeprom_mapping[x])
|
||||
continue
|
||||
data = self.get_eeprom_data(x)
|
||||
if data:
|
||||
with open(self.eeprom_mapping[x], 'w') as sfp_eeprom:
|
||||
sfp_eeprom.write(data)
|
||||
else:
|
||||
DBG_PRINT("get sfp{} eeprom data failed.".format(x))
|
||||
break
|
||||
except IOError as e:
|
||||
DBG_PRINT(str(e))
|
||||
|
||||
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
|
||||
try:
|
||||
with open(self.f_sfp_present.format(port_num), 'r') as sfp_file:
|
||||
return 1 == int(sfp_file.read())
|
||||
except IOError as e:
|
||||
DBG_PRINT(str(e))
|
||||
|
||||
return False
|
||||
|
||||
def get_low_power_mode(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
def set_low_power_mode(self, port_num, lpmode):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
def reset(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
def get_transceiver_change_event(self, timeout=0):
|
||||
return False, {}
|
@ -1,55 +1,55 @@
|
||||
# name lanes
|
||||
Ethernet1 4
|
||||
Ethernet2 5
|
||||
Ethernet3 6
|
||||
Ethernet4 8
|
||||
Ethernet5 9
|
||||
Ethernet6 10
|
||||
Ethernet7 12
|
||||
Ethernet8 13
|
||||
Ethernet9 14
|
||||
Ethernet10 16
|
||||
Ethernet11 17
|
||||
Ethernet12 18
|
||||
Ethernet13 20
|
||||
Ethernet14 21
|
||||
Ethernet15 22
|
||||
Ethernet16 24
|
||||
Ethernet17 25
|
||||
Ethernet18 26
|
||||
Ethernet19 28
|
||||
Ethernet20 30
|
||||
Ethernet21 31
|
||||
Ethernet22 32
|
||||
Ethernet23 34
|
||||
Ethernet24 35
|
||||
Ethernet25 40
|
||||
Ethernet26 41
|
||||
Ethernet27 43
|
||||
Ethernet28 36
|
||||
Ethernet29 37
|
||||
Ethernet30 39
|
||||
Ethernet31 44
|
||||
Ethernet32 45
|
||||
Ethernet33 46
|
||||
Ethernet34 47
|
||||
Ethernet35 80
|
||||
Ethernet36 81
|
||||
Ethernet37 82
|
||||
Ethernet38 88
|
||||
Ethernet39 89
|
||||
Ethernet40 90
|
||||
Ethernet41 84
|
||||
Ethernet42 85
|
||||
Ethernet43 86
|
||||
Ethernet44 87
|
||||
Ethernet45 92
|
||||
Ethernet46 93
|
||||
Ethernet47 94
|
||||
Ethernet48 95
|
||||
Ethernet49 52,53,54,55
|
||||
Ethernet50 56,57,58,59
|
||||
Ethernet51 60,61,62,63
|
||||
Ethernet52 68,69,70,71
|
||||
Ethernet53 72,73,74,75
|
||||
Ethernet54 76,77,78,79
|
||||
# name lanes alias speed
|
||||
Ethernet1 4 eth-0-1 1000
|
||||
Ethernet2 5 eth-0-2 1000
|
||||
Ethernet3 6 eth-0-3 1000
|
||||
Ethernet4 8 eth-0-4 1000
|
||||
Ethernet5 9 eth-0-5 1000
|
||||
Ethernet6 10 eth-0-6 1000
|
||||
Ethernet7 12 eth-0-7 1000
|
||||
Ethernet8 13 eth-0-8 1000
|
||||
Ethernet9 14 eth-0-9 1000
|
||||
Ethernet10 16 eth-0-10 1000
|
||||
Ethernet11 17 eth-0-11 1000
|
||||
Ethernet12 18 eth-0-12 1000
|
||||
Ethernet13 20 eth-0-13 10000
|
||||
Ethernet14 21 eth-0-14 10000
|
||||
Ethernet15 22 eth-0-15 10000
|
||||
Ethernet16 24 eth-0-16 10000
|
||||
Ethernet17 25 eth-0-17 10000
|
||||
Ethernet18 26 eth-0-18 10000
|
||||
Ethernet19 28 eth-0-19 10000
|
||||
Ethernet20 30 eth-0-20 10000
|
||||
Ethernet21 31 eth-0-21 10000
|
||||
Ethernet22 32 eth-0-22 10000
|
||||
Ethernet23 34 eth-0-23 10000
|
||||
Ethernet24 35 eth-0-24 10000
|
||||
Ethernet25 36 eth-0-25 10000
|
||||
Ethernet26 37 eth-0-26 10000
|
||||
Ethernet27 39 eth-0-27 10000
|
||||
Ethernet28 40 eth-0-28 10000
|
||||
Ethernet29 41 eth-0-29 10000
|
||||
Ethernet30 43 eth-0-30 10000
|
||||
Ethernet31 47 eth-0-31 10000
|
||||
Ethernet32 46 eth-0-32 10000
|
||||
Ethernet33 45 eth-0-33 10000
|
||||
Ethernet34 44 eth-0-34 10000
|
||||
Ethernet35 92 eth-0-35 10000
|
||||
Ethernet36 93 eth-0-36 10000
|
||||
Ethernet37 94 eth-0-37 10000
|
||||
Ethernet38 95 eth-0-38 10000
|
||||
Ethernet39 90 eth-0-39 10000
|
||||
Ethernet40 89 eth-0-40 10000
|
||||
Ethernet41 88 eth-0-41 10000
|
||||
Ethernet42 87 eth-0-42 10000
|
||||
Ethernet43 86 eth-0-43 10000
|
||||
Ethernet44 85 eth-0-44 10000
|
||||
Ethernet45 84 eth-0-45 10000
|
||||
Ethernet46 82 eth-0-46 10000
|
||||
Ethernet47 81 eth-0-47 10000
|
||||
Ethernet48 80 eth-0-48 10000
|
||||
Ethernet49 77,78,76,79 eth-0-49 40000
|
||||
Ethernet50 73,74,72,75 eth-0-50 40000
|
||||
Ethernet51 70,71,69,68 eth-0-51 40000
|
||||
Ethernet52 61,63,60,62 eth-0-52 40000
|
||||
Ethernet53 59,57,58,56 eth-0-53 40000
|
||||
Ethernet54 53,55,54,52 eth-0-54 40000
|
||||
|
@ -1,133 +0,0 @@
|
||||
{
|
||||
"DSCP_TO_TC_MAP": {
|
||||
"AZURE": {
|
||||
"0":"0",
|
||||
"1":"0",
|
||||
"2":"0",
|
||||
"3":"0",
|
||||
"4":"0",
|
||||
"5":"0",
|
||||
"6":"0",
|
||||
"7":"0",
|
||||
"8":"1",
|
||||
"9":"1",
|
||||
"10":"1",
|
||||
"11":"1",
|
||||
"12":"1",
|
||||
"13":"1",
|
||||
"14":"1",
|
||||
"15":"1",
|
||||
"16":"2",
|
||||
"17":"2",
|
||||
"18":"2",
|
||||
"19":"2",
|
||||
"20":"2",
|
||||
"21":"2",
|
||||
"22":"2",
|
||||
"23":"2",
|
||||
"24":"3",
|
||||
"25":"3",
|
||||
"26":"3",
|
||||
"27":"3",
|
||||
"28":"3",
|
||||
"29":"3",
|
||||
"30":"3",
|
||||
"31":"3",
|
||||
"32":"4",
|
||||
"33":"4",
|
||||
"34":"4",
|
||||
"35":"4",
|
||||
"36":"4",
|
||||
"37":"4",
|
||||
"38":"4",
|
||||
"39":"4",
|
||||
"40":"5",
|
||||
"41":"5",
|
||||
"42":"5",
|
||||
"43":"5",
|
||||
"44":"5",
|
||||
"45":"5",
|
||||
"46":"5",
|
||||
"47":"5",
|
||||
"48":"6",
|
||||
"49":"6",
|
||||
"50":"6",
|
||||
"51":"6",
|
||||
"52":"6",
|
||||
"53":"6",
|
||||
"54":"6",
|
||||
"55":"6",
|
||||
"56":"7",
|
||||
"57":"7",
|
||||
"58":"7",
|
||||
"59":"7",
|
||||
"60":"7",
|
||||
"61":"7",
|
||||
"62":"7",
|
||||
"63":"7"
|
||||
}
|
||||
},
|
||||
"SCHEDULER": {
|
||||
"scheduler.0": {
|
||||
"type":"DWRR",
|
||||
"weight": "25"
|
||||
},
|
||||
"scheduler.1": {
|
||||
"type":"DWRR",
|
||||
"weight": "30"
|
||||
},
|
||||
"scheduler.2": {
|
||||
"type":"DWRR",
|
||||
"weight": "20"
|
||||
}
|
||||
},
|
||||
"PORT_QOS_MAP": {
|
||||
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54": {
|
||||
"dscp_to_tc_map" : "[DSCP_TO_TC_MAP|AZURE]",
|
||||
"pfc_enable": "3,4"
|
||||
}
|
||||
},
|
||||
"WRED_PROFILE": {
|
||||
"AZURE_LOSSY": {
|
||||
"wred_green_enable":"true",
|
||||
"wred_yellow_enable":"true",
|
||||
"red_max_threshold":"32760",
|
||||
"red_min_threshold":"4095",
|
||||
"yellow_max_threshold":"32760",
|
||||
"yellow_min_threshold":"4095",
|
||||
"green_max_threshold": "32760",
|
||||
"green_min_threshold": "4095"
|
||||
},
|
||||
"AZURE_LOSSLESS": {
|
||||
"wred_green_enable":"true",
|
||||
"wred_yellow_enable":"true",
|
||||
"red_max_threshold":"32760",
|
||||
"red_min_threshold":"4095",
|
||||
"yellow_max_threshold":"32760",
|
||||
"yellow_min_threshold":"4095",
|
||||
"green_max_threshold": "32760",
|
||||
"green_min_threshold": "4095"
|
||||
}
|
||||
},
|
||||
"QUEUE": {
|
||||
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|0-2": {
|
||||
"scheduler" : "[SCHEDULER|scheduler.1]"
|
||||
},
|
||||
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|5-7": {
|
||||
"scheduler" : "[SCHEDULER|scheduler.2]"
|
||||
},
|
||||
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|0-2": {
|
||||
"wred_profile" : "[WRED_PROFILE|AZURE_LOSSY]"
|
||||
},
|
||||
|
||||
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|5-7": {
|
||||
"wred_profile" : "[WRED_PROFILE|AZURE_LOSSY]"
|
||||
},
|
||||
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|3-4": {
|
||||
"scheduler" : "[SCHEDULER|scheduler.0]",
|
||||
"wred_profile" : "[WRED_PROFILE|AZURE_LOSSLESS]"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
{%- include 'qos_config.j2' %}
|
@ -1,3 +1,2 @@
|
||||
BOARD_CONFIG_FILE_PATH=/etc/centec/E582-48x6q.json
|
||||
SAI_INIT_CONFIG_FILE=/etc/centec/E582-48x6q-chip-profile.txt
|
||||
SAI_HW_PORT_PROFILE_ID_CONFIG_FILE=/etc/centec/E582-48x6q-datapath-cfg.txt
|
||||
|
@ -1,11 +1,10 @@
|
||||
# Configuration file generated by pwmconfig, changes will be lost
|
||||
INTERVAL=10
|
||||
DEVPATH=hwmon0= hwmon5=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-15/15-002f
|
||||
DEVNAME=hwmon0=acpitz hwmon5=adt7470
|
||||
FCTEMPS=hwmon5/device/pwm4=hwmon0/temp1_input hwmon5/device/pwm3=hwmon0/temp1_input hwmon5/device/pwm2=hwmon0/temp1_input hwmon5/device/pwm1=hwmon0/temp1_input
|
||||
FCFANS=hwmon5/device/pwm4=hwmon5/device/fan4_input hwmon5/device/pwm3=hwmon5/device/fan3_input hwmon5/device/pwm2=hwmon5/device/fan2_input hwmon5/device/pwm1=hwmon5/device/fan1_input
|
||||
MINTEMP=hwmon5/device/pwm4=20 hwmon5/device/pwm3=20 hwmon5/device/pwm2=20 hwmon5/device/pwm1=20
|
||||
MAXTEMP=hwmon5/device/pwm4=60 hwmon5/device/pwm3=60 hwmon5/device/pwm2=60 hwmon5/device/pwm1=60
|
||||
MINSTART=hwmon5/device/pwm4=150 hwmon5/device/pwm3=12 hwmon5/device/pwm2=12 hwmon5/device/pwm1=150
|
||||
MINSTOP=hwmon5/device/pwm4=0 hwmon5/device/pwm3=12 hwmon5/device/pwm2=12 hwmon5/device/pwm1=0
|
||||
MAXPWM= hwmon5/device/pwm4=150
|
||||
DEVPATH=hwmon1=devices/platform/coretemp.0 hwmon5=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-15/15-002f
|
||||
DEVNAME=hwmon1=coretemp hwmon5=adt7470
|
||||
FCTEMPS=hwmon5/pwm4=hwmon1/temp1_input hwmon5/pwm3=hwmon1/temp1_input hwmon5/pwm2=hwmon1/temp1_input hwmon5/pwm1=hwmon1/temp1_input
|
||||
FCFANS=hwmon5/pwm4=hwmon5/fan4_input hwmon5/pwm3=hwmon5/fan3_input hwmon5/pwm2=hwmon5/fan2_input hwmon5/pwm1=hwmon5/fan1_input
|
||||
MINTEMP=hwmon5/pwm4=20 hwmon5/pwm3=20 hwmon5/pwm2=20 hwmon5/pwm1=20
|
||||
MAXTEMP=hwmon5/pwm4=60 hwmon5/pwm3=60 hwmon5/pwm2=60 hwmon5/pwm1=60
|
||||
MINSTART=hwmon5/pwm4=150 hwmon5/pwm3=150 hwmon5/pwm2=150 hwmon5/pwm1=150
|
||||
MINSTOP=hwmon5/pwm4=0 hwmon5/pwm3=0 hwmon5/pwm2=0 hwmon5/pwm1=100
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Mellanox
|
||||
# Centec
|
||||
#
|
||||
# Module contains an implementation of SONiC PSU Base API and
|
||||
# provides the PSUs status which are available in the platform
|
||||
|
@ -158,11 +158,5 @@ class SfpUtil(SfpUtilBase):
|
||||
|
||||
return False
|
||||
|
||||
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
|
||||
|
||||
def get_transceiver_change_event(self, timeout=0):
|
||||
return False, {}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# libsaithrift-dev package
|
||||
|
||||
LIBSAITHRIFT_DEV_CENTEC = libsaithrift-dev_1.2.1_amd64.deb
|
||||
LIBSAITHRIFT_DEV_CENTEC = libsaithrift-dev_1.3.5_amd64.deb
|
||||
$(LIBSAITHRIFT_DEV_CENTEC)_SRC_PATH = $(SRC_PATH)/sonic-sairedis/SAI
|
||||
$(LIBSAITHRIFT_DEV_CENTEC)_DEPENDS += $(LIBTHRIFT) $(LIBTHRIFT_DEV) $(THRIFT_COMPILER) $(CENTEC_SAI)
|
||||
$(LIBSAITHRIFT_DEV_CENTEC)_RDEPENDS += $(LIBTHRIFT) $(CENTEC_SAI)
|
||||
|
@ -3,6 +3,7 @@
|
||||
SONIC_ONE_IMAGE = sonic-centec.bin
|
||||
$(SONIC_ONE_IMAGE)_MACHINE = centec
|
||||
$(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie
|
||||
$(SONIC_ONE_IMAGE)_INSTALLS += $(CENTEC_E582_48X6Q_PLATFORM_MODULE)
|
||||
$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CENTEC_E582_48X6Q_PLATFORM_MODULE) \
|
||||
$(CENTEC_E582_48X2Q4Z_PLATFORM_MODULE)
|
||||
$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES)
|
||||
SONIC_INSTALLERS += $(SONIC_ONE_IMAGE)
|
||||
|
@ -12,6 +12,7 @@ CENTEC_E582_48X6Q_PLATFORM_MODULE = platform-modules-e582-48x6q_$(CENTEC_E582_48
|
||||
$(CENTEC_E582_48X6Q_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-e582
|
||||
$(CENTEC_E582_48X6Q_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
|
||||
$(CENTEC_E582_48X6Q_PLATFORM_MODULE)_PLATFORM = x86_64-centec_e582_48x6q-r0
|
||||
SONIC_STRETCH_DEBS += $(CENTEC_E582_48X6Q_PLATFORM_MODULE)
|
||||
SONIC_DPKG_DEBS += $(CENTEC_E582_48X6Q_PLATFORM_MODULE)
|
||||
|
||||
CENTEC_E582_48X2Q4Z_PLATFORM_MODULE = platform-modules-e582-48x2q4z_$(CENTEC_E582_48X2Q4Z_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
|
@ -1,6 +1,6 @@
|
||||
# python-saithrift package
|
||||
|
||||
PYTHON_SAITHRIFT_CENTEC = python-saithrift_1.2.1_amd64.deb
|
||||
PYTHON_SAITHRIFT_CENTEC = python-saithrift_1.3.5_amd64.deb
|
||||
$(PYTHON_SAITHRIFT_CENTEC)_SRC_PATH = $(SRC_PATH)/sonic-sairedis/SAI
|
||||
$(PYTHON_SAITHRIFT_CENTEC)_DEPENDS += $(CENTEC_SAI) $(THRIFT_COMPILER) $(PYTHON_THRIFT) $(LIBTHRIFT_DEV)
|
||||
SONIC_DPKG_DEBS += $(PYTHON_SAITHRIFT_CENTEC)
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Centec SAI
|
||||
CENTEC_SAI = libsai_1.2.4_amd64.deb
|
||||
$(CENTEC_SAI)_URL = https://github.com/CentecNetworks/goldengate-sai/raw/master/lib/SONiC_1.2.4/libsai_1.2.4-1.0_amd64.deb
|
||||
CENTEC_SAI = libsai_1.3.3_amd64.deb
|
||||
$(CENTEC_SAI)_URL = https://github.com/CentecNetworks/goldengate-sai/raw/master/lib/SONiC_1.3.3/libsai_1.3.3-1.0_amd64.deb
|
||||
|
||||
SONIC_ONLINE_DEBS += $(CENTEC_SAI)
|
||||
|
@ -12,6 +12,3 @@ i2c-mux-pca954x
|
||||
lm77
|
||||
adt7470
|
||||
tun
|
||||
centec_e582_48x6q_platform
|
||||
dal
|
||||
centec_at24c64
|
||||
|
@ -0,0 +1,302 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"bgp_asn": 65100,
|
||||
"deployment_id": null,
|
||||
"hostname": "switch1",
|
||||
"type": "LeafRouter",
|
||||
"hwsku": "E582-48x6q"
|
||||
|
||||
}
|
||||
},
|
||||
"BGP_PEER_RANGE": {},
|
||||
"VLAN": {},
|
||||
"PORT": {
|
||||
"Ethernet1": {
|
||||
"alias": "eth-0-1",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet2": {
|
||||
"alias": "eth-0-2",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet3": {
|
||||
"alias": "eth-0-3",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet4": {
|
||||
"alias": "eth-0-4",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet5": {
|
||||
"alias": "eth-0-5",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet6": {
|
||||
"alias": "eth-0-6",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet7": {
|
||||
"alias": "eth-0-7",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet8": {
|
||||
"alias": "eth-0-8",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet9": {
|
||||
"alias": "eth-0-9",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet10": {
|
||||
"alias": "eth-0-10",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet11": {
|
||||
"alias": "eth-0-11",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet12": {
|
||||
"alias": "eth-0-12",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet13": {
|
||||
"alias": "eth-0-13",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet14": {
|
||||
"alias": "eth-0-14",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet15": {
|
||||
"alias": "eth-0-15",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet16": {
|
||||
"alias": "eth-0-16",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet17": {
|
||||
"alias": "eth-0-17",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet18": {
|
||||
"alias": "eth-0-18",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet19": {
|
||||
"alias": "eth-0-19",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet20": {
|
||||
"alias": "eth-0-20",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet21": {
|
||||
"alias": "eth-0-21",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet22": {
|
||||
"alias": "eth-0-22",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet23": {
|
||||
"alias": "eth-0-23",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet24": {
|
||||
"alias": "eth-0-24",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet25": {
|
||||
"alias": "eth-0-25",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet26": {
|
||||
"alias": "eth-0-26",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet27": {
|
||||
"alias": "eth-0-27",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet28": {
|
||||
"alias": "eth-0-28",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet29": {
|
||||
"alias": "eth-0-29",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet30": {
|
||||
"alias": "eth-0-30",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet31": {
|
||||
"alias": "eth-0-31",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet32": {
|
||||
"alias": "eth-0-32",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet33": {
|
||||
"alias": "eth-0-33",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet34": {
|
||||
"alias": "eth-0-34",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet35": {
|
||||
"alias": "eth-0-35",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet36": {
|
||||
"alias": "eth-0-36",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet37": {
|
||||
"alias": "eth-0-37",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet38": {
|
||||
"alias": "eth-0-38",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet39": {
|
||||
"alias": "eth-0-39",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet40": {
|
||||
"alias": "eth-0-40",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet41": {
|
||||
"alias": "eth-0-41",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet42": {
|
||||
"alias": "eth-0-42",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet43": {
|
||||
"alias": "eth-0-43",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet44": {
|
||||
"alias": "eth-0-44",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet45": {
|
||||
"alias": "eth-0-45",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet46": {
|
||||
"alias": "eth-0-46",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet47": {
|
||||
"alias": "eth-0-47",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet48": {
|
||||
"alias": "eth-0-48",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet49": {
|
||||
"alias": "eth-0-49",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet50": {
|
||||
"alias": "eth-0-50",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet51": {
|
||||
"alias": "eth-0-51",
|
||||
"speed": "100000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet52": {
|
||||
"alias": "eth-0-52",
|
||||
"speed": "100000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet53": {
|
||||
"alias": "eth-0-53",
|
||||
"speed": "100000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet54": {
|
||||
"alias": "eth-0-54",
|
||||
"speed": "100000",
|
||||
"mtu": "9100"
|
||||
}
|
||||
},
|
||||
"SYSLOG_SERVER": {},
|
||||
"VLAN_INTERFACE": {},
|
||||
"PORTCHANNEL_INTERFACE": {},
|
||||
"PORTCHANNEL": {},
|
||||
"MGMT_INTERFACE": {},
|
||||
"DHCP_SERVER": {},
|
||||
"LOOPBACK_INTERFACE": {
|
||||
"Loopback0|127.0.0.1/8": {}
|
||||
},
|
||||
"ACL_TABLE": {},
|
||||
"INTERFACE": {
|
||||
"Ethernet1|192.168.1.1/24": {},
|
||||
"Ethernet2|192.168.2.1/24": {},
|
||||
"Ethernet3|192.168.3.1/24": {},
|
||||
"Ethernet4|192.168.4.1/24": {}
|
||||
}
|
||||
}
|
@ -0,0 +1,610 @@
|
||||
{
|
||||
"QUEUE": {
|
||||
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|0-2": {
|
||||
"wred_profile": "[WRED_PROFILE|AZURE_LOSSY]"
|
||||
},
|
||||
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|3-4": {
|
||||
"wred_profile": "[WRED_PROFILE|AZURE_LOSSLESS]",
|
||||
"scheduler": "[SCHEDULER|scheduler.0]"
|
||||
},
|
||||
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54|5-7": {
|
||||
"wred_profile": "[WRED_PROFILE|AZURE_LOSSY]"
|
||||
}
|
||||
},
|
||||
"WRED_PROFILE": {
|
||||
"AZURE_LOSSLESS": {
|
||||
"red_max_threshold": "32760",
|
||||
"yellow_max_threshold": "32760",
|
||||
"green_min_threshold": "4095",
|
||||
"red_min_threshold": "4095",
|
||||
"yellow_min_threshold": "4095",
|
||||
"green_max_threshold": "32760",
|
||||
"wred_yellow_enable": "true",
|
||||
"wred_green_enable": "true"
|
||||
},
|
||||
"AZURE_LOSSY": {
|
||||
"red_max_threshold": "32760",
|
||||
"yellow_max_threshold": "32760",
|
||||
"green_min_threshold": "4095",
|
||||
"red_min_threshold": "4095",
|
||||
"yellow_min_threshold": "4095",
|
||||
"green_max_threshold": "32760",
|
||||
"wred_yellow_enable": "true",
|
||||
"wred_green_enable": "true"
|
||||
}
|
||||
},
|
||||
"DSCP_TO_TC_MAP": {
|
||||
"AZURE": {
|
||||
"56": "7",
|
||||
"54": "6",
|
||||
"28": "3",
|
||||
"48": "6",
|
||||
"29": "3",
|
||||
"60": "7",
|
||||
"61": "7",
|
||||
"62": "7",
|
||||
"63": "7",
|
||||
"49": "6",
|
||||
"34": "4",
|
||||
"24": "3",
|
||||
"25": "3",
|
||||
"26": "3",
|
||||
"27": "3",
|
||||
"20": "2",
|
||||
"21": "2",
|
||||
"22": "2",
|
||||
"23": "2",
|
||||
"46": "5",
|
||||
"47": "5",
|
||||
"44": "5",
|
||||
"45": "5",
|
||||
"42": "5",
|
||||
"43": "5",
|
||||
"40": "5",
|
||||
"41": "5",
|
||||
"1": "0",
|
||||
"0": "0",
|
||||
"3": "0",
|
||||
"2": "0",
|
||||
"5": "0",
|
||||
"4": "0",
|
||||
"7": "0",
|
||||
"6": "0",
|
||||
"9": "1",
|
||||
"8": "1",
|
||||
"35": "4",
|
||||
"13": "1",
|
||||
"12": "1",
|
||||
"15": "1",
|
||||
"58": "7",
|
||||
"11": "1",
|
||||
"10": "1",
|
||||
"39": "4",
|
||||
"38": "4",
|
||||
"59": "7",
|
||||
"14": "1",
|
||||
"17": "2",
|
||||
"16": "2",
|
||||
"19": "2",
|
||||
"18": "2",
|
||||
"31": "3",
|
||||
"30": "3",
|
||||
"51": "6",
|
||||
"36": "4",
|
||||
"53": "6",
|
||||
"52": "6",
|
||||
"33": "4",
|
||||
"55": "6",
|
||||
"37": "4",
|
||||
"32": "4",
|
||||
"57": "7",
|
||||
"50": "6"
|
||||
}
|
||||
},
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"hwsku": "E582-48x6q",
|
||||
"hostname": "switch1",
|
||||
"bgp_asn": "None",
|
||||
"deployment_id": "None",
|
||||
"type": "LeafRouter"
|
||||
}
|
||||
},
|
||||
"PORT": {
|
||||
"Ethernet1": {
|
||||
"alias": "eth-0-1",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet2": {
|
||||
"alias": "eth-0-2",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet3": {
|
||||
"alias": "eth-0-3",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet4": {
|
||||
"alias": "eth-0-4",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet5": {
|
||||
"alias": "eth-0-5",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet6": {
|
||||
"alias": "eth-0-6",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet7": {
|
||||
"alias": "eth-0-7",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet8": {
|
||||
"alias": "eth-0-8",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet9": {
|
||||
"alias": "eth-0-9",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet10": {
|
||||
"alias": "eth-0-10",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet11": {
|
||||
"alias": "eth-0-11",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet12": {
|
||||
"alias": "eth-0-12",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet13": {
|
||||
"alias": "eth-0-13",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet14": {
|
||||
"alias": "eth-0-14",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet15": {
|
||||
"alias": "eth-0-15",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet16": {
|
||||
"alias": "eth-0-16",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet17": {
|
||||
"alias": "eth-0-17",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet18": {
|
||||
"alias": "eth-0-18",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet19": {
|
||||
"alias": "eth-0-19",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet20": {
|
||||
"alias": "eth-0-20",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet21": {
|
||||
"alias": "eth-0-21",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet22": {
|
||||
"alias": "eth-0-22",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet23": {
|
||||
"alias": "eth-0-23",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet24": {
|
||||
"alias": "eth-0-24",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet25": {
|
||||
"alias": "eth-0-25",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet26": {
|
||||
"alias": "eth-0-26",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet27": {
|
||||
"alias": "eth-0-27",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet28": {
|
||||
"alias": "eth-0-28",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet29": {
|
||||
"alias": "eth-0-29",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet30": {
|
||||
"alias": "eth-0-30",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet31": {
|
||||
"alias": "eth-0-31",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet32": {
|
||||
"alias": "eth-0-32",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet33": {
|
||||
"alias": "eth-0-33",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet34": {
|
||||
"alias": "eth-0-34",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet35": {
|
||||
"alias": "eth-0-35",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet36": {
|
||||
"alias": "eth-0-36",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet37": {
|
||||
"alias": "eth-0-37",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet38": {
|
||||
"alias": "eth-0-38",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet39": {
|
||||
"alias": "eth-0-39",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet40": {
|
||||
"alias": "eth-0-40",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet41": {
|
||||
"alias": "eth-0-41",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet42": {
|
||||
"alias": "eth-0-42",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet43": {
|
||||
"alias": "eth-0-43",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet44": {
|
||||
"alias": "eth-0-44",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet45": {
|
||||
"alias": "eth-0-45",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet46": {
|
||||
"alias": "eth-0-46",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet47": {
|
||||
"alias": "eth-0-47",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet48": {
|
||||
"alias": "eth-0-48",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet49": {
|
||||
"alias": "eth-0-49",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet50": {
|
||||
"alias": "eth-0-50",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet51": {
|
||||
"alias": "eth-0-51",
|
||||
"speed": "100000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet52": {
|
||||
"alias": "eth-0-52",
|
||||
"speed": "100000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet53": {
|
||||
"alias": "eth-0-53",
|
||||
"speed": "100000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet54": {
|
||||
"alias": "eth-0-54",
|
||||
"speed": "100000",
|
||||
"mtu": "9100"
|
||||
}
|
||||
},
|
||||
"PORT_QOS_MAP": {
|
||||
"Ethernet1,Ethernet2,Ethernet3,Ethernet4,Ethernet5,Ethernet6,Ethernet7,Ethernet8,Ethernet9,Ethernet10,Ethernet11,Ethernet12,Ethernet13,Ethernet14,Ethernet15,Ethernet16,Ethernet17,Ethernet18,Ethernet19,Ethernet20,Ethernet21,Ethernet22,Ethernet23,Ethernet24,Ethernet25,Ethernet26,Ethernet27,Ethernet28,Ethernet29,Ethernet30,Ethernet31,Ethernet32,Ethernet33,Ethernet34,Ethernet35,Ethernet36,Ethernet37,Ethernet38,Ethernet39,Ethernet40,Ethernet41,Ethernet42,Ethernet43,Ethernet44,Ethernet45,Ethernet46,Ethernet47,Ethernet48,Ethernet49,Ethernet50,Ethernet51,Ethernet52,Ethernet53,Ethernet54": {
|
||||
"pfc_enable": "3,4",
|
||||
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]"
|
||||
}
|
||||
},
|
||||
"SCHEDULER": {
|
||||
"scheduler.0": {
|
||||
"type": "DWRR",
|
||||
"weight": "25"
|
||||
},
|
||||
"scheduler.1": {
|
||||
"type": "DWRR",
|
||||
"weight": "30"
|
||||
},
|
||||
"scheduler.2": {
|
||||
"type": "DWRR",
|
||||
"weight": "20"
|
||||
}
|
||||
},
|
||||
"VLAN": {
|
||||
"Vlan500": {
|
||||
"dhcp_servers": [
|
||||
"192.168.5.1",
|
||||
"192.168.5.2",
|
||||
"192.168.5.3",
|
||||
"192.168.5.4"
|
||||
],
|
||||
"members": [
|
||||
"Ethernet5",
|
||||
"Ethernet6",
|
||||
"Ethernet7",
|
||||
"Ethernet8"
|
||||
],
|
||||
"vlanid": "500"
|
||||
},
|
||||
"Vlan600": {
|
||||
"dhcp_servers": [
|
||||
"192.168.6.1",
|
||||
"192.168.6.2",
|
||||
"192.168.6.3",
|
||||
"192.168.6.4"
|
||||
],
|
||||
"members": [
|
||||
"Ethernet5",
|
||||
"Ethernet6"
|
||||
],
|
||||
"vlanid": "600"
|
||||
},
|
||||
"Vlan700": {
|
||||
"dhcp_servers": [
|
||||
"192.168.7.1",
|
||||
"192.168.7.2",
|
||||
"192.168.7.3",
|
||||
"192.168.7.4"
|
||||
],
|
||||
"members": [
|
||||
"Ethernet5",
|
||||
"Ethernet7"
|
||||
],
|
||||
"vlanid": "700"
|
||||
},
|
||||
"Vlan800": {
|
||||
"dhcp_servers": [
|
||||
"192.168.8.1",
|
||||
"192.168.8.2",
|
||||
"192.168.8.3",
|
||||
"192.168.8.4"
|
||||
],
|
||||
"members": [
|
||||
"Ethernet5",
|
||||
"Ethernet8"
|
||||
],
|
||||
"vlanid": "800"
|
||||
}
|
||||
},
|
||||
"VLAN_MEMBER": {
|
||||
"Vlan500|Ethernet5": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan500|Ethernet6": {
|
||||
"tagging_mode": "untagged"
|
||||
},
|
||||
"Vlan500|Ethernet7": {
|
||||
"tagging_mode": "untagged"
|
||||
},
|
||||
"Vlan500|Ethernet8": {
|
||||
"tagging_mode": "untagged"
|
||||
},
|
||||
"Vlan600|Ethernet5": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan600|Ethernet6": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan700|Ethernet5": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan700|Ethernet7": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan800|Ethernet5": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan800|Ethernet8": {
|
||||
"tagging_mode": "tagged"
|
||||
}
|
||||
},
|
||||
"INTERFACE": {
|
||||
"Ethernet1|192.168.1.1/24": {},
|
||||
"Ethernet2|192.168.2.1/24": {},
|
||||
"Ethernet3|192.168.3.1/24": {},
|
||||
"Ethernet4|192.168.4.1/24": {}
|
||||
},
|
||||
"VLAN_INTERFACE": {
|
||||
"Vlan500|192.168.5.1/24": {},
|
||||
"Vlan600|192.168.6.1/24": {},
|
||||
"Vlan700|192.168.7.1/24": {},
|
||||
"Vlan800|192.168.8.1/24": {}
|
||||
},
|
||||
"LOOPBACK_INTERFACE": {
|
||||
"Loopback0|127.0.0.1/8": {}
|
||||
},
|
||||
"CABLE_LENGTH": {
|
||||
"AZURE": {
|
||||
"Ethernet8": "40m",
|
||||
"Ethernet9": "40m",
|
||||
"Ethernet2": "40m",
|
||||
"Ethernet3": "40m",
|
||||
"Ethernet1": "40m",
|
||||
"Ethernet6": "40m",
|
||||
"Ethernet7": "40m",
|
||||
"Ethernet4": "40m",
|
||||
"Ethernet5": "40m",
|
||||
"Ethernet22": "40m",
|
||||
"Ethernet50": "40m",
|
||||
"Ethernet51": "40m",
|
||||
"Ethernet52": "40m",
|
||||
"Ethernet53": "40m",
|
||||
"Ethernet54": "40m",
|
||||
"Ethernet38": "40m",
|
||||
"Ethernet39": "40m",
|
||||
"Ethernet18": "40m",
|
||||
"Ethernet19": "40m",
|
||||
"Ethernet14": "40m",
|
||||
"Ethernet15": "40m",
|
||||
"Ethernet16": "40m",
|
||||
"Ethernet17": "40m",
|
||||
"Ethernet10": "40m",
|
||||
"Ethernet11": "40m",
|
||||
"Ethernet12": "40m",
|
||||
"Ethernet35": "40m",
|
||||
"Ethernet37": "40m",
|
||||
"Ethernet32": "40m",
|
||||
"Ethernet33": "40m",
|
||||
"Ethernet30": "40m",
|
||||
"Ethernet31": "40m",
|
||||
"Ethernet49": "40m",
|
||||
"Ethernet48": "40m",
|
||||
"Ethernet47": "40m",
|
||||
"Ethernet36": "40m",
|
||||
"Ethernet45": "40m",
|
||||
"Ethernet44": "40m",
|
||||
"Ethernet43": "40m",
|
||||
"Ethernet42": "40m",
|
||||
"Ethernet41": "40m",
|
||||
"Ethernet40": "40m",
|
||||
"Ethernet29": "40m",
|
||||
"Ethernet28": "40m",
|
||||
"Ethernet34": "40m",
|
||||
"Ethernet46": "40m",
|
||||
"Ethernet21": "40m",
|
||||
"Ethernet20": "40m",
|
||||
"Ethernet23": "40m",
|
||||
"Ethernet13": "40m",
|
||||
"Ethernet25": "40m",
|
||||
"Ethernet24": "40m",
|
||||
"Ethernet27": "40m",
|
||||
"Ethernet26": "40m"
|
||||
}
|
||||
},
|
||||
"CRM": {
|
||||
"Config": {
|
||||
"acl_table_threshold_type": "percentage",
|
||||
"nexthop_group_threshold_type": "percentage",
|
||||
"fdb_entry_high_threshold": "85",
|
||||
"acl_entry_threshold_type": "percentage",
|
||||
"ipv6_neighbor_low_threshold": "70",
|
||||
"nexthop_group_member_low_threshold": "70",
|
||||
"acl_group_high_threshold": "85",
|
||||
"ipv4_route_high_threshold": "85",
|
||||
"acl_counter_high_threshold": "85",
|
||||
"ipv4_route_low_threshold": "70",
|
||||
"ipv4_route_threshold_type": "percentage",
|
||||
"ipv4_neighbor_low_threshold": "70",
|
||||
"acl_group_threshold_type": "percentage",
|
||||
"ipv4_nexthop_high_threshold": "85",
|
||||
"ipv6_route_threshold_type": "percentage",
|
||||
"nexthop_group_low_threshold": "70",
|
||||
"ipv4_neighbor_high_threshold": "85",
|
||||
"ipv6_route_high_threshold": "85",
|
||||
"ipv6_nexthop_threshold_type": "percentage",
|
||||
"polling_interval": "300",
|
||||
"ipv4_nexthop_threshold_type": "percentage",
|
||||
"acl_group_low_threshold": "70",
|
||||
"acl_entry_low_threshold": "70",
|
||||
"nexthop_group_member_threshold_type": "percentage",
|
||||
"ipv4_nexthop_low_threshold": "70",
|
||||
"acl_counter_threshold_type": "percentage",
|
||||
"ipv6_neighbor_high_threshold": "85",
|
||||
"nexthop_group_member_high_threshold": "85",
|
||||
"acl_table_low_threshold": "70",
|
||||
"fdb_entry_threshold_type": "percentage",
|
||||
"ipv6_neighbor_threshold_type": "percentage",
|
||||
"acl_table_high_threshold": "85",
|
||||
"ipv6_nexthop_low_threshold": "70",
|
||||
"acl_counter_low_threshold": "70",
|
||||
"ipv4_neighbor_threshold_type": "percentage",
|
||||
"nexthop_group_high_threshold": "85",
|
||||
"ipv6_route_low_threshold": "70",
|
||||
"acl_entry_high_threshold": "85",
|
||||
"fdb_entry_low_threshold": "70",
|
||||
"ipv6_nexthop_high_threshold": "85"
|
||||
}
|
||||
}
|
||||
}
|
@ -53,26 +53,25 @@
|
||||
*/
|
||||
|
||||
struct at24_data {
|
||||
struct at24_platform_data chip;
|
||||
struct memory_accessor macc;
|
||||
int use_smbus;
|
||||
struct at24_platform_data chip;
|
||||
int use_smbus;
|
||||
|
||||
/*
|
||||
* Lock protects against activities from other Linux tasks,
|
||||
* but not from changes by other I2C masters.
|
||||
*/
|
||||
struct mutex lock;
|
||||
struct bin_attribute bin;
|
||||
/*
|
||||
* Lock protects against activities from other Linux tasks,
|
||||
* but not from changes by other I2C masters.
|
||||
*/
|
||||
struct mutex lock;
|
||||
struct bin_attribute bin;
|
||||
|
||||
u8 *writebuf;
|
||||
unsigned write_max;
|
||||
unsigned num_addresses;
|
||||
u8 *writebuf;
|
||||
unsigned write_max;
|
||||
unsigned num_addresses;
|
||||
|
||||
/*
|
||||
* Some chips tie up multiple I2C addresses; dummy devices reserve
|
||||
* them for us, and we'll use them with SMBus calls.
|
||||
*/
|
||||
struct i2c_client *client[];
|
||||
/*
|
||||
* Some chips tie up multiple I2C addresses; dummy devices reserve
|
||||
* them for us, and we'll use them with SMBus calls.
|
||||
*/
|
||||
struct i2c_client *client[];
|
||||
};
|
||||
|
||||
/*
|
||||
@ -102,13 +101,13 @@ MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)");
|
||||
#define AT24_BITMASK(x) (BIT(x) - 1)
|
||||
|
||||
/* create non-zero magic value for given eeprom parameters */
|
||||
#define AT24_DEVICE_MAGIC(_len, _flags) \
|
||||
((1 << AT24_SIZE_FLAGS | (_flags)) \
|
||||
<< AT24_SIZE_BYTELEN | ilog2(_len))
|
||||
#define AT24_DEVICE_MAGIC(_len, _flags) \
|
||||
((1 << AT24_SIZE_FLAGS | (_flags)) \
|
||||
<< AT24_SIZE_BYTELEN | ilog2(_len))
|
||||
|
||||
static const struct i2c_device_id at24_ctc_ids[] = {
|
||||
{ "24c64-ctc", AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16 | AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
|
||||
{ /* END OF LIST */ }
|
||||
{ "24c64-ctc", AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16 | AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
|
||||
{ /* END OF LIST */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, at24_ctc_ids);
|
||||
|
||||
@ -120,62 +119,62 @@ MODULE_DEVICE_TABLE(i2c, at24_ctc_ids);
|
||||
* Assumes that sanity checks for offset happened at sysfs-layer.
|
||||
*/
|
||||
static struct i2c_client *at24_translate_offset(struct at24_data *at24,
|
||||
unsigned *offset)
|
||||
unsigned *offset)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned i = 0;
|
||||
|
||||
if (at24->chip.flags & AT24_FLAG_ADDR16) {
|
||||
i = *offset >> 16;
|
||||
*offset &= 0xffff;
|
||||
} else {
|
||||
i = *offset >> 8;
|
||||
*offset &= 0xff;
|
||||
}
|
||||
if (at24->chip.flags & AT24_FLAG_ADDR16) {
|
||||
i = *offset >> 16;
|
||||
*offset &= 0xffff;
|
||||
} else {
|
||||
i = *offset >> 8;
|
||||
*offset &= 0xff;
|
||||
}
|
||||
|
||||
return at24->client[i];
|
||||
return at24->client[i];
|
||||
}
|
||||
|
||||
static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
|
||||
unsigned offset, size_t count)
|
||||
unsigned offset, size_t count)
|
||||
{
|
||||
struct i2c_msg msg[2];
|
||||
struct i2c_client *client;
|
||||
unsigned long timeout, read_time;
|
||||
int status;
|
||||
struct i2c_msg msg[2];
|
||||
struct i2c_client *client;
|
||||
unsigned long timeout, read_time;
|
||||
int status;
|
||||
|
||||
memset(msg, 0, sizeof(msg));
|
||||
memset(msg, 0, sizeof(msg));
|
||||
|
||||
/*
|
||||
* REVISIT some multi-address chips don't rollover page reads to
|
||||
* the next slave address, so we may need to truncate the count.
|
||||
* Those chips might need another quirk flag.
|
||||
*
|
||||
* If the real hardware used four adjacent 24c02 chips and that
|
||||
* were misconfigured as one 24c08, that would be a similar effect:
|
||||
* one "eeprom" file not four, but larger reads would fail when
|
||||
* they crossed certain pages.
|
||||
*/
|
||||
/*
|
||||
* REVISIT some multi-address chips don't rollover page reads to
|
||||
* the next slave address, so we may need to truncate the count.
|
||||
* Those chips might need another quirk flag.
|
||||
*
|
||||
* If the real hardware used four adjacent 24c02 chips and that
|
||||
* were misconfigured as one 24c08, that would be a similar effect:
|
||||
* one "eeprom" file not four, but larger reads would fail when
|
||||
* they crossed certain pages.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Slave address and byte offset derive from the offset. Always
|
||||
* set the byte address; on a multi-master board, another master
|
||||
* may have changed the chip's "current" address pointer.
|
||||
*/
|
||||
client = at24_translate_offset(at24, &offset);
|
||||
/*
|
||||
* Slave address and byte offset derive from the offset. Always
|
||||
* set the byte address; on a multi-master board, another master
|
||||
* may have changed the chip's "current" address pointer.
|
||||
*/
|
||||
client = at24_translate_offset(at24, &offset);
|
||||
|
||||
if (count > io_limit)
|
||||
count = io_limit;
|
||||
if (count > io_limit)
|
||||
count = io_limit;
|
||||
|
||||
count = 1;
|
||||
count = 1;
|
||||
|
||||
/*
|
||||
* Reads fail if the previous write didn't complete yet. We may
|
||||
* loop a few times until this one succeeds, waiting at least
|
||||
* long enough for one entire page write to work.
|
||||
*/
|
||||
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||
do {
|
||||
read_time = jiffies;
|
||||
/*
|
||||
* Reads fail if the previous write didn't complete yet. We may
|
||||
* loop a few times until this one succeeds, waiting at least
|
||||
* long enough for one entire page write to work.
|
||||
*/
|
||||
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||
do {
|
||||
read_time = jiffies;
|
||||
|
||||
status = i2c_smbus_write_byte_data(client, (offset >> 8) & 0x0ff, offset & 0x0ff );
|
||||
status = i2c_smbus_read_byte(client);
|
||||
@ -184,65 +183,62 @@ static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
|
||||
status = count;
|
||||
}
|
||||
|
||||
dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n",
|
||||
count, offset, status, jiffies);
|
||||
dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n", count, offset, status, jiffies);
|
||||
|
||||
if (status == count)
|
||||
return count;
|
||||
if (status == count)
|
||||
return count;
|
||||
|
||||
/* REVISIT: at HZ=100, this is sloooow */
|
||||
msleep(1);
|
||||
} while (time_before(read_time, timeout));
|
||||
/* REVISIT: at HZ=100, this is sloooow */
|
||||
msleep(1);
|
||||
} while (time_before(read_time, timeout));
|
||||
|
||||
return -ETIMEDOUT;
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static ssize_t at24_read(struct at24_data *at24,
|
||||
char *buf, loff_t off, size_t count)
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
ssize_t retval = 0;
|
||||
ssize_t retval = 0;
|
||||
|
||||
if (unlikely(!count))
|
||||
return count;
|
||||
if (unlikely(!count))
|
||||
return count;
|
||||
|
||||
memset(buf, 0, count);
|
||||
|
||||
/*
|
||||
* Read data from chip, protecting against concurrent updates
|
||||
* from this host, but not from other I2C masters.
|
||||
*/
|
||||
mutex_lock(&at24->lock);
|
||||
/*
|
||||
* Read data from chip, protecting against concurrent updates
|
||||
* from this host, but not from other I2C masters.
|
||||
*/
|
||||
mutex_lock(&at24->lock);
|
||||
|
||||
while (count) {
|
||||
ssize_t status;
|
||||
while (count) {
|
||||
ssize_t status;
|
||||
|
||||
status = at24_eeprom_read(at24, buf, off, count);
|
||||
if (status <= 0) {
|
||||
if (retval == 0)
|
||||
retval = status;
|
||||
break;
|
||||
}
|
||||
buf += status;
|
||||
off += status;
|
||||
count -= status;
|
||||
retval += status;
|
||||
}
|
||||
status = at24_eeprom_read(at24, buf, off, count);
|
||||
if (status <= 0) {
|
||||
if (retval == 0)
|
||||
retval = status;
|
||||
break;
|
||||
}
|
||||
buf += status;
|
||||
off += status;
|
||||
count -= status;
|
||||
retval += status;
|
||||
}
|
||||
|
||||
//printk(KERN_ALERT "at24_read buf = %s, retval = %zu\n", buf, retval);
|
||||
mutex_unlock(&at24->lock);
|
||||
|
||||
mutex_unlock(&at24->lock);
|
||||
|
||||
return retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static ssize_t at24_bin_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
struct bin_attribute *attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
struct at24_data *at24;
|
||||
struct at24_data *at24;
|
||||
|
||||
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||
return at24_read(at24, buf, off, count);
|
||||
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||
return at24_read(at24, buf, off, count);
|
||||
}
|
||||
|
||||
|
||||
@ -255,334 +251,281 @@ static ssize_t at24_bin_read(struct file *filp, struct kobject *kobj,
|
||||
* writes at most one page.
|
||||
*/
|
||||
static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
|
||||
unsigned offset, size_t count)
|
||||
unsigned offset, size_t count)
|
||||
{
|
||||
struct i2c_client *client;
|
||||
ssize_t status;
|
||||
unsigned long timeout, write_time;
|
||||
unsigned next_page;
|
||||
struct i2c_client *client;
|
||||
ssize_t status;
|
||||
unsigned long timeout, write_time;
|
||||
unsigned next_page;
|
||||
|
||||
/* Get corresponding I2C address and adjust offset */
|
||||
client = at24_translate_offset(at24, &offset);
|
||||
/* Get corresponding I2C address and adjust offset */
|
||||
client = at24_translate_offset(at24, &offset);
|
||||
|
||||
/* write_max is at most a page */
|
||||
if (count > at24->write_max)
|
||||
count = at24->write_max;
|
||||
/* write_max is at most a page */
|
||||
if (count > at24->write_max)
|
||||
count = at24->write_max;
|
||||
|
||||
/* Never roll over backwards, to the start of this page */
|
||||
next_page = roundup(offset + 1, at24->chip.page_size);
|
||||
if (offset + count > next_page)
|
||||
count = next_page - offset;
|
||||
/* Never roll over backwards, to the start of this page */
|
||||
next_page = roundup(offset + 1, at24->chip.page_size);
|
||||
if (offset + count > next_page)
|
||||
count = next_page - offset;
|
||||
|
||||
/*
|
||||
* Writes fail if the previous one didn't complete yet. We may
|
||||
* loop a few times until this one succeeds, waiting at least
|
||||
* long enough for one entire page write to work.
|
||||
*/
|
||||
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||
do {
|
||||
write_time = jiffies;
|
||||
/*
|
||||
* Writes fail if the previous one didn't complete yet. We may
|
||||
* loop a few times until this one succeeds, waiting at least
|
||||
* long enough for one entire page write to work.
|
||||
*/
|
||||
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||
do {
|
||||
write_time = jiffies;
|
||||
|
||||
status = i2c_smbus_write_word_data(client,
|
||||
(offset >> 8) & 0x0ff, (offset & 0xFF) | buf[0]);
|
||||
status = i2c_smbus_write_word_data(client, (offset >> 8) & 0x0ff, (offset & 0xFF) | buf[0]);
|
||||
if (status == 0)
|
||||
status = count;
|
||||
|
||||
dev_dbg(&client->dev, "write %zu@%d --> %zd (%ld)\n",
|
||||
count, offset, status, jiffies);
|
||||
dev_dbg(&client->dev, "write %zu@%d --> %zd (%ld)\n", count, offset, status, jiffies);
|
||||
|
||||
if (status == count)
|
||||
return count;
|
||||
if (status == count)
|
||||
return count;
|
||||
|
||||
/* REVISIT: at HZ=100, this is sloooow */
|
||||
msleep(1);
|
||||
} while (time_before(write_time, timeout));
|
||||
/* REVISIT: at HZ=100, this is sloooow */
|
||||
msleep(1);
|
||||
} while (time_before(write_time, timeout));
|
||||
|
||||
return -ETIMEDOUT;
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off,
|
||||
size_t count)
|
||||
size_t count)
|
||||
{
|
||||
ssize_t retval = 0;
|
||||
ssize_t retval = 0;
|
||||
|
||||
if (unlikely(!count))
|
||||
return count;
|
||||
if (unlikely(!count))
|
||||
return count;
|
||||
|
||||
/*
|
||||
* Write data to chip, protecting against concurrent updates
|
||||
* from this host, but not from other I2C masters.
|
||||
*/
|
||||
mutex_lock(&at24->lock);
|
||||
/*
|
||||
* Write data to chip, protecting against concurrent updates
|
||||
* from this host, but not from other I2C masters.
|
||||
*/
|
||||
mutex_lock(&at24->lock);
|
||||
|
||||
while (count) {
|
||||
ssize_t status;
|
||||
while (count) {
|
||||
ssize_t status;
|
||||
|
||||
status = at24_eeprom_write(at24, buf, off, 1); /* only one-byte to write; TODO page wirte */
|
||||
if (status <= 0) {
|
||||
if (retval == 0)
|
||||
retval = status;
|
||||
break;
|
||||
}
|
||||
buf += status;
|
||||
off += status;
|
||||
count -= status;
|
||||
retval += status;
|
||||
}
|
||||
status = at24_eeprom_write(at24, buf, off, 1); /* only one-byte to write; TODO page wirte */
|
||||
if (status <= 0) {
|
||||
if (retval == 0)
|
||||
retval = status;
|
||||
break;
|
||||
}
|
||||
buf += status;
|
||||
off += status;
|
||||
count -= status;
|
||||
retval += status;
|
||||
}
|
||||
|
||||
mutex_unlock(&at24->lock);
|
||||
mutex_unlock(&at24->lock);
|
||||
|
||||
return retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static ssize_t at24_bin_write(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
struct bin_attribute *attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
struct at24_data *at24;
|
||||
struct at24_data *at24;
|
||||
|
||||
if (unlikely(off >= attr->size))
|
||||
return -EFBIG;
|
||||
if (unlikely(off >= attr->size))
|
||||
return -EFBIG;
|
||||
|
||||
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||
return at24_write(at24, buf, off, count);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* This lets other kernel code access the eeprom data. For example, it
|
||||
* might hold a board's Ethernet address, or board-specific calibration
|
||||
* data generated on the manufacturing floor.
|
||||
*/
|
||||
|
||||
static ssize_t at24_macc_read(struct memory_accessor *macc, char *buf,
|
||||
off_t offset, size_t count)
|
||||
{
|
||||
struct at24_data *at24 = container_of(macc, struct at24_data, macc);
|
||||
|
||||
return at24_read(at24, buf, offset, count);
|
||||
}
|
||||
|
||||
static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf,
|
||||
off_t offset, size_t count)
|
||||
{
|
||||
struct at24_data *at24 = container_of(macc, struct at24_data, macc);
|
||||
|
||||
return at24_write(at24, buf, offset, count);
|
||||
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||
return at24_write(at24, buf, off, count);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static void at24_get_ofdata(struct i2c_client *client,
|
||||
struct at24_platform_data *chip)
|
||||
struct at24_platform_data *chip)
|
||||
{
|
||||
const __be32 *val;
|
||||
struct device_node *node = client->dev.of_node;
|
||||
const __be32 *val;
|
||||
struct device_node *node = client->dev.of_node;
|
||||
|
||||
if (node) {
|
||||
if (of_get_property(node, "read-only", NULL))
|
||||
chip->flags |= AT24_FLAG_READONLY;
|
||||
val = of_get_property(node, "pagesize", NULL);
|
||||
if (val)
|
||||
chip->page_size = be32_to_cpup(val);
|
||||
}
|
||||
if (node) {
|
||||
if (of_get_property(node, "read-only", NULL))
|
||||
chip->flags |= AT24_FLAG_READONLY;
|
||||
val = of_get_property(node, "pagesize", NULL);
|
||||
if (val)
|
||||
chip->page_size = be32_to_cpup(val);
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void at24_get_ofdata(struct i2c_client *client,
|
||||
struct at24_platform_data *chip)
|
||||
struct at24_platform_data *chip)
|
||||
{ }
|
||||
#endif /* CONFIG_OF */
|
||||
|
||||
static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct at24_platform_data chip;
|
||||
bool writable;
|
||||
int use_smbus = 0;
|
||||
struct at24_data *at24;
|
||||
int err;
|
||||
unsigned i, num_addresses;
|
||||
kernel_ulong_t magic;
|
||||
struct at24_platform_data chip;
|
||||
bool writable;
|
||||
int use_smbus = 0;
|
||||
struct at24_data *at24;
|
||||
int err;
|
||||
unsigned i, num_addresses;
|
||||
kernel_ulong_t magic;
|
||||
|
||||
if (client->dev.platform_data) {
|
||||
chip = *(struct at24_platform_data *)client->dev.platform_data;
|
||||
} else {
|
||||
if (!id->driver_data)
|
||||
return -ENODEV;
|
||||
if (client->dev.platform_data) {
|
||||
chip = *(struct at24_platform_data *)client->dev.platform_data;
|
||||
} else {
|
||||
if (!id->driver_data)
|
||||
return -ENODEV;
|
||||
|
||||
magic = id->driver_data;
|
||||
chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
|
||||
magic >>= AT24_SIZE_BYTELEN;
|
||||
chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS);
|
||||
magic = id->driver_data;
|
||||
chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
|
||||
magic >>= AT24_SIZE_BYTELEN;
|
||||
chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS);
|
||||
|
||||
/*
|
||||
* This is slow, but we can't know all eeproms, so we better
|
||||
* play safe. Specifying custom eeprom-types via platform_data
|
||||
* is recommended anyhow.
|
||||
*/
|
||||
chip.page_size = 1;
|
||||
/*
|
||||
* This is slow, but we can't know all eeproms, so we better
|
||||
* play safe. Specifying custom eeprom-types via platform_data
|
||||
* is recommended anyhow.
|
||||
*/
|
||||
chip.page_size = 1;
|
||||
|
||||
/* update chipdata if OF is present */
|
||||
at24_get_ofdata(client, &chip);
|
||||
/* update chipdata if OF is present */
|
||||
at24_get_ofdata(client, &chip);
|
||||
|
||||
printk(KERN_ALERT "at24_probe chip.byte_len = 0x%x\n", chip.byte_len);
|
||||
printk(KERN_ALERT "at24_probe chip.flags = 0x%x\n", chip.flags);
|
||||
printk(KERN_ALERT "at24_probe chip.magic = 0x%lx\n", id->driver_data);
|
||||
chip.setup = NULL;
|
||||
chip.context = NULL;
|
||||
}
|
||||
|
||||
chip.setup = NULL;
|
||||
chip.context = NULL;
|
||||
}
|
||||
if (!is_power_of_2(chip.byte_len))
|
||||
dev_warn(&client->dev,
|
||||
"byte_len looks suspicious (no power of 2)!\n");
|
||||
if (!chip.page_size) {
|
||||
dev_err(&client->dev, "page_size must not be 0!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!is_power_of_2(chip.page_size))
|
||||
dev_warn(&client->dev,
|
||||
"page_size looks suspicious (no power of 2)!\n");
|
||||
|
||||
if (!is_power_of_2(chip.byte_len))
|
||||
dev_warn(&client->dev,
|
||||
"byte_len looks suspicious (no power of 2)!\n");
|
||||
if (!chip.page_size) {
|
||||
dev_err(&client->dev, "page_size must not be 0!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!is_power_of_2(chip.page_size))
|
||||
dev_warn(&client->dev,
|
||||
"page_size looks suspicious (no power of 2)!\n");
|
||||
|
||||
/* Use I2C operations unless we're stuck with SMBus extensions. */
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
|
||||
if (i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
|
||||
use_smbus = I2C_SMBUS_I2C_BLOCK_DATA;
|
||||
} else if (i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_READ_WORD_DATA)) {
|
||||
use_smbus = I2C_SMBUS_WORD_DATA;
|
||||
} else if (i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
|
||||
use_smbus = I2C_SMBUS_BYTE_DATA;
|
||||
} else {
|
||||
return -EPFNOSUPPORT;
|
||||
}
|
||||
/* Use I2C operations unless we're stuck with SMBus extensions. */
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
|
||||
if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
|
||||
use_smbus = I2C_SMBUS_I2C_BLOCK_DATA;
|
||||
} else if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_WORD_DATA)) {
|
||||
use_smbus = I2C_SMBUS_WORD_DATA;
|
||||
} else if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
|
||||
use_smbus = I2C_SMBUS_BYTE_DATA;
|
||||
} else {
|
||||
return -EPFNOSUPPORT;
|
||||
}
|
||||
use_smbus = I2C_SMBUS_BYTE_DATA;
|
||||
printk(KERN_ALERT "at24_probe use_smbus --> %d\n",
|
||||
use_smbus);
|
||||
}
|
||||
}
|
||||
|
||||
if (chip.flags & AT24_FLAG_TAKE8ADDR)
|
||||
num_addresses = 8;
|
||||
else
|
||||
num_addresses = DIV_ROUND_UP(chip.byte_len,
|
||||
(chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
|
||||
if (chip.flags & AT24_FLAG_TAKE8ADDR)
|
||||
num_addresses = 8;
|
||||
else
|
||||
num_addresses = DIV_ROUND_UP(chip.byte_len, (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
|
||||
|
||||
at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
|
||||
num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
|
||||
if (!at24)
|
||||
return -ENOMEM;
|
||||
at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) + num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
|
||||
if (!at24)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_init(&at24->lock);
|
||||
at24->use_smbus = use_smbus;
|
||||
at24->chip = chip;
|
||||
at24->num_addresses = num_addresses;
|
||||
mutex_init(&at24->lock);
|
||||
at24->use_smbus = use_smbus;
|
||||
at24->chip = chip;
|
||||
at24->num_addresses = num_addresses;
|
||||
|
||||
/*
|
||||
* Export the EEPROM bytes through sysfs, since that's convenient.
|
||||
* By default, only root should see the data (maybe passwords etc)
|
||||
*/
|
||||
sysfs_bin_attr_init(&at24->bin);
|
||||
at24->bin.attr.name = "eeprom";
|
||||
at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
|
||||
at24->bin.read = at24_bin_read;
|
||||
at24->bin.size = chip.byte_len;
|
||||
printk(KERN_ALERT "at24_probe chip.byte_len = 0x%x\n", chip.byte_len);
|
||||
printk(KERN_ALERT "at24_probe chip.flags = 0x%x\n", chip.flags);
|
||||
printk(KERN_ALERT "at24_probe chip.magic = 0x%lx\n", id->driver_data);
|
||||
printk(KERN_ALERT "at24_probe use_smbus = %d\n", at24->use_smbus);
|
||||
printk(KERN_ALERT "at24_probe num_addresses = %d\n", at24->num_addresses);
|
||||
|
||||
at24->macc.read = at24_macc_read;
|
||||
/*
|
||||
* Export the EEPROM bytes through sysfs, since that's convenient.
|
||||
* By default, only root should see the data (maybe passwords etc)
|
||||
*/
|
||||
sysfs_bin_attr_init(&at24->bin);
|
||||
at24->bin.attr.name = "eeprom";
|
||||
at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
|
||||
at24->bin.read = at24_bin_read;
|
||||
at24->bin.size = chip.byte_len;
|
||||
|
||||
writable = !(chip.flags & AT24_FLAG_READONLY);
|
||||
if (writable) {
|
||||
if (!use_smbus || i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
|
||||
writable = !(chip.flags & AT24_FLAG_READONLY);
|
||||
if (writable) {
|
||||
if (!use_smbus || i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
|
||||
unsigned write_max = chip.page_size;
|
||||
|
||||
unsigned write_max = chip.page_size;
|
||||
at24->bin.write = at24_bin_write;
|
||||
at24->bin.attr.mode |= S_IWUSR;
|
||||
|
||||
at24->macc.write = at24_macc_write;
|
||||
if (write_max > io_limit)
|
||||
write_max = io_limit;
|
||||
if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX)
|
||||
write_max = I2C_SMBUS_BLOCK_MAX;
|
||||
at24->write_max = write_max;
|
||||
|
||||
at24->bin.write = at24_bin_write;
|
||||
at24->bin.attr.mode |= S_IWUSR;
|
||||
/* buffer (data + address at the beginning) */
|
||||
at24->writebuf = devm_kzalloc(&client->dev, write_max + 2, GFP_KERNEL);
|
||||
if (!at24->writebuf)
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
dev_warn(&client->dev, "cannot write due to controller restrictions.");
|
||||
}
|
||||
}
|
||||
|
||||
if (write_max > io_limit)
|
||||
write_max = io_limit;
|
||||
if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX)
|
||||
write_max = I2C_SMBUS_BLOCK_MAX;
|
||||
at24->write_max = write_max;
|
||||
at24->client[0] = client;
|
||||
|
||||
/* buffer (data + address at the beginning) */
|
||||
at24->writebuf = devm_kzalloc(&client->dev,
|
||||
write_max + 2, GFP_KERNEL);
|
||||
if (!at24->writebuf)
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
dev_warn(&client->dev,
|
||||
"cannot write due to controller restrictions.");
|
||||
}
|
||||
}
|
||||
/* use dummy devices for multiple-address chips */
|
||||
for (i = 1; i < num_addresses; i++) {
|
||||
at24->client[i] = i2c_new_dummy(client->adapter, client->addr + i);
|
||||
if (!at24->client[i]) {
|
||||
dev_err(&client->dev, "address 0x%02x unavailable\n", client->addr + i);
|
||||
err = -EADDRINUSE;
|
||||
goto err_clients;
|
||||
}
|
||||
}
|
||||
|
||||
at24->client[0] = client;
|
||||
err = sysfs_create_bin_file(&client->dev.kobj, &at24->bin);
|
||||
if (err)
|
||||
goto err_clients;
|
||||
|
||||
/* use dummy devices for multiple-address chips */
|
||||
for (i = 1; i < num_addresses; i++) {
|
||||
at24->client[i] = i2c_new_dummy(client->adapter,
|
||||
client->addr + i);
|
||||
if (!at24->client[i]) {
|
||||
dev_err(&client->dev, "address 0x%02x unavailable\n",
|
||||
client->addr + i);
|
||||
err = -EADDRINUSE;
|
||||
goto err_clients;
|
||||
}
|
||||
}
|
||||
i2c_set_clientdata(client, at24);
|
||||
|
||||
err = sysfs_create_bin_file(&client->dev.kobj, &at24->bin);
|
||||
if (err)
|
||||
goto err_clients;
|
||||
printk(KERN_ALERT "at24_probe %s done\n", client->name);
|
||||
|
||||
i2c_set_clientdata(client, at24);
|
||||
|
||||
dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n",
|
||||
at24->bin.size, client->name,
|
||||
writable ? "writable" : "read-only", at24->write_max);
|
||||
if (use_smbus == I2C_SMBUS_WORD_DATA ||
|
||||
use_smbus == I2C_SMBUS_BYTE_DATA) {
|
||||
dev_notice(&client->dev, "Falling back to %s reads, "
|
||||
"performance will suffer\n", use_smbus ==
|
||||
I2C_SMBUS_WORD_DATA ? "word" : "byte");
|
||||
}
|
||||
|
||||
/* export data to kernel code */
|
||||
if (chip.setup)
|
||||
chip.setup(&at24->macc, chip.context);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
err_clients:
|
||||
for (i = 1; i < num_addresses; i++)
|
||||
if (at24->client[i])
|
||||
i2c_unregister_device(at24->client[i]);
|
||||
for (i = 1; i < num_addresses; i++)
|
||||
if (at24->client[i])
|
||||
i2c_unregister_device(at24->client[i]);
|
||||
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int at24_remove(struct i2c_client *client)
|
||||
{
|
||||
struct at24_data *at24;
|
||||
int i;
|
||||
struct at24_data *at24;
|
||||
int i;
|
||||
|
||||
at24 = i2c_get_clientdata(client);
|
||||
sysfs_remove_bin_file(&client->dev.kobj, &at24->bin);
|
||||
at24 = i2c_get_clientdata(client);
|
||||
sysfs_remove_bin_file(&client->dev.kobj, &at24->bin);
|
||||
|
||||
for (i = 1; i < at24->num_addresses; i++)
|
||||
i2c_unregister_device(at24->client[i]);
|
||||
for (i = 1; i < at24->num_addresses; i++)
|
||||
i2c_unregister_device(at24->client[i]);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
static struct i2c_board_info i2c_devs = {
|
||||
I2C_BOARD_INFO("24c64-ctc", 0x57),
|
||||
I2C_BOARD_INFO("24c64-ctc", 0x57),
|
||||
};
|
||||
|
||||
static struct i2c_adapter *adapter = NULL;
|
||||
@ -590,68 +533,70 @@ static struct i2c_client *client = NULL;
|
||||
|
||||
static int ctc_at24c64_init(void)
|
||||
{
|
||||
printk(KERN_ALERT "ctc_at24c64_init\n");
|
||||
printk(KERN_ALERT "ctc_at24c64_init\n");
|
||||
|
||||
adapter = i2c_get_adapter(0);
|
||||
if(adapter == NULL){
|
||||
printk(KERN_ALERT "i2c_get_adapter == NULL\n");
|
||||
return -1;
|
||||
}
|
||||
adapter = i2c_get_adapter(0);
|
||||
if(adapter == NULL){
|
||||
printk(KERN_ALERT "i2c_get_adapter == NULL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
client = i2c_new_device(adapter, &i2c_devs);
|
||||
if(client == NULL){
|
||||
printk(KERN_ALERT "i2c_new_device == NULL\n");
|
||||
i2c_put_adapter(adapter);
|
||||
adapter = NULL;
|
||||
return -1;
|
||||
}
|
||||
client = i2c_new_device(adapter, &i2c_devs);
|
||||
if(client == NULL){
|
||||
printk(KERN_ALERT "i2c_new_device == NULL\n");
|
||||
i2c_put_adapter(adapter);
|
||||
adapter = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ctc_at24c64_exit(void)
|
||||
{
|
||||
printk(KERN_ALERT "ctc_at24c64_exit\n");
|
||||
if(client){
|
||||
i2c_unregister_device(client);
|
||||
}
|
||||
if(adapter){
|
||||
i2c_put_adapter(adapter);
|
||||
}
|
||||
printk(KERN_ALERT "ctc_at24c64_exit\n");
|
||||
if(client){
|
||||
i2c_unregister_device(client);
|
||||
}
|
||||
if(adapter){
|
||||
i2c_put_adapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
static struct i2c_driver at24_ctc_driver = {
|
||||
.driver = {
|
||||
.name = "at24-ctc",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = at24_probe,
|
||||
.remove = at24_remove,
|
||||
.id_table = at24_ctc_ids,
|
||||
.driver = {
|
||||
.name = "at24-ctc",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = at24_probe,
|
||||
.remove = at24_remove,
|
||||
.id_table = at24_ctc_ids,
|
||||
};
|
||||
|
||||
static int __init at24_ctc_init(void)
|
||||
{
|
||||
if (!io_limit) {
|
||||
pr_err("at24_ctc: io_limit must not be 0!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!io_limit) {
|
||||
pr_err("at24_ctc: io_limit must not be 0!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
io_limit = rounddown_pow_of_two(io_limit);
|
||||
io_limit = rounddown_pow_of_two(io_limit);
|
||||
|
||||
ctc_at24c64_init();
|
||||
|
||||
return i2c_add_driver(&at24_ctc_driver);
|
||||
return i2c_add_driver(&at24_ctc_driver);
|
||||
}
|
||||
module_init(at24_ctc_init);
|
||||
|
||||
static void __exit at24_ctc_exit(void)
|
||||
{
|
||||
ctc_at24c64_exit();
|
||||
i2c_del_driver(&at24_ctc_driver);
|
||||
i2c_del_driver(&at24_ctc_driver);
|
||||
}
|
||||
module_exit(at24_ctc_exit);
|
||||
|
||||
MODULE_DESCRIPTION("Driver for most I2C EEPROMs");
|
||||
MODULE_AUTHOR("David Brownell and Wolfram Sang");
|
||||
MODULE_LICENSE("GPL");
|
||||
/* XXX */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@
|
||||
#endif
|
||||
#include "dal_kernel.h"
|
||||
#include "dal_mpool.h"
|
||||
|
||||
#include <linux/slab.h>
|
||||
MODULE_AUTHOR("Centec Networks Inc.");
|
||||
MODULE_DESCRIPTION("DAL kernel module");
|
||||
MODULE_LICENSE("GPL");
|
||||
@ -47,7 +47,9 @@ MODULE_PARM_DESC(dma_pool_size,
|
||||
|
||||
#define CTC_VENDOR_VID 0xc001
|
||||
#define CTC_HUMBER_DEVICE_ID 0x6048
|
||||
#define CTC_GOLDENGATE_DEVICE_ID 0xcb10
|
||||
#define CTC_GOLDENGATE_DEVICE_ID 0xc010
|
||||
#define CTC_PCIE_VENDOR_ID 0xcb10
|
||||
#define CTC_DUET2_DEVICE_ID 0x7148
|
||||
|
||||
#define MEM_MAP_RESERVE SetPageReserved
|
||||
#define MEM_MAP_UNRESERVE ClearPageReserved
|
||||
@ -82,7 +84,7 @@ typedef struct dal_kernel_dev_s
|
||||
uintptr logic_address;
|
||||
|
||||
/* Physical address */
|
||||
uintptr phys_address;
|
||||
unsigned long long phys_address;
|
||||
} dal_kern_dev_t;
|
||||
|
||||
typedef struct _dma_segment
|
||||
@ -126,8 +128,8 @@ static unsigned int* dma_virt_base[DAL_MAX_CHIP_NUM];
|
||||
#ifndef DMA_MEM_MODE_PLATFORM
|
||||
static unsigned int* dma_virt_base_tmp[DAL_MAX_CHIP_NUM];
|
||||
#endif
|
||||
static uintptr dma_phy_base[DAL_MAX_CHIP_NUM];
|
||||
static unsigned int dma_mem_size = 0x800000;
|
||||
static unsigned long long dma_phy_base[DAL_MAX_CHIP_NUM];
|
||||
static unsigned int dma_mem_size = 0xc00000;
|
||||
static unsigned int msi_irq_base[DAL_MAX_CHIP_NUM];
|
||||
static unsigned int msi_irq_num[DAL_MAX_CHIP_NUM];
|
||||
static unsigned int msi_used = 0;
|
||||
@ -141,7 +143,9 @@ MODULE_PARM_DESC(dal_debug, "Set debug level (default 0)");
|
||||
static struct pci_device_id dal_id_table[] =
|
||||
{
|
||||
{PCI_DEVICE(CTC_VENDOR_VID, CTC_GREATBELT_DEVICE_ID)},
|
||||
{PCI_DEVICE(0xcb10, 0xc010)},
|
||||
{PCI_DEVICE(CTC_PCIE_VENDOR_ID, CTC_GOLDENGATE_DEVICE_ID)},
|
||||
{PCI_DEVICE((CTC_PCIE_VENDOR_ID+1), (CTC_GOLDENGATE_DEVICE_ID+1))},
|
||||
{PCI_DEVICE(CTC_PCIE_VENDOR_ID, CTC_DUET2_DEVICE_ID)},
|
||||
{0, },
|
||||
};
|
||||
|
||||
@ -186,7 +190,11 @@ static struct file_operations dal_intr_fops[CTC_MAX_INTR_NUM] =
|
||||
.poll = linux_dal_poll7,
|
||||
},
|
||||
};
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
|
||||
#include <linux/slab.h>
|
||||
#define virt_to_bus virt_to_phys
|
||||
#define bus_to_virt phys_to_virt
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* macros
|
||||
*****************************************************************************/
|
||||
@ -450,9 +458,12 @@ dal_interrupt_register(unsigned int irq, int prio, void (* isr)(void*), void* da
|
||||
{
|
||||
if (irq == dal_isr[intr_num_tmp].irq)
|
||||
{
|
||||
dal_isr[intr_num_tmp].count++;
|
||||
printk("Interrupt irq %d register count %d.\n", irq, dal_isr[intr_num_tmp].count);
|
||||
return 0;
|
||||
if (0 == msi_used)
|
||||
{
|
||||
dal_isr[intr_num_tmp].count++;
|
||||
printk("Interrupt irq %d register count %d.\n", irq, dal_isr[intr_num_tmp].count);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if ((0 == dal_isr[intr_num_tmp].irq) && (CTC_MAX_INTR_NUM == intr_num))
|
||||
{
|
||||
@ -608,6 +619,7 @@ int
|
||||
dal_set_msi_cap(unsigned long arg)
|
||||
{
|
||||
int ret = 0;
|
||||
int index = 0;
|
||||
dal_msi_info_t msi_info;
|
||||
|
||||
if (copy_from_user(&msi_info, (void*)arg, sizeof(dal_msi_info_t)))
|
||||
@ -618,8 +630,21 @@ dal_set_msi_cap(unsigned long arg)
|
||||
printk("####dal_set_msi_cap lchip %d base %d num:%d\n", msi_info.lchip, msi_info.irq_base, msi_info.irq_num);
|
||||
if (msi_info.irq_num > 0)
|
||||
{
|
||||
msi_used = 1;
|
||||
ret = _dal_set_msi_enabe(msi_info.lchip, msi_info.irq_num);
|
||||
if (0 == msi_used)
|
||||
{
|
||||
msi_used = 1;
|
||||
ret = _dal_set_msi_enabe(msi_info.lchip, msi_info.irq_num);
|
||||
}
|
||||
else if ((1 == msi_used) && (msi_info.irq_num != msi_irq_num[msi_info.lchip]))
|
||||
{
|
||||
for (index = 0; index < msi_irq_num[msi_info.lchip]; index++)
|
||||
{
|
||||
dal_interrupt_unregister(msi_irq_base[msi_info.lchip]+index);
|
||||
}
|
||||
_dal_set_msi_disable(msi_info.lchip);
|
||||
msi_used = 1;
|
||||
ret = _dal_set_msi_enabe(msi_info.lchip, msi_info.irq_num);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1054,6 +1079,10 @@ int
|
||||
dal_create_irq_mapping(unsigned long arg)
|
||||
{
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
|
||||
|
||||
#ifndef NO_IRQ
|
||||
#define NO_IRQ (-1)
|
||||
#endif
|
||||
dal_irq_mapping_t irq_map;
|
||||
|
||||
if (copy_from_user(&irq_map, (void*)arg, sizeof(dal_irq_mapping_t)))
|
||||
@ -1086,7 +1115,7 @@ dal_pci_read(unsigned long arg)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
_dal_pci_read((unsigned char)cmdpara_chip.chip_id, (unsigned int)cmdpara_chip.reg_addr,
|
||||
_dal_pci_read((unsigned char)cmdpara_chip.lchip, (unsigned int)cmdpara_chip.reg_addr,
|
||||
(unsigned int*)(&(cmdpara_chip.value)));
|
||||
|
||||
if (copy_to_user((dal_chip_parm_t*)arg, (void*)&cmdpara_chip, sizeof(dal_chip_parm_t)))
|
||||
@ -1119,7 +1148,7 @@ dal_pci_write(unsigned long arg)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
_dal_pci_write((unsigned char)cmdpara_chip.chip_id, (unsigned int)cmdpara_chip.reg_addr,
|
||||
_dal_pci_write((unsigned char)cmdpara_chip.lchip, (unsigned int)cmdpara_chip.reg_addr,
|
||||
(unsigned int)cmdpara_chip.value);
|
||||
|
||||
return 0;
|
||||
@ -1158,7 +1187,7 @@ dal_user_read_pci_conf(unsigned long arg)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (dal_pci_conf_read(dal_cfg.chip_id, dal_cfg.offset, &dal_cfg.value))
|
||||
if (dal_pci_conf_read(dal_cfg.lchip, dal_cfg.offset, &dal_cfg.value))
|
||||
{
|
||||
printk("dal_pci_conf_read failed.\n");
|
||||
return -EFAULT;
|
||||
@ -1182,14 +1211,14 @@ dal_user_write_pci_conf(unsigned long arg)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return dal_pci_conf_write(dal_cfg.chip_id, dal_cfg.offset, dal_cfg.value);
|
||||
return dal_pci_conf_write(dal_cfg.lchip, dal_cfg.offset, dal_cfg.value);
|
||||
}
|
||||
|
||||
static int
|
||||
linux_get_device(unsigned long arg)
|
||||
{
|
||||
dal_user_dev_t user_dev;
|
||||
int chip_id = 0;
|
||||
int lchip = 0;
|
||||
|
||||
if (copy_from_user(&user_dev, (void*)arg, sizeof(user_dev)))
|
||||
{
|
||||
@ -1197,20 +1226,16 @@ linux_get_device(unsigned long arg)
|
||||
}
|
||||
|
||||
user_dev.chip_num = dal_chip_num;
|
||||
chip_id = user_dev.chip_id;
|
||||
lchip = user_dev.lchip;
|
||||
|
||||
if (chip_id < dal_chip_num)
|
||||
if (lchip < dal_chip_num)
|
||||
{
|
||||
user_dev.phy_base0 = (unsigned int)dal_dev[chip_id].phys_address;
|
||||
#ifdef PHYS_ADDR_IS_64BIT
|
||||
user_dev.phy_base1 = (unsigned int)(dal_dev[chip_id].phys_address >> 32);
|
||||
#else
|
||||
user_dev.phy_base1 = 0;
|
||||
#endif
|
||||
user_dev.phy_base0 = (unsigned int)dal_dev[lchip].phys_address;
|
||||
user_dev.phy_base1 = (unsigned int)(dal_dev[lchip].phys_address >> 32);
|
||||
|
||||
user_dev.bus_no = dal_dev[chip_id].pci_dev->bus->number;
|
||||
user_dev.dev_no = dal_dev[chip_id].pci_dev->device;
|
||||
user_dev.fun_no = dal_dev[chip_id].pci_dev->devfn;
|
||||
user_dev.bus_no = dal_dev[lchip].pci_dev->bus->number;
|
||||
user_dev.dev_no = dal_dev[lchip].pci_dev->device;
|
||||
user_dev.fun_no = dal_dev[lchip].pci_dev->devfn;
|
||||
}
|
||||
|
||||
if (copy_to_user((dal_user_dev_t*)arg, (void*)&user_dev, sizeof(user_dev)))
|
||||
@ -1248,11 +1273,7 @@ linux_get_dma_info(unsigned long arg)
|
||||
}
|
||||
|
||||
dma_para.phy_base = (unsigned int)dma_phy_base[dma_para.lchip];
|
||||
#ifdef PHYS_ADDR_IS_64BIT
|
||||
dma_para.phy_base_hi = dma_phy_base[dma_para.lchip] >> 32;
|
||||
#else
|
||||
dma_para.phy_base_hi = 0;
|
||||
#endif
|
||||
dma_para.size = dma_mem_size;
|
||||
|
||||
if (copy_to_user((dma_info_t*)arg, (void*)&dma_para, sizeof(dma_info_t)))
|
||||
@ -1340,10 +1361,10 @@ dal_cache_inval(unsigned long arg)
|
||||
|
||||
#if 0
|
||||
dma_sync_single_for_cpu(NULL, intr_para.ptr, intr_para.length, DMA_BIDIRECTIONAL);
|
||||
#endif
|
||||
|
||||
|
||||
dma_cache_sync(NULL, (void*)intr_para.ptr, intr_para.length, DMA_BIDIRECTIONAL);
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1363,10 +1384,10 @@ dal_cache_flush(unsigned long arg)
|
||||
|
||||
#if 0
|
||||
dma_sync_single_for_cpu(NULL, intr_para.ptr, intr_para.length, DMA_BIDIRECTIONAL);
|
||||
#endif
|
||||
|
||||
|
||||
dma_cache_sync(NULL, (void*)intr_para.ptr, intr_para.length, DMA_BIDIRECTIONAL);
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1378,31 +1399,30 @@ linux_dal_probe(struct pci_dev* pdev, const struct pci_device_id* id)
|
||||
int ret = 0;
|
||||
unsigned int temp = 0;
|
||||
unsigned int lchip = 0;
|
||||
unsigned int chip_id = 0;
|
||||
|
||||
printk(KERN_WARNING "********found dal device*****\n");
|
||||
|
||||
for (chip_id = 0; chip_id < DAL_MAX_CHIP_NUM; chip_id ++)
|
||||
for (lchip = 0; lchip < DAL_MAX_CHIP_NUM; lchip ++)
|
||||
{
|
||||
if (NULL == dal_dev[chip_id].pci_dev)
|
||||
if (NULL == dal_dev[lchip].pci_dev)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (chip_id >= DAL_MAX_CHIP_NUM)
|
||||
if (lchip >= DAL_MAX_CHIP_NUM)
|
||||
{
|
||||
printk("Exceed max local chip num\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dev = &dal_dev[chip_id];
|
||||
dev = &dal_dev[lchip];
|
||||
if (NULL == dev)
|
||||
{
|
||||
printk("Cannot obtain PCI resources\n");
|
||||
}
|
||||
|
||||
lchip = chip_id;
|
||||
lchip = lchip;
|
||||
dal_chip_num += 1;
|
||||
|
||||
dev->pci_dev = pdev;
|
||||
@ -1446,7 +1466,6 @@ linux_dal_probe(struct pci_dev* pdev, const struct pci_device_id* id)
|
||||
if (dma_mem_size)
|
||||
{
|
||||
dal_alloc_dma_pool(lchip, dma_mem_size);
|
||||
#ifdef PHYS_ADDR_IS_64BIT
|
||||
|
||||
/*add check Dma memory pool cannot cross 4G space*/
|
||||
if ((0==(dma_phy_base[lchip]>>32)) && (0!=((dma_phy_base[lchip]+dma_mem_size)>>32)))
|
||||
@ -1454,7 +1473,6 @@ linux_dal_probe(struct pci_dev* pdev, const struct pci_device_id* id)
|
||||
printk("Dma malloc memory cross 4G space!!!!!! \n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
printk(KERN_WARNING "linux_dal_probe end*****\n");
|
||||
@ -1465,12 +1483,12 @@ linux_dal_probe(struct pci_dev* pdev, const struct pci_device_id* id)
|
||||
void
|
||||
linux_dal_remove(struct pci_dev* pdev)
|
||||
{
|
||||
unsigned int chip_id = 0;
|
||||
unsigned int lchip = 0;
|
||||
unsigned int flag = 0;
|
||||
|
||||
for (chip_id = 0; chip_id < DAL_MAX_CHIP_NUM; chip_id ++)
|
||||
for (lchip = 0; lchip < DAL_MAX_CHIP_NUM; lchip ++)
|
||||
{
|
||||
if (pdev == dal_dev[chip_id].pci_dev)
|
||||
if (pdev == dal_dev[lchip].pci_dev)
|
||||
{
|
||||
flag = 1;
|
||||
break;
|
||||
@ -1479,11 +1497,11 @@ linux_dal_remove(struct pci_dev* pdev)
|
||||
|
||||
if (1 == flag)
|
||||
{
|
||||
dal_free_dma_pool(chip_id);
|
||||
dal_free_dma_pool(lchip);
|
||||
pci_release_regions(pdev);
|
||||
pci_disable_device(pdev);
|
||||
|
||||
dal_dev[chip_id].pci_dev = NULL;
|
||||
dal_dev[lchip].pci_dev = NULL;
|
||||
dal_chip_num--;
|
||||
}
|
||||
|
||||
@ -1496,7 +1514,7 @@ linux_dal_ioctl(struct file* file,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
#else
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 13))
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36))
|
||||
static int
|
||||
linux_dal_ioctl(struct file* file,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
@ -1812,3 +1830,4 @@ linux_dal_exit(void)
|
||||
module_init(linux_dal_init);
|
||||
module_exit(linux_dal_exit);
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ typedef unsigned int uintptr;
|
||||
#define DAL_ONE_MB (1024*1024)
|
||||
struct dal_chip_parm_s
|
||||
{
|
||||
unsigned int chip_id; /*tmp should be uint8*/
|
||||
unsigned int lchip; /*tmp should be uint8*/
|
||||
unsigned int fpga_id; /*tmp add*/
|
||||
unsigned int reg_addr;
|
||||
unsigned int value;
|
||||
@ -78,7 +78,7 @@ typedef struct dal_irq_mapping_s dal_irq_mapping_t;
|
||||
struct dal_user_dev_s
|
||||
{
|
||||
unsigned int chip_num; /*output: local chip number*/
|
||||
unsigned int chip_id; /*input: local chip id*/
|
||||
unsigned int lchip; /*input: local chip id*/
|
||||
unsigned int phy_base0; /* low 32bits physical base address */
|
||||
unsigned int phy_base1; /* high 32bits physical base address */
|
||||
unsigned int bus_no;
|
||||
@ -100,7 +100,7 @@ typedef struct dma_info_s dma_info_t;
|
||||
|
||||
struct dal_pci_cfg_ioctl_s
|
||||
{
|
||||
unsigned int chip_id; /* Device ID */
|
||||
unsigned int lchip; /* Device ID */
|
||||
unsigned int offset;
|
||||
unsigned int value;
|
||||
};
|
||||
@ -168,3 +168,4 @@ typedef enum dal_version_e dal_version_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#include "dal_mpool.h"
|
||||
|
||||
#ifdef __KERNEL__
|
||||
@ -27,6 +26,8 @@ static sal_mutex_t* dal_mpool_lock;
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
|
||||
|
||||
dal_mpool_mem_t* g_free_block_ptr = NULL;
|
||||
|
||||
/* System cache line size */
|
||||
@ -34,8 +35,9 @@ dal_mpool_mem_t* g_free_block_ptr = NULL;
|
||||
#define DAL_CACHE_LINE_BYTES 256
|
||||
#endif
|
||||
|
||||
static dal_mpool_mem_t* p_desc_pool = NULL;
|
||||
static dal_mpool_mem_t* p_data_pool = NULL;
|
||||
#define DAL_MAX_CHIP_NUM 32
|
||||
static dal_mpool_mem_t* p_desc_pool[DAL_MAX_CHIP_NUM] = {0};
|
||||
static dal_mpool_mem_t* p_data_pool[DAL_MAX_CHIP_NUM] = {0};
|
||||
|
||||
int
|
||||
dal_mpool_init(void)
|
||||
@ -74,7 +76,7 @@ _dal_mpool_create(void* base, int size, int type)
|
||||
}
|
||||
|
||||
dal_mpool_mem_t*
|
||||
dal_mpool_create(void* base, int size)
|
||||
dal_mpool_create(unsigned char lchip, void* base, int size)
|
||||
{
|
||||
dal_mpool_mem_t* head = NULL;
|
||||
int mod = (int)(((unsigned long)base) & (DAL_CACHE_LINE_BYTES - 1));
|
||||
@ -98,8 +100,8 @@ dal_mpool_create(void* base, int size)
|
||||
}
|
||||
|
||||
/* init for desc linkptr */
|
||||
p_desc_pool = _dal_mpool_create(base, DAL_MPOOL_MAX_DESX_SIZE, DAL_MPOOL_TYPE_DESC);
|
||||
if (NULL == p_desc_pool)
|
||||
p_desc_pool[lchip] = _dal_mpool_create(base, DAL_MPOOL_MAX_DESX_SIZE, DAL_MPOOL_TYPE_DESC);
|
||||
if (NULL == p_desc_pool[lchip])
|
||||
{
|
||||
MPOOL_UNLOCK();
|
||||
DAL_FREE(head->next);
|
||||
@ -108,14 +110,14 @@ dal_mpool_create(void* base, int size)
|
||||
}
|
||||
|
||||
/* init for data linkptr */
|
||||
p_data_pool = _dal_mpool_create(((char*)base+DAL_MPOOL_MAX_DESX_SIZE), (size - DAL_MPOOL_MAX_DESX_SIZE), DAL_MPOOL_TYPE_DATA);
|
||||
if (NULL == p_data_pool)
|
||||
p_data_pool[lchip] = _dal_mpool_create(((char*)base+DAL_MPOOL_MAX_DESX_SIZE), (size - DAL_MPOOL_MAX_DESX_SIZE), DAL_MPOOL_TYPE_DATA);
|
||||
if (NULL == p_data_pool[lchip])
|
||||
{
|
||||
MPOOL_UNLOCK();
|
||||
DAL_FREE(head->next);
|
||||
DAL_FREE(head);
|
||||
DAL_FREE(p_desc_pool->next);
|
||||
DAL_FREE(p_desc_pool);
|
||||
DAL_FREE(p_desc_pool[lchip]->next);
|
||||
DAL_FREE(p_desc_pool[lchip]);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -160,7 +162,7 @@ _dal_mpool_alloc_comon(dal_mpool_mem_t* ptr, int size, int type)
|
||||
}
|
||||
|
||||
void*
|
||||
dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type)
|
||||
dal_mpool_alloc(unsigned char lchip, dal_mpool_mem_t* pool, int size, int type)
|
||||
{
|
||||
dal_mpool_mem_t* ptr = NULL;
|
||||
dal_mpool_mem_t* new_ptr = NULL;
|
||||
@ -186,7 +188,7 @@ dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type)
|
||||
}
|
||||
break;
|
||||
case DAL_MPOOL_TYPE_DESC:
|
||||
ptr = p_desc_pool;
|
||||
ptr = p_desc_pool[lchip];
|
||||
new_ptr = _dal_mpool_alloc_comon(ptr, size, type);
|
||||
if (NULL == new_ptr)
|
||||
{
|
||||
@ -195,7 +197,7 @@ dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type)
|
||||
}
|
||||
break;
|
||||
case DAL_MPOOL_TYPE_DATA:
|
||||
ptr = p_data_pool;
|
||||
ptr = p_data_pool[lchip];
|
||||
new_ptr = _dal_mpool_alloc_comon(ptr, size, type);
|
||||
if (NULL == new_ptr)
|
||||
{
|
||||
@ -210,6 +212,10 @@ dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type)
|
||||
}
|
||||
|
||||
MPOOL_UNLOCK();
|
||||
if( NULL == new_ptr )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new_ptr->address;
|
||||
}
|
||||
@ -242,7 +248,7 @@ _dal_mpool_free(dal_mpool_mem_t* ptr, void* addr, int type)
|
||||
}
|
||||
|
||||
void
|
||||
dal_mpool_free(dal_mpool_mem_t* pool, void* addr)
|
||||
dal_mpool_free(unsigned char lchip, dal_mpool_mem_t* pool, void* addr)
|
||||
{
|
||||
dal_mpool_mem_t* ptr = pool;
|
||||
|
||||
@ -255,11 +261,11 @@ dal_mpool_free(dal_mpool_mem_t* pool, void* addr)
|
||||
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_USELESS);
|
||||
break;
|
||||
case DAL_MPOOL_TYPE_DESC:
|
||||
ptr = p_desc_pool;
|
||||
ptr = p_desc_pool[lchip];
|
||||
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_DESC);
|
||||
break;
|
||||
case DAL_MPOOL_TYPE_DATA:
|
||||
ptr = p_data_pool;
|
||||
ptr = p_data_pool[lchip];
|
||||
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_DATA);
|
||||
break;
|
||||
default:
|
||||
@ -271,7 +277,7 @@ dal_mpool_free(dal_mpool_mem_t* pool, void* addr)
|
||||
}
|
||||
|
||||
int
|
||||
dal_mpool_destroy(dal_mpool_mem_t* pool)
|
||||
dal_mpool_destroy(unsigned char lchip, dal_mpool_mem_t* pool)
|
||||
{
|
||||
dal_mpool_mem_t* ptr, * next;
|
||||
|
||||
@ -283,13 +289,13 @@ dal_mpool_destroy(dal_mpool_mem_t* pool)
|
||||
DAL_FREE(ptr);
|
||||
}
|
||||
|
||||
for (ptr = p_desc_pool; ptr; ptr = next)
|
||||
for (ptr = p_desc_pool[lchip]; ptr; ptr = next)
|
||||
{
|
||||
next = ptr->next;
|
||||
DAL_FREE(ptr);
|
||||
}
|
||||
|
||||
for (ptr = p_data_pool; ptr; ptr = next)
|
||||
for (ptr = p_data_pool[lchip]; ptr; ptr = next)
|
||||
{
|
||||
next = ptr->next;
|
||||
DAL_FREE(ptr);
|
||||
@ -341,3 +347,4 @@ dal_mpool_debug(dal_mpool_mem_t* pool)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,16 +47,16 @@ extern int
|
||||
dal_mpool_init(void);
|
||||
|
||||
extern dal_mpool_mem_t*
|
||||
dal_mpool_create(void* base_ptr, int size);
|
||||
dal_mpool_create(unsigned char lchip, void* base_ptr, int size);
|
||||
|
||||
extern void*
|
||||
dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type);
|
||||
dal_mpool_alloc(unsigned char lchip, dal_mpool_mem_t* pool, int size, int type);
|
||||
|
||||
extern void
|
||||
dal_mpool_free(dal_mpool_mem_t* pool, void* addr);
|
||||
dal_mpool_free(unsigned char lchip, dal_mpool_mem_t* pool, void* addr);
|
||||
|
||||
extern int
|
||||
dal_mpool_destroy(dal_mpool_mem_t* pool);
|
||||
dal_mpool_destroy(unsigned char lchip, dal_mpool_mem_t* pool);
|
||||
|
||||
extern int
|
||||
dal_mpool_usage(dal_mpool_mem_t* pool, int type);
|
||||
@ -69,3 +69,4 @@ dal_mpool_debug(dal_mpool_mem_t* pool);
|
||||
|
||||
#endif /* !_DMA_MPOOL_H */
|
||||
|
||||
|
||||
|
@ -19,16 +19,58 @@ init_devnum() {
|
||||
init_devnum
|
||||
|
||||
if [ "$1" == "init" ]; then
|
||||
#install drivers and dependencies
|
||||
depmod -a
|
||||
modprobe i2c-i801
|
||||
modprobe i2c-dev
|
||||
modprobe i2c-mux
|
||||
modprobe i2c-smbus
|
||||
modprobe i2c-mux-pca954x force_deselect_on_exit=1
|
||||
modprobe centec_e582_48x2q4z_platform
|
||||
i2cset -y 0 0x58 0x8 0x3f
|
||||
modprobe lm77
|
||||
modprobe tun
|
||||
modprobe dal
|
||||
modprobe centec_at24c64
|
||||
modprobe centec_e582_48x2q4z_platform
|
||||
i2cset -y 15 0x21 0x18 0x0
|
||||
i2cset -y 15 0x21 0x19 0x0
|
||||
i2cset -y 15 0x21 0x1a 0xff
|
||||
i2cset -y 15 0x21 0x1b 0xff
|
||||
i2cset -y 15 0x21 0x1c 0xff
|
||||
i2cset -y 15 0x21 0x8 0x0
|
||||
i2cset -y 15 0x21 0x9 0x0
|
||||
i2cset -y 15 0x22 0x18 0xff
|
||||
i2cset -y 15 0x22 0x19 0x0
|
||||
i2cset -y 15 0x22 0x1a 0x0
|
||||
i2cset -y 15 0x22 0x1b 0xff
|
||||
i2cset -y 15 0x22 0x1c 0xff
|
||||
i2cset -y 15 0x22 0x9 0x0
|
||||
i2cset -y 15 0x22 0xa 0x0
|
||||
i2cset -y 16 0x21 0x18 0x0
|
||||
i2cset -y 16 0x21 0x19 0x0
|
||||
i2cset -y 16 0x21 0x1a 0xff
|
||||
i2cset -y 16 0x21 0x1b 0xff
|
||||
i2cset -y 16 0x21 0x1c 0xff
|
||||
i2cset -y 16 0x21 0x8 0x0
|
||||
i2cset -y 16 0x21 0x9 0x0
|
||||
i2cset -y 17 0x22 0x18 0xff
|
||||
i2cset -y 17 0x22 0x19 0x0
|
||||
i2cset -y 17 0x22 0x1a 0xff
|
||||
i2cset -y 17 0x22 0x1b 0x0
|
||||
i2cset -y 17 0x22 0x1c 0xff
|
||||
i2cset -y 17 0x22 0x9 0x0
|
||||
i2cset -y 17 0x22 0xb 0x0c
|
||||
|
||||
#start platform monitor
|
||||
rm -rf /usr/bin/platform_monitor
|
||||
ln -s /usr/bin/48x2q4z_platform_monitor.py /usr/bin/platform_monitor
|
||||
python /usr/bin/platform_monitor &
|
||||
elif [ "$1" == "deinit" ]; then
|
||||
kill -9 $(pidof platform_monitor) > /dev/null 2>&1
|
||||
rm -rf /usr/bin/platform_monitor
|
||||
modprobe -r centec_e582_48x2q4z_platform
|
||||
modprobe -r centec_at24c64
|
||||
modprobe -r dal
|
||||
modprobe -r centec_e582_48x2q4z_platform
|
||||
modprobe -r i2c-mux-pca954x
|
||||
modprobe -r i2c-dev
|
||||
else
|
||||
|
@ -0,0 +1,217 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Centec
|
||||
#
|
||||
# Module contains an implementation of sfp presence scan logic
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
try:
|
||||
import os
|
||||
import os.path
|
||||
import threading
|
||||
import time
|
||||
import logging
|
||||
import struct
|
||||
import syslog
|
||||
import swsssdk
|
||||
from socket import *
|
||||
from select import *
|
||||
except ImportError, e:
|
||||
raise ImportError(str(e) + " - required module not found")
|
||||
|
||||
|
||||
def DBG_PRINT(str):
|
||||
syslog.openlog("centec-pmon")
|
||||
syslog.syslog(syslog.LOG_INFO, str)
|
||||
syslog.closelog()
|
||||
|
||||
PORT_NUMBER = (48+6)
|
||||
|
||||
class PlatformMonitor:
|
||||
|
||||
"""init board platform default config"""
|
||||
def __init__(self):
|
||||
"""[ctlid, slavedevid]"""
|
||||
self.fiber_mapping = [(0, 0)] # res
|
||||
self.fiber_mapping.extend([(1, 7), (1, 6), (1, 5), (1, 4), (1, 3), (1, 2), (1, 1), (1, 0)]) # panel port 1~8
|
||||
self.fiber_mapping.extend([(1, 15), (1, 14), (1, 13), (1, 12), (1, 11), (1, 10), (1, 9), (1, 8)]) # panel port 9~16
|
||||
self.fiber_mapping.extend([(1, 19), (1, 17), (1, 16), (1, 18), (0, 7), (0, 6), (0, 5), (0, 4)]) # panel port 17~24
|
||||
self.fiber_mapping.extend([(0, 3), (0, 2), (0, 1), (0, 0), (0, 15), (0, 14), (0, 13), (0, 12)]) # panel port 25~32
|
||||
self.fiber_mapping.extend([(0, 11), (0, 10), (0, 9), (0, 8), (0, 23), (0, 22), (0, 21), (0, 20)]) # panel port 33~40
|
||||
self.fiber_mapping.extend([(0, 19), (0, 18), (0, 17), (0, 16), (0, 31), (0, 26), (0, 29), (0, 27)]) # panel port 41~48
|
||||
self.fiber_mapping.extend([(0, 24), (0, 25), (1, 23), (1, 22), (1, 21), (1, 20)]) # panel port 49~54
|
||||
|
||||
self.udpClient = socket(AF_INET, SOCK_DGRAM)
|
||||
self.sfp_present = [0]*(PORT_NUMBER+1)
|
||||
self.sfp_enable = [0]*(PORT_NUMBER+1)
|
||||
self.f_sfp_present = "/sys/class/sfp/sfp{}/sfp_presence"
|
||||
self.f_sfp_enable = "/sys/class/sfp/sfp{}/sfp_enable"
|
||||
self.sfp_scan_timer = 0
|
||||
|
||||
def is_qsfp(self, port):
|
||||
if port <= 48:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def get_sfp_present(self, port):
|
||||
with open(self.f_sfp_present.format(port), 'r') as sfp_file:
|
||||
return int(sfp_file.read())
|
||||
|
||||
def set_sfp_present(self, port, present):
|
||||
self.sfp_present[port] = present
|
||||
|
||||
def set_sfp_enable(self, port, enable):
|
||||
if self.is_qsfp(port):
|
||||
if enable:
|
||||
with open(self.f_sfp_enable.format(port), 'w') as sfp_file:
|
||||
sfp_file.write("1")
|
||||
self.sfp_enable[port] = 1
|
||||
else:
|
||||
with open(self.f_sfp_enable.format(port), 'w') as sfp_file:
|
||||
sfp_file.write("0")
|
||||
self.sfp_enable[port] = 0
|
||||
else:
|
||||
(ctlid, devid) = self.fiber_mapping[port]
|
||||
req = struct.pack('=HHHBBHIBBBBI', 0, 9, 16, ctlid, devid, 0x50, 0, 0x56, 1, 0xf, 0, 1)
|
||||
self.udpClient.sendto(req, ('localhost', 8101))
|
||||
rsp, addr = self.udpClient.recvfrom(1024)
|
||||
rsp_data = struct.unpack('=HHHBBHIBBBBIi512B', rsp)
|
||||
enable_v = rsp_data[13]
|
||||
if enable:
|
||||
enable_v &= 0xf0
|
||||
else:
|
||||
enable_v |= 0x0f
|
||||
data = struct.pack('=HHHBBHBBBB', 0, 11, 8, ctlid, 0x56, 0x50, devid, enable_v, 0xf, 0)
|
||||
self.udpClient.sendto(data, ('localhost', 8101))
|
||||
DBG_PRINT("set sfp{} to {}".format(port, ("enable" if enable else "disable")))
|
||||
|
||||
def initialize_configdb(self):
|
||||
try:
|
||||
f_mac = os.popen('ip link show eth0 | grep ether | awk \'{print $2}\'')
|
||||
mac_addr = f_mac.read(17)
|
||||
last_byte = mac_addr[-2:]
|
||||
aligned_last_byte = format(int(int(str(last_byte), 16) + 1), '02x')
|
||||
mac_addr = mac_addr[:-2] + aligned_last_byte
|
||||
DBG_PRINT("start connect swss config-db to set device mac-address")
|
||||
swss = swsssdk.SonicV2Connector()
|
||||
swss.connect(swss.CONFIG_DB)
|
||||
swss.set(swss.CONFIG_DB, "DEVICE_METADATA|localhost", 'mac', mac_addr)
|
||||
mac_addr = swss.get(swss.CONFIG_DB, "DEVICE_METADATA|localhost", 'mac')
|
||||
DBG_PRINT("set device mac-address: %s" % mac_addr)
|
||||
except IOError as e:
|
||||
DBG_PRINT(str(e))
|
||||
|
||||
def initialize_rpc(self):
|
||||
while True:
|
||||
try:
|
||||
r_sel = [self.udpClient]
|
||||
echo_req = struct.pack('=HHH', 0, 1, 0)
|
||||
self.udpClient.sendto(echo_req, ('localhost', 8101))
|
||||
result = select(r_sel, [], [], 1)
|
||||
if self.udpClient in result[0]:
|
||||
echo_rsp, srv_addr = self.udpClient.recvfrom(1024)
|
||||
if echo_rsp:
|
||||
break
|
||||
DBG_PRINT("connect to sdk rpc server timeout, try again.")
|
||||
except IOError as e:
|
||||
DBG_PRINT(str(e))
|
||||
|
||||
DBG_PRINT("connect to sdk rpc server success.")
|
||||
|
||||
def initialize_gpio(self):
|
||||
# set gpio 1,2,3,4,5,6,7,8 output mode
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 1, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 2, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 3, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 4, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 5, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 6, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 7, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 1, 8, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
# set gpio 1,2,3,4,5,6,7,8 output 0 to reset i2c bridge
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 1, 0)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 2, 0)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 3, 0)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 4, 0)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 5, 0)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 6, 0)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 7, 0)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 8, 0)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
# set gpio 1,2,3,4,5,6,7,8 output 1 to release i2c bridge
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 1, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 2, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 3, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 4, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 5, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 6, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 7, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
gpio_init = struct.pack('=HHHBBB', 0, 13, 3, 2, 8, 1)
|
||||
self.udpClient.sendto(gpio_init, ('localhost', 8101))
|
||||
DBG_PRINT("config ctc chip gpio done.")
|
||||
|
||||
def initialize_sfp(self):
|
||||
try:
|
||||
for port in range(1, PORT_NUMBER+1):
|
||||
if self.get_sfp_present(port):
|
||||
self.set_sfp_present(port, 1)
|
||||
self.set_sfp_enable(port, 1)
|
||||
else:
|
||||
self.set_sfp_present(port, 0)
|
||||
self.set_sfp_enable(port, 0)
|
||||
except IOError as e:
|
||||
DBG_PRINT(str(e))
|
||||
|
||||
def initialize(self):
|
||||
DBG_PRINT("start connect to sdk rpc server.")
|
||||
|
||||
self.initialize_configdb()
|
||||
self.initialize_rpc()
|
||||
self.initialize_gpio()
|
||||
self.initialize_sfp()
|
||||
|
||||
def sfp_scan(self):
|
||||
try:
|
||||
for port in range(1, PORT_NUMBER+1):
|
||||
cur_present = self.get_sfp_present(port)
|
||||
if self.sfp_present[port] != cur_present:
|
||||
self.set_sfp_present(port, cur_present)
|
||||
self.set_sfp_enable(port, cur_present)
|
||||
except IOError as e:
|
||||
DBG_PRINT(str(e))
|
||||
|
||||
def start(self):
|
||||
while True:
|
||||
self.sfp_scan()
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
monitor = PlatformMonitor()
|
||||
monitor.initialize()
|
||||
monitor.start()
|
||||
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Centec e582 48x2q4z platform modules
|
||||
After=local-fs.target
|
||||
Before=pmon.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=-/etc/init.d/platform-modules-e582-48x2q4z start
|
||||
ExecStop=-/etc/init.d/platform-modules-e582-48x2q4z stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -13,274 +13,274 @@
|
||||
"VLAN": {},
|
||||
"PORT": {
|
||||
"Ethernet1": {
|
||||
"alias": "Ethernet1",
|
||||
"lanes": "4",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-1",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet2": {
|
||||
"alias": "Ethernet2",
|
||||
"lanes": "5",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-2",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet3": {
|
||||
"alias": "Ethernet3",
|
||||
"lanes": "6",
|
||||
"speed": "1000"
|
||||
"Ethernet3": {
|
||||
"alias": "eth-0-3",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet4": {
|
||||
"alias": "Ethernet4",
|
||||
"lanes": "8",
|
||||
"speed": "1000"
|
||||
"Ethernet4": {
|
||||
"alias": "eth-0-4",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet5": {
|
||||
"alias": "Ethernet5",
|
||||
"lanes": "9",
|
||||
"speed": "1000"
|
||||
"Ethernet5": {
|
||||
"alias": "eth-0-5",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet6": {
|
||||
"alias": "Ethernet6",
|
||||
"lanes": "10",
|
||||
"speed": "1000"
|
||||
"Ethernet6": {
|
||||
"alias": "eth-0-6",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet7": {
|
||||
"alias": "Ethernet7",
|
||||
"lanes": "12",
|
||||
"speed": "1000"
|
||||
"Ethernet7": {
|
||||
"alias": "eth-0-7",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet8": {
|
||||
"alias": "Ethernet8",
|
||||
"lanes": "13",
|
||||
"speed": "1000"
|
||||
"Ethernet8": {
|
||||
"alias": "eth-0-8",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet9": {
|
||||
"alias": "Ethernet9",
|
||||
"lanes": "14",
|
||||
"speed": "1000"
|
||||
"Ethernet9": {
|
||||
"alias": "eth-0-9",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet10": {
|
||||
"alias": "Ethernet10",
|
||||
"lanes": "16",
|
||||
"speed": "1000"
|
||||
"Ethernet10": {
|
||||
"alias": "eth-0-10",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet11": {
|
||||
"alias": "Ethernet11",
|
||||
"lanes": "17",
|
||||
"speed": "1000"
|
||||
"Ethernet11": {
|
||||
"alias": "eth-0-11",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet12": {
|
||||
"alias": "Ethernet12",
|
||||
"lanes": "18",
|
||||
"speed": "1000"
|
||||
"Ethernet12": {
|
||||
"alias": "eth-0-12",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet13": {
|
||||
"alias": "Ethernet13",
|
||||
"lanes": "20",
|
||||
"speed": "10000"
|
||||
"Ethernet13": {
|
||||
"alias": "eth-0-13",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet14": {
|
||||
"alias": "Ethernet14",
|
||||
"lanes": "21",
|
||||
"speed": "10000"
|
||||
"Ethernet14": {
|
||||
"alias": "eth-0-14",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet15": {
|
||||
"alias": "Ethernet15",
|
||||
"lanes": "22",
|
||||
"speed": "10000"
|
||||
"Ethernet15": {
|
||||
"alias": "eth-0-15",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet16": {
|
||||
"alias": "Ethernet16",
|
||||
"lanes": "24",
|
||||
"speed": "10000"
|
||||
"Ethernet16": {
|
||||
"alias": "eth-0-16",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet17": {
|
||||
"alias": "Ethernet17",
|
||||
"lanes": "25",
|
||||
"speed": "10000"
|
||||
"Ethernet17": {
|
||||
"alias": "eth-0-17",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet18": {
|
||||
"alias": "Ethernet18",
|
||||
"lanes": "26",
|
||||
"speed": "10000"
|
||||
"Ethernet18": {
|
||||
"alias": "eth-0-18",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet19": {
|
||||
"alias": "Ethernet19",
|
||||
"lanes": "28",
|
||||
"speed": "10000"
|
||||
"Ethernet19": {
|
||||
"alias": "eth-0-19",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet20": {
|
||||
"alias": "Ethernet20",
|
||||
"lanes": "30",
|
||||
"speed": "10000"
|
||||
"Ethernet20": {
|
||||
"alias": "eth-0-20",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet21": {
|
||||
"alias": "Ethernet21",
|
||||
"lanes": "31",
|
||||
"speed": "10000"
|
||||
"Ethernet21": {
|
||||
"alias": "eth-0-21",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet22": {
|
||||
"alias": "Ethernet22",
|
||||
"lanes": "32",
|
||||
"speed": "10000"
|
||||
"Ethernet22": {
|
||||
"alias": "eth-0-22",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet23": {
|
||||
"alias": "Ethernet23",
|
||||
"lanes": "34",
|
||||
"speed": "10000"
|
||||
"Ethernet23": {
|
||||
"alias": "eth-0-23",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet24": {
|
||||
"alias": "Ethernet24",
|
||||
"lanes": "35",
|
||||
"speed": "10000"
|
||||
"Ethernet24": {
|
||||
"alias": "eth-0-24",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet25": {
|
||||
"alias": "Ethernet25",
|
||||
"lanes": "40",
|
||||
"speed": "10000"
|
||||
"Ethernet25": {
|
||||
"alias": "eth-0-25",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet26": {
|
||||
"alias": "Ethernet26",
|
||||
"lanes": "41",
|
||||
"speed": "10000"
|
||||
"Ethernet26": {
|
||||
"alias": "eth-0-26",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet27": {
|
||||
"alias": "Ethernet27",
|
||||
"lanes": "43",
|
||||
"speed": "10000"
|
||||
"Ethernet27": {
|
||||
"alias": "eth-0-27",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet28": {
|
||||
"alias": "Ethernet28",
|
||||
"lanes": "36",
|
||||
"speed": "10000"
|
||||
"Ethernet28": {
|
||||
"alias": "eth-0-28",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet29": {
|
||||
"alias": "Ethernet29",
|
||||
"lanes": "37",
|
||||
"speed": "10000"
|
||||
"Ethernet29": {
|
||||
"alias": "eth-0-29",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet30": {
|
||||
"alias": "Ethernet30",
|
||||
"lanes": "39",
|
||||
"speed": "10000"
|
||||
"Ethernet30": {
|
||||
"alias": "eth-0-30",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet31": {
|
||||
"alias": "Ethernet31",
|
||||
"lanes": "44",
|
||||
"speed": "10000"
|
||||
"Ethernet31": {
|
||||
"alias": "eth-0-31",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet32": {
|
||||
"alias": "Ethernet32",
|
||||
"lanes": "45",
|
||||
"speed": "10000"
|
||||
"Ethernet32": {
|
||||
"alias": "eth-0-32",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet33": {
|
||||
"alias": "Ethernet33",
|
||||
"lanes": "46",
|
||||
"speed": "10000"
|
||||
"Ethernet33": {
|
||||
"alias": "eth-0-33",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet34": {
|
||||
"alias": "Ethernet34",
|
||||
"lanes": "47",
|
||||
"speed": "10000"
|
||||
"Ethernet34": {
|
||||
"alias": "eth-0-34",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet35": {
|
||||
"alias": "Ethernet35",
|
||||
"lanes": "80",
|
||||
"speed": "10000"
|
||||
"Ethernet35": {
|
||||
"alias": "eth-0-35",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet36": {
|
||||
"alias": "Ethernet36",
|
||||
"lanes": "81",
|
||||
"speed": "10000"
|
||||
"Ethernet36": {
|
||||
"alias": "eth-0-36",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet37": {
|
||||
"alias": "Ethernet37",
|
||||
"lanes": "82",
|
||||
"speed": "10000"
|
||||
"Ethernet37": {
|
||||
"alias": "eth-0-37",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet38": {
|
||||
"alias": "Ethernet38",
|
||||
"lanes": "88",
|
||||
"speed": "10000"
|
||||
"Ethernet38": {
|
||||
"alias": "eth-0-38",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet39": {
|
||||
"alias": "Ethernet39",
|
||||
"lanes": "89",
|
||||
"speed": "10000"
|
||||
"Ethernet39": {
|
||||
"alias": "eth-0-39",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet40": {
|
||||
"alias": "Ethernet40",
|
||||
"lanes": "90",
|
||||
"speed": "10000"
|
||||
"Ethernet40": {
|
||||
"alias": "eth-0-40",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet41": {
|
||||
"alias": "Ethernet41",
|
||||
"lanes": "84",
|
||||
"speed": "10000"
|
||||
"Ethernet41": {
|
||||
"alias": "eth-0-41",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet42": {
|
||||
"alias": "Ethernet42",
|
||||
"lanes": "85",
|
||||
"speed": "10000"
|
||||
"Ethernet42": {
|
||||
"alias": "eth-0-42",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet43": {
|
||||
"alias": "Ethernet43",
|
||||
"lanes": "86",
|
||||
"speed": "10000"
|
||||
"Ethernet43": {
|
||||
"alias": "eth-0-43",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet44": {
|
||||
"alias": "Ethernet44",
|
||||
"lanes": "87",
|
||||
"speed": "10000"
|
||||
"Ethernet44": {
|
||||
"alias": "eth-0-44",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet45": {
|
||||
"alias": "Ethernet45",
|
||||
"lanes": "92",
|
||||
"speed": "10000"
|
||||
"Ethernet45": {
|
||||
"alias": "eth-0-45",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet46": {
|
||||
"alias": "Ethernet46",
|
||||
"lanes": "93",
|
||||
"speed": "10000"
|
||||
"Ethernet46": {
|
||||
"alias": "eth-0-46",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet47": {
|
||||
"alias": "Ethernet47",
|
||||
"lanes": "94",
|
||||
"speed": "10000"
|
||||
"Ethernet47": {
|
||||
"alias": "eth-0-47",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet48": {
|
||||
"alias": "Ethernet48",
|
||||
"lanes": "95",
|
||||
"speed": "10000"
|
||||
"Ethernet48": {
|
||||
"alias": "eth-0-48",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet49": {
|
||||
"alias": "Ethernet49",
|
||||
"lanes": "52,53,54,55",
|
||||
"speed": "40000"
|
||||
"Ethernet49": {
|
||||
"alias": "eth-0-49",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet50": {
|
||||
"alias": "Ethernet50",
|
||||
"lanes": "56,57,58,59",
|
||||
"speed": "40000"
|
||||
"Ethernet50": {
|
||||
"alias": "eth-0-50",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet51": {
|
||||
"alias": "Ethernet51",
|
||||
"lanes": "60,61,62,63",
|
||||
"speed": "40000"
|
||||
"Ethernet51": {
|
||||
"alias": "eth-0-51",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet52": {
|
||||
"alias": "Ethernet52",
|
||||
"lanes": "68,69,70,71",
|
||||
"speed": "40000"
|
||||
"Ethernet52": {
|
||||
"alias": "eth-0-52",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet53": {
|
||||
"alias": "Ethernet53",
|
||||
"lanes": "72,73,74,75",
|
||||
"speed": "40000"
|
||||
"Ethernet53": {
|
||||
"alias": "eth-0-53",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet54": {
|
||||
"alias": "Ethernet54",
|
||||
"lanes": "76,77,78,79",
|
||||
"speed": "40000"
|
||||
"alias": "eth-0-54",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
}
|
||||
},
|
||||
"SYSLOG_SERVER": {},
|
||||
@ -300,4 +300,3 @@
|
||||
"Ethernet4|192.168.4.1/24": {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,274 +112,274 @@
|
||||
},
|
||||
"PORT": {
|
||||
"Ethernet1": {
|
||||
"alias": "Ethernet1",
|
||||
"lanes": "4",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-1",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet2": {
|
||||
"alias": "Ethernet2",
|
||||
"lanes": "5",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-2",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet3": {
|
||||
"alias": "Ethernet3",
|
||||
"lanes": "6",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-3",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet4": {
|
||||
"alias": "Ethernet4",
|
||||
"lanes": "8",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-4",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet5": {
|
||||
"alias": "Ethernet5",
|
||||
"lanes": "9",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-5",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet6": {
|
||||
"alias": "Ethernet6",
|
||||
"lanes": "10",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-6",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet7": {
|
||||
"alias": "Ethernet7",
|
||||
"lanes": "12",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-7",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet8": {
|
||||
"alias": "Ethernet8",
|
||||
"lanes": "13",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-8",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet9": {
|
||||
"alias": "Ethernet9",
|
||||
"lanes": "14",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-9",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet10": {
|
||||
"alias": "Ethernet10",
|
||||
"lanes": "16",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-10",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet11": {
|
||||
"alias": "Ethernet11",
|
||||
"lanes": "17",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-11",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet12": {
|
||||
"alias": "Ethernet12",
|
||||
"lanes": "18",
|
||||
"speed": "1000"
|
||||
"alias": "eth-0-12",
|
||||
"speed": "1000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet13": {
|
||||
"alias": "Ethernet13",
|
||||
"lanes": "20",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-13",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet14": {
|
||||
"alias": "Ethernet14",
|
||||
"lanes": "21",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-14",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet15": {
|
||||
"alias": "Ethernet15",
|
||||
"lanes": "22",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-15",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet16": {
|
||||
"alias": "Ethernet16",
|
||||
"lanes": "24",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-16",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet17": {
|
||||
"alias": "Ethernet17",
|
||||
"lanes": "25",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-17",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet18": {
|
||||
"alias": "Ethernet18",
|
||||
"lanes": "26",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-18",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet19": {
|
||||
"alias": "Ethernet19",
|
||||
"lanes": "28",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-19",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet20": {
|
||||
"alias": "Ethernet20",
|
||||
"lanes": "30",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-20",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet21": {
|
||||
"alias": "Ethernet21",
|
||||
"lanes": "31",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-21",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet22": {
|
||||
"alias": "Ethernet22",
|
||||
"lanes": "32",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-22",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet23": {
|
||||
"alias": "Ethernet23",
|
||||
"lanes": "34",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-23",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet24": {
|
||||
"alias": "Ethernet24",
|
||||
"lanes": "35",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-24",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet25": {
|
||||
"alias": "Ethernet25",
|
||||
"lanes": "40",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-25",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet26": {
|
||||
"alias": "Ethernet26",
|
||||
"lanes": "41",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-26",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet27": {
|
||||
"alias": "Ethernet27",
|
||||
"lanes": "43",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-27",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet28": {
|
||||
"alias": "Ethernet28",
|
||||
"lanes": "36",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-28",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet29": {
|
||||
"alias": "Ethernet29",
|
||||
"lanes": "37",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-29",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet30": {
|
||||
"alias": "Ethernet30",
|
||||
"lanes": "39",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-30",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet31": {
|
||||
"alias": "Ethernet31",
|
||||
"lanes": "44",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-31",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet32": {
|
||||
"alias": "Ethernet32",
|
||||
"lanes": "45",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-32",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet33": {
|
||||
"alias": "Ethernet33",
|
||||
"lanes": "46",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-33",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet34": {
|
||||
"alias": "Ethernet34",
|
||||
"lanes": "47",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-34",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet35": {
|
||||
"alias": "Ethernet35",
|
||||
"lanes": "80",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-35",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet36": {
|
||||
"alias": "Ethernet36",
|
||||
"lanes": "81",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-36",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet37": {
|
||||
"alias": "Ethernet37",
|
||||
"lanes": "82",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-37",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet38": {
|
||||
"alias": "Ethernet38",
|
||||
"lanes": "88",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-38",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet39": {
|
||||
"alias": "Ethernet39",
|
||||
"lanes": "89",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-39",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet40": {
|
||||
"alias": "Ethernet40",
|
||||
"lanes": "90",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-40",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet41": {
|
||||
"alias": "Ethernet41",
|
||||
"lanes": "84",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-41",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet42": {
|
||||
"alias": "Ethernet42",
|
||||
"lanes": "85",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-42",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet43": {
|
||||
"alias": "Ethernet43",
|
||||
"lanes": "86",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-43",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet44": {
|
||||
"alias": "Ethernet44",
|
||||
"lanes": "87",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-44",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet45": {
|
||||
"alias": "Ethernet45",
|
||||
"lanes": "92",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-45",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet46": {
|
||||
"alias": "Ethernet46",
|
||||
"lanes": "93",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-46",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet47": {
|
||||
"alias": "Ethernet47",
|
||||
"lanes": "94",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-47",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet48": {
|
||||
"alias": "Ethernet48",
|
||||
"lanes": "95",
|
||||
"speed": "10000"
|
||||
"alias": "eth-0-48",
|
||||
"speed": "10000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet49": {
|
||||
"alias": "Ethernet49",
|
||||
"lanes": "52,53,54,55",
|
||||
"speed": "40000"
|
||||
"alias": "eth-0-49",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet50": {
|
||||
"alias": "Ethernet50",
|
||||
"lanes": "56,57,58,59",
|
||||
"speed": "40000"
|
||||
"alias": "eth-0-50",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet51": {
|
||||
"alias": "Ethernet51",
|
||||
"lanes": "60,61,62,63",
|
||||
"speed": "40000"
|
||||
"alias": "eth-0-51",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet52": {
|
||||
"alias": "Ethernet52",
|
||||
"lanes": "68,69,70,71",
|
||||
"speed": "40000"
|
||||
"alias": "eth-0-52",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet53": {
|
||||
"alias": "Ethernet53",
|
||||
"lanes": "72,73,74,75",
|
||||
"speed": "40000"
|
||||
"alias": "eth-0-53",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
},
|
||||
"Ethernet54": {
|
||||
"alias": "Ethernet54",
|
||||
"lanes": "76,77,78,79",
|
||||
"speed": "40000"
|
||||
"alias": "eth-0-54",
|
||||
"speed": "40000",
|
||||
"mtu": "9100"
|
||||
}
|
||||
},
|
||||
"PORT_QOS_MAP": {
|
||||
@ -402,7 +402,7 @@
|
||||
"weight": "20"
|
||||
}
|
||||
},
|
||||
"VLAN": {
|
||||
"VLAN": {
|
||||
"Vlan500": {
|
||||
"dhcp_servers": [
|
||||
"192.168.5.1",
|
||||
@ -418,7 +418,7 @@
|
||||
],
|
||||
"vlanid": "500"
|
||||
},
|
||||
"Vlan600": {
|
||||
"Vlan600": {
|
||||
"dhcp_servers": [
|
||||
"192.168.6.1",
|
||||
"192.168.6.2",
|
||||
@ -431,7 +431,7 @@
|
||||
],
|
||||
"vlanid": "600"
|
||||
},
|
||||
"Vlan700": {
|
||||
"Vlan700": {
|
||||
"dhcp_servers": [
|
||||
"192.168.7.1",
|
||||
"192.168.7.2",
|
||||
@ -444,7 +444,7 @@
|
||||
],
|
||||
"vlanid": "700"
|
||||
},
|
||||
"Vlan800": {
|
||||
"Vlan800": {
|
||||
"dhcp_servers": [
|
||||
"192.168.8.1",
|
||||
"192.168.8.2",
|
||||
@ -458,32 +458,32 @@
|
||||
"vlanid": "800"
|
||||
}
|
||||
},
|
||||
"VLAN_MEMBER": {
|
||||
"VLAN_MEMBER": {
|
||||
"Vlan500|Ethernet5": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan500|Ethernet6": {
|
||||
"Vlan500|Ethernet6": {
|
||||
"tagging_mode": "untagged"
|
||||
},
|
||||
"Vlan500|Ethernet7": {
|
||||
"Vlan500|Ethernet7": {
|
||||
"tagging_mode": "untagged"
|
||||
},
|
||||
"Vlan500|Ethernet8": {
|
||||
"Vlan500|Ethernet8": {
|
||||
"tagging_mode": "untagged"
|
||||
},
|
||||
"Vlan600|Ethernet5": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan600|Ethernet6": {
|
||||
"Vlan600|Ethernet6": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan700|Ethernet5": {
|
||||
"Vlan700|Ethernet5": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan700|Ethernet7": {
|
||||
"Vlan700|Ethernet7": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan800|Ethernet5": {
|
||||
"Vlan800|Ethernet5": {
|
||||
"tagging_mode": "tagged"
|
||||
},
|
||||
"Vlan800|Ethernet8": {
|
||||
@ -496,11 +496,11 @@
|
||||
"Ethernet3|192.168.3.1/24": {},
|
||||
"Ethernet4|192.168.4.1/24": {}
|
||||
},
|
||||
"VLAN_INTERFACE": {
|
||||
"VLAN_INTERFACE": {
|
||||
"Vlan500|192.168.5.1/24": {},
|
||||
"Vlan600|192.168.6.1/24": {},
|
||||
"Vlan700|192.168.7.1/24": {},
|
||||
"Vlan800|192.168.8.1/24": {}
|
||||
"Vlan600|192.168.6.1/24": {},
|
||||
"Vlan700|192.168.7.1/24": {},
|
||||
"Vlan800|192.168.8.1/24": {}
|
||||
},
|
||||
"LOOPBACK_INTERFACE": {
|
||||
"Loopback0|127.0.0.1/8": {}
|
||||
|
@ -1,38 +0,0 @@
|
||||
<DeviceMiniGraph xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="Microsoft.Search.Autopilot.Evolution">
|
||||
<CpgDec>
|
||||
<IsisRouters xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
<PeeringSessions/>
|
||||
<Routers xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
</CpgDec>
|
||||
<DpgDec>
|
||||
<DeviceDataPlaneInfo>
|
||||
<IPSecTunnels/>
|
||||
<LoopbackIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
</LoopbackIPInterfaces>
|
||||
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
</ManagementIPInterfaces>
|
||||
<MplsInterfaces/>
|
||||
<MplsTeInterfaces/>
|
||||
<RsvpInterfaces/>
|
||||
<Hostname>switch1</Hostname>
|
||||
<PortChannelInterfaces/>
|
||||
<VlanInterfaces/>
|
||||
<IPInterfaces/>
|
||||
<DataAcls/>
|
||||
<AclInterfaces/>
|
||||
<DownstreamSummaries/>
|
||||
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
</DeviceDataPlaneInfo>
|
||||
</DpgDec>
|
||||
<PngDec>
|
||||
<Devices>
|
||||
<Device i:type="LeafRouter">
|
||||
<Hostname>switch1</Hostname>
|
||||
<HwSku>E582-48x6q</HwSku>
|
||||
</Device>
|
||||
</Devices>
|
||||
</PngDec>
|
||||
<Hostname>switch1</Hostname>
|
||||
<HwSku>E582-48x6q</HwSku>
|
||||
</DeviceMiniGraph>
|
||||
|
@ -53,26 +53,25 @@
|
||||
*/
|
||||
|
||||
struct at24_data {
|
||||
struct at24_platform_data chip;
|
||||
struct memory_accessor macc;
|
||||
int use_smbus;
|
||||
struct at24_platform_data chip;
|
||||
int use_smbus;
|
||||
|
||||
/*
|
||||
* Lock protects against activities from other Linux tasks,
|
||||
* but not from changes by other I2C masters.
|
||||
*/
|
||||
struct mutex lock;
|
||||
struct bin_attribute bin;
|
||||
/*
|
||||
* Lock protects against activities from other Linux tasks,
|
||||
* but not from changes by other I2C masters.
|
||||
*/
|
||||
struct mutex lock;
|
||||
struct bin_attribute bin;
|
||||
|
||||
u8 *writebuf;
|
||||
unsigned write_max;
|
||||
unsigned num_addresses;
|
||||
u8 *writebuf;
|
||||
unsigned write_max;
|
||||
unsigned num_addresses;
|
||||
|
||||
/*
|
||||
* Some chips tie up multiple I2C addresses; dummy devices reserve
|
||||
* them for us, and we'll use them with SMBus calls.
|
||||
*/
|
||||
struct i2c_client *client[];
|
||||
/*
|
||||
* Some chips tie up multiple I2C addresses; dummy devices reserve
|
||||
* them for us, and we'll use them with SMBus calls.
|
||||
*/
|
||||
struct i2c_client *client[];
|
||||
};
|
||||
|
||||
/*
|
||||
@ -102,13 +101,13 @@ MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)");
|
||||
#define AT24_BITMASK(x) (BIT(x) - 1)
|
||||
|
||||
/* create non-zero magic value for given eeprom parameters */
|
||||
#define AT24_DEVICE_MAGIC(_len, _flags) \
|
||||
((1 << AT24_SIZE_FLAGS | (_flags)) \
|
||||
<< AT24_SIZE_BYTELEN | ilog2(_len))
|
||||
#define AT24_DEVICE_MAGIC(_len, _flags) \
|
||||
((1 << AT24_SIZE_FLAGS | (_flags)) \
|
||||
<< AT24_SIZE_BYTELEN | ilog2(_len))
|
||||
|
||||
static const struct i2c_device_id at24_ctc_ids[] = {
|
||||
{ "24c64-ctc", AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16 | AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
|
||||
{ /* END OF LIST */ }
|
||||
{ "24c64-ctc", AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16 | AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
|
||||
{ /* END OF LIST */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, at24_ctc_ids);
|
||||
|
||||
@ -120,62 +119,62 @@ MODULE_DEVICE_TABLE(i2c, at24_ctc_ids);
|
||||
* Assumes that sanity checks for offset happened at sysfs-layer.
|
||||
*/
|
||||
static struct i2c_client *at24_translate_offset(struct at24_data *at24,
|
||||
unsigned *offset)
|
||||
unsigned *offset)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned i = 0;
|
||||
|
||||
if (at24->chip.flags & AT24_FLAG_ADDR16) {
|
||||
i = *offset >> 16;
|
||||
*offset &= 0xffff;
|
||||
} else {
|
||||
i = *offset >> 8;
|
||||
*offset &= 0xff;
|
||||
}
|
||||
if (at24->chip.flags & AT24_FLAG_ADDR16) {
|
||||
i = *offset >> 16;
|
||||
*offset &= 0xffff;
|
||||
} else {
|
||||
i = *offset >> 8;
|
||||
*offset &= 0xff;
|
||||
}
|
||||
|
||||
return at24->client[i];
|
||||
return at24->client[i];
|
||||
}
|
||||
|
||||
static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
|
||||
unsigned offset, size_t count)
|
||||
unsigned offset, size_t count)
|
||||
{
|
||||
struct i2c_msg msg[2];
|
||||
struct i2c_client *client;
|
||||
unsigned long timeout, read_time;
|
||||
int status;
|
||||
struct i2c_msg msg[2];
|
||||
struct i2c_client *client;
|
||||
unsigned long timeout, read_time;
|
||||
int status;
|
||||
|
||||
memset(msg, 0, sizeof(msg));
|
||||
memset(msg, 0, sizeof(msg));
|
||||
|
||||
/*
|
||||
* REVISIT some multi-address chips don't rollover page reads to
|
||||
* the next slave address, so we may need to truncate the count.
|
||||
* Those chips might need another quirk flag.
|
||||
*
|
||||
* If the real hardware used four adjacent 24c02 chips and that
|
||||
* were misconfigured as one 24c08, that would be a similar effect:
|
||||
* one "eeprom" file not four, but larger reads would fail when
|
||||
* they crossed certain pages.
|
||||
*/
|
||||
/*
|
||||
* REVISIT some multi-address chips don't rollover page reads to
|
||||
* the next slave address, so we may need to truncate the count.
|
||||
* Those chips might need another quirk flag.
|
||||
*
|
||||
* If the real hardware used four adjacent 24c02 chips and that
|
||||
* were misconfigured as one 24c08, that would be a similar effect:
|
||||
* one "eeprom" file not four, but larger reads would fail when
|
||||
* they crossed certain pages.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Slave address and byte offset derive from the offset. Always
|
||||
* set the byte address; on a multi-master board, another master
|
||||
* may have changed the chip's "current" address pointer.
|
||||
*/
|
||||
client = at24_translate_offset(at24, &offset);
|
||||
/*
|
||||
* Slave address and byte offset derive from the offset. Always
|
||||
* set the byte address; on a multi-master board, another master
|
||||
* may have changed the chip's "current" address pointer.
|
||||
*/
|
||||
client = at24_translate_offset(at24, &offset);
|
||||
|
||||
if (count > io_limit)
|
||||
count = io_limit;
|
||||
if (count > io_limit)
|
||||
count = io_limit;
|
||||
|
||||
count = 1;
|
||||
count = 1;
|
||||
|
||||
/*
|
||||
* Reads fail if the previous write didn't complete yet. We may
|
||||
* loop a few times until this one succeeds, waiting at least
|
||||
* long enough for one entire page write to work.
|
||||
*/
|
||||
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||
do {
|
||||
read_time = jiffies;
|
||||
/*
|
||||
* Reads fail if the previous write didn't complete yet. We may
|
||||
* loop a few times until this one succeeds, waiting at least
|
||||
* long enough for one entire page write to work.
|
||||
*/
|
||||
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||
do {
|
||||
read_time = jiffies;
|
||||
|
||||
status = i2c_smbus_write_byte_data(client, (offset >> 8) & 0x0ff, offset & 0x0ff );
|
||||
status = i2c_smbus_read_byte(client);
|
||||
@ -184,65 +183,62 @@ static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
|
||||
status = count;
|
||||
}
|
||||
|
||||
dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n",
|
||||
count, offset, status, jiffies);
|
||||
dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n", count, offset, status, jiffies);
|
||||
|
||||
if (status == count)
|
||||
return count;
|
||||
if (status == count)
|
||||
return count;
|
||||
|
||||
/* REVISIT: at HZ=100, this is sloooow */
|
||||
msleep(1);
|
||||
} while (time_before(read_time, timeout));
|
||||
/* REVISIT: at HZ=100, this is sloooow */
|
||||
msleep(1);
|
||||
} while (time_before(read_time, timeout));
|
||||
|
||||
return -ETIMEDOUT;
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static ssize_t at24_read(struct at24_data *at24,
|
||||
char *buf, loff_t off, size_t count)
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
ssize_t retval = 0;
|
||||
ssize_t retval = 0;
|
||||
|
||||
if (unlikely(!count))
|
||||
return count;
|
||||
if (unlikely(!count))
|
||||
return count;
|
||||
|
||||
memset(buf, 0, count);
|
||||
|
||||
/*
|
||||
* Read data from chip, protecting against concurrent updates
|
||||
* from this host, but not from other I2C masters.
|
||||
*/
|
||||
mutex_lock(&at24->lock);
|
||||
/*
|
||||
* Read data from chip, protecting against concurrent updates
|
||||
* from this host, but not from other I2C masters.
|
||||
*/
|
||||
mutex_lock(&at24->lock);
|
||||
|
||||
while (count) {
|
||||
ssize_t status;
|
||||
while (count) {
|
||||
ssize_t status;
|
||||
|
||||
status = at24_eeprom_read(at24, buf, off, count);
|
||||
if (status <= 0) {
|
||||
if (retval == 0)
|
||||
retval = status;
|
||||
break;
|
||||
}
|
||||
buf += status;
|
||||
off += status;
|
||||
count -= status;
|
||||
retval += status;
|
||||
}
|
||||
status = at24_eeprom_read(at24, buf, off, count);
|
||||
if (status <= 0) {
|
||||
if (retval == 0)
|
||||
retval = status;
|
||||
break;
|
||||
}
|
||||
buf += status;
|
||||
off += status;
|
||||
count -= status;
|
||||
retval += status;
|
||||
}
|
||||
|
||||
//printk(KERN_ALERT "at24_read buf = %s, retval = %zu\n", buf, retval);
|
||||
mutex_unlock(&at24->lock);
|
||||
|
||||
mutex_unlock(&at24->lock);
|
||||
|
||||
return retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static ssize_t at24_bin_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
struct bin_attribute *attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
struct at24_data *at24;
|
||||
struct at24_data *at24;
|
||||
|
||||
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||
return at24_read(at24, buf, off, count);
|
||||
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||
return at24_read(at24, buf, off, count);
|
||||
}
|
||||
|
||||
|
||||
@ -255,334 +251,281 @@ static ssize_t at24_bin_read(struct file *filp, struct kobject *kobj,
|
||||
* writes at most one page.
|
||||
*/
|
||||
static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
|
||||
unsigned offset, size_t count)
|
||||
unsigned offset, size_t count)
|
||||
{
|
||||
struct i2c_client *client;
|
||||
ssize_t status;
|
||||
unsigned long timeout, write_time;
|
||||
unsigned next_page;
|
||||
struct i2c_client *client;
|
||||
ssize_t status;
|
||||
unsigned long timeout, write_time;
|
||||
unsigned next_page;
|
||||
|
||||
/* Get corresponding I2C address and adjust offset */
|
||||
client = at24_translate_offset(at24, &offset);
|
||||
/* Get corresponding I2C address and adjust offset */
|
||||
client = at24_translate_offset(at24, &offset);
|
||||
|
||||
/* write_max is at most a page */
|
||||
if (count > at24->write_max)
|
||||
count = at24->write_max;
|
||||
/* write_max is at most a page */
|
||||
if (count > at24->write_max)
|
||||
count = at24->write_max;
|
||||
|
||||
/* Never roll over backwards, to the start of this page */
|
||||
next_page = roundup(offset + 1, at24->chip.page_size);
|
||||
if (offset + count > next_page)
|
||||
count = next_page - offset;
|
||||
/* Never roll over backwards, to the start of this page */
|
||||
next_page = roundup(offset + 1, at24->chip.page_size);
|
||||
if (offset + count > next_page)
|
||||
count = next_page - offset;
|
||||
|
||||
/*
|
||||
* Writes fail if the previous one didn't complete yet. We may
|
||||
* loop a few times until this one succeeds, waiting at least
|
||||
* long enough for one entire page write to work.
|
||||
*/
|
||||
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||
do {
|
||||
write_time = jiffies;
|
||||
/*
|
||||
* Writes fail if the previous one didn't complete yet. We may
|
||||
* loop a few times until this one succeeds, waiting at least
|
||||
* long enough for one entire page write to work.
|
||||
*/
|
||||
timeout = jiffies + msecs_to_jiffies(write_timeout);
|
||||
do {
|
||||
write_time = jiffies;
|
||||
|
||||
status = i2c_smbus_write_word_data(client,
|
||||
(offset >> 8) & 0x0ff, (offset & 0xFF) | buf[0]);
|
||||
status = i2c_smbus_write_word_data(client, (offset >> 8) & 0x0ff, (offset & 0xFF) | buf[0]);
|
||||
if (status == 0)
|
||||
status = count;
|
||||
|
||||
dev_dbg(&client->dev, "write %zu@%d --> %zd (%ld)\n",
|
||||
count, offset, status, jiffies);
|
||||
dev_dbg(&client->dev, "write %zu@%d --> %zd (%ld)\n", count, offset, status, jiffies);
|
||||
|
||||
if (status == count)
|
||||
return count;
|
||||
if (status == count)
|
||||
return count;
|
||||
|
||||
/* REVISIT: at HZ=100, this is sloooow */
|
||||
msleep(1);
|
||||
} while (time_before(write_time, timeout));
|
||||
/* REVISIT: at HZ=100, this is sloooow */
|
||||
msleep(1);
|
||||
} while (time_before(write_time, timeout));
|
||||
|
||||
return -ETIMEDOUT;
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off,
|
||||
size_t count)
|
||||
size_t count)
|
||||
{
|
||||
ssize_t retval = 0;
|
||||
ssize_t retval = 0;
|
||||
|
||||
if (unlikely(!count))
|
||||
return count;
|
||||
if (unlikely(!count))
|
||||
return count;
|
||||
|
||||
/*
|
||||
* Write data to chip, protecting against concurrent updates
|
||||
* from this host, but not from other I2C masters.
|
||||
*/
|
||||
mutex_lock(&at24->lock);
|
||||
/*
|
||||
* Write data to chip, protecting against concurrent updates
|
||||
* from this host, but not from other I2C masters.
|
||||
*/
|
||||
mutex_lock(&at24->lock);
|
||||
|
||||
while (count) {
|
||||
ssize_t status;
|
||||
while (count) {
|
||||
ssize_t status;
|
||||
|
||||
status = at24_eeprom_write(at24, buf, off, 1); /* only one-byte to write; TODO page wirte */
|
||||
if (status <= 0) {
|
||||
if (retval == 0)
|
||||
retval = status;
|
||||
break;
|
||||
}
|
||||
buf += status;
|
||||
off += status;
|
||||
count -= status;
|
||||
retval += status;
|
||||
}
|
||||
status = at24_eeprom_write(at24, buf, off, 1); /* only one-byte to write; TODO page wirte */
|
||||
if (status <= 0) {
|
||||
if (retval == 0)
|
||||
retval = status;
|
||||
break;
|
||||
}
|
||||
buf += status;
|
||||
off += status;
|
||||
count -= status;
|
||||
retval += status;
|
||||
}
|
||||
|
||||
mutex_unlock(&at24->lock);
|
||||
mutex_unlock(&at24->lock);
|
||||
|
||||
return retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static ssize_t at24_bin_write(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
struct bin_attribute *attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
struct at24_data *at24;
|
||||
struct at24_data *at24;
|
||||
|
||||
if (unlikely(off >= attr->size))
|
||||
return -EFBIG;
|
||||
if (unlikely(off >= attr->size))
|
||||
return -EFBIG;
|
||||
|
||||
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||
return at24_write(at24, buf, off, count);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* This lets other kernel code access the eeprom data. For example, it
|
||||
* might hold a board's Ethernet address, or board-specific calibration
|
||||
* data generated on the manufacturing floor.
|
||||
*/
|
||||
|
||||
static ssize_t at24_macc_read(struct memory_accessor *macc, char *buf,
|
||||
off_t offset, size_t count)
|
||||
{
|
||||
struct at24_data *at24 = container_of(macc, struct at24_data, macc);
|
||||
|
||||
return at24_read(at24, buf, offset, count);
|
||||
}
|
||||
|
||||
static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf,
|
||||
off_t offset, size_t count)
|
||||
{
|
||||
struct at24_data *at24 = container_of(macc, struct at24_data, macc);
|
||||
|
||||
return at24_write(at24, buf, offset, count);
|
||||
at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||
return at24_write(at24, buf, off, count);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static void at24_get_ofdata(struct i2c_client *client,
|
||||
struct at24_platform_data *chip)
|
||||
struct at24_platform_data *chip)
|
||||
{
|
||||
const __be32 *val;
|
||||
struct device_node *node = client->dev.of_node;
|
||||
const __be32 *val;
|
||||
struct device_node *node = client->dev.of_node;
|
||||
|
||||
if (node) {
|
||||
if (of_get_property(node, "read-only", NULL))
|
||||
chip->flags |= AT24_FLAG_READONLY;
|
||||
val = of_get_property(node, "pagesize", NULL);
|
||||
if (val)
|
||||
chip->page_size = be32_to_cpup(val);
|
||||
}
|
||||
if (node) {
|
||||
if (of_get_property(node, "read-only", NULL))
|
||||
chip->flags |= AT24_FLAG_READONLY;
|
||||
val = of_get_property(node, "pagesize", NULL);
|
||||
if (val)
|
||||
chip->page_size = be32_to_cpup(val);
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void at24_get_ofdata(struct i2c_client *client,
|
||||
struct at24_platform_data *chip)
|
||||
struct at24_platform_data *chip)
|
||||
{ }
|
||||
#endif /* CONFIG_OF */
|
||||
|
||||
static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct at24_platform_data chip;
|
||||
bool writable;
|
||||
int use_smbus = 0;
|
||||
struct at24_data *at24;
|
||||
int err;
|
||||
unsigned i, num_addresses;
|
||||
kernel_ulong_t magic;
|
||||
struct at24_platform_data chip;
|
||||
bool writable;
|
||||
int use_smbus = 0;
|
||||
struct at24_data *at24;
|
||||
int err;
|
||||
unsigned i, num_addresses;
|
||||
kernel_ulong_t magic;
|
||||
|
||||
if (client->dev.platform_data) {
|
||||
chip = *(struct at24_platform_data *)client->dev.platform_data;
|
||||
} else {
|
||||
if (!id->driver_data)
|
||||
return -ENODEV;
|
||||
if (client->dev.platform_data) {
|
||||
chip = *(struct at24_platform_data *)client->dev.platform_data;
|
||||
} else {
|
||||
if (!id->driver_data)
|
||||
return -ENODEV;
|
||||
|
||||
magic = id->driver_data;
|
||||
chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
|
||||
magic >>= AT24_SIZE_BYTELEN;
|
||||
chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS);
|
||||
magic = id->driver_data;
|
||||
chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
|
||||
magic >>= AT24_SIZE_BYTELEN;
|
||||
chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS);
|
||||
|
||||
/*
|
||||
* This is slow, but we can't know all eeproms, so we better
|
||||
* play safe. Specifying custom eeprom-types via platform_data
|
||||
* is recommended anyhow.
|
||||
*/
|
||||
chip.page_size = 1;
|
||||
/*
|
||||
* This is slow, but we can't know all eeproms, so we better
|
||||
* play safe. Specifying custom eeprom-types via platform_data
|
||||
* is recommended anyhow.
|
||||
*/
|
||||
chip.page_size = 1;
|
||||
|
||||
/* update chipdata if OF is present */
|
||||
at24_get_ofdata(client, &chip);
|
||||
/* update chipdata if OF is present */
|
||||
at24_get_ofdata(client, &chip);
|
||||
|
||||
printk(KERN_ALERT "at24_probe chip.byte_len = 0x%x\n", chip.byte_len);
|
||||
printk(KERN_ALERT "at24_probe chip.flags = 0x%x\n", chip.flags);
|
||||
printk(KERN_ALERT "at24_probe chip.magic = 0x%lx\n", id->driver_data);
|
||||
chip.setup = NULL;
|
||||
chip.context = NULL;
|
||||
}
|
||||
|
||||
chip.setup = NULL;
|
||||
chip.context = NULL;
|
||||
}
|
||||
if (!is_power_of_2(chip.byte_len))
|
||||
dev_warn(&client->dev,
|
||||
"byte_len looks suspicious (no power of 2)!\n");
|
||||
if (!chip.page_size) {
|
||||
dev_err(&client->dev, "page_size must not be 0!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!is_power_of_2(chip.page_size))
|
||||
dev_warn(&client->dev,
|
||||
"page_size looks suspicious (no power of 2)!\n");
|
||||
|
||||
if (!is_power_of_2(chip.byte_len))
|
||||
dev_warn(&client->dev,
|
||||
"byte_len looks suspicious (no power of 2)!\n");
|
||||
if (!chip.page_size) {
|
||||
dev_err(&client->dev, "page_size must not be 0!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!is_power_of_2(chip.page_size))
|
||||
dev_warn(&client->dev,
|
||||
"page_size looks suspicious (no power of 2)!\n");
|
||||
|
||||
/* Use I2C operations unless we're stuck with SMBus extensions. */
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
|
||||
if (i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
|
||||
use_smbus = I2C_SMBUS_I2C_BLOCK_DATA;
|
||||
} else if (i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_READ_WORD_DATA)) {
|
||||
use_smbus = I2C_SMBUS_WORD_DATA;
|
||||
} else if (i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
|
||||
use_smbus = I2C_SMBUS_BYTE_DATA;
|
||||
} else {
|
||||
return -EPFNOSUPPORT;
|
||||
}
|
||||
/* Use I2C operations unless we're stuck with SMBus extensions. */
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
|
||||
if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
|
||||
use_smbus = I2C_SMBUS_I2C_BLOCK_DATA;
|
||||
} else if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_WORD_DATA)) {
|
||||
use_smbus = I2C_SMBUS_WORD_DATA;
|
||||
} else if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
|
||||
use_smbus = I2C_SMBUS_BYTE_DATA;
|
||||
} else {
|
||||
return -EPFNOSUPPORT;
|
||||
}
|
||||
use_smbus = I2C_SMBUS_BYTE_DATA;
|
||||
printk(KERN_ALERT "at24_probe use_smbus --> %d\n",
|
||||
use_smbus);
|
||||
}
|
||||
}
|
||||
|
||||
if (chip.flags & AT24_FLAG_TAKE8ADDR)
|
||||
num_addresses = 8;
|
||||
else
|
||||
num_addresses = DIV_ROUND_UP(chip.byte_len,
|
||||
(chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
|
||||
if (chip.flags & AT24_FLAG_TAKE8ADDR)
|
||||
num_addresses = 8;
|
||||
else
|
||||
num_addresses = DIV_ROUND_UP(chip.byte_len, (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
|
||||
|
||||
at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
|
||||
num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
|
||||
if (!at24)
|
||||
return -ENOMEM;
|
||||
at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) + num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
|
||||
if (!at24)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_init(&at24->lock);
|
||||
at24->use_smbus = use_smbus;
|
||||
at24->chip = chip;
|
||||
at24->num_addresses = num_addresses;
|
||||
mutex_init(&at24->lock);
|
||||
at24->use_smbus = use_smbus;
|
||||
at24->chip = chip;
|
||||
at24->num_addresses = num_addresses;
|
||||
|
||||
/*
|
||||
* Export the EEPROM bytes through sysfs, since that's convenient.
|
||||
* By default, only root should see the data (maybe passwords etc)
|
||||
*/
|
||||
sysfs_bin_attr_init(&at24->bin);
|
||||
at24->bin.attr.name = "eeprom";
|
||||
at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
|
||||
at24->bin.read = at24_bin_read;
|
||||
at24->bin.size = chip.byte_len;
|
||||
printk(KERN_ALERT "at24_probe chip.byte_len = 0x%x\n", chip.byte_len);
|
||||
printk(KERN_ALERT "at24_probe chip.flags = 0x%x\n", chip.flags);
|
||||
printk(KERN_ALERT "at24_probe chip.magic = 0x%lx\n", id->driver_data);
|
||||
printk(KERN_ALERT "at24_probe use_smbus = %d\n", at24->use_smbus);
|
||||
printk(KERN_ALERT "at24_probe num_addresses = %d\n", at24->num_addresses);
|
||||
|
||||
at24->macc.read = at24_macc_read;
|
||||
/*
|
||||
* Export the EEPROM bytes through sysfs, since that's convenient.
|
||||
* By default, only root should see the data (maybe passwords etc)
|
||||
*/
|
||||
sysfs_bin_attr_init(&at24->bin);
|
||||
at24->bin.attr.name = "eeprom";
|
||||
at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
|
||||
at24->bin.read = at24_bin_read;
|
||||
at24->bin.size = chip.byte_len;
|
||||
|
||||
writable = !(chip.flags & AT24_FLAG_READONLY);
|
||||
if (writable) {
|
||||
if (!use_smbus || i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
|
||||
writable = !(chip.flags & AT24_FLAG_READONLY);
|
||||
if (writable) {
|
||||
if (!use_smbus || i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
|
||||
unsigned write_max = chip.page_size;
|
||||
|
||||
unsigned write_max = chip.page_size;
|
||||
at24->bin.write = at24_bin_write;
|
||||
at24->bin.attr.mode |= S_IWUSR;
|
||||
|
||||
at24->macc.write = at24_macc_write;
|
||||
if (write_max > io_limit)
|
||||
write_max = io_limit;
|
||||
if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX)
|
||||
write_max = I2C_SMBUS_BLOCK_MAX;
|
||||
at24->write_max = write_max;
|
||||
|
||||
at24->bin.write = at24_bin_write;
|
||||
at24->bin.attr.mode |= S_IWUSR;
|
||||
/* buffer (data + address at the beginning) */
|
||||
at24->writebuf = devm_kzalloc(&client->dev, write_max + 2, GFP_KERNEL);
|
||||
if (!at24->writebuf)
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
dev_warn(&client->dev, "cannot write due to controller restrictions.");
|
||||
}
|
||||
}
|
||||
|
||||
if (write_max > io_limit)
|
||||
write_max = io_limit;
|
||||
if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX)
|
||||
write_max = I2C_SMBUS_BLOCK_MAX;
|
||||
at24->write_max = write_max;
|
||||
at24->client[0] = client;
|
||||
|
||||
/* buffer (data + address at the beginning) */
|
||||
at24->writebuf = devm_kzalloc(&client->dev,
|
||||
write_max + 2, GFP_KERNEL);
|
||||
if (!at24->writebuf)
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
dev_warn(&client->dev,
|
||||
"cannot write due to controller restrictions.");
|
||||
}
|
||||
}
|
||||
/* use dummy devices for multiple-address chips */
|
||||
for (i = 1; i < num_addresses; i++) {
|
||||
at24->client[i] = i2c_new_dummy(client->adapter, client->addr + i);
|
||||
if (!at24->client[i]) {
|
||||
dev_err(&client->dev, "address 0x%02x unavailable\n", client->addr + i);
|
||||
err = -EADDRINUSE;
|
||||
goto err_clients;
|
||||
}
|
||||
}
|
||||
|
||||
at24->client[0] = client;
|
||||
err = sysfs_create_bin_file(&client->dev.kobj, &at24->bin);
|
||||
if (err)
|
||||
goto err_clients;
|
||||
|
||||
/* use dummy devices for multiple-address chips */
|
||||
for (i = 1; i < num_addresses; i++) {
|
||||
at24->client[i] = i2c_new_dummy(client->adapter,
|
||||
client->addr + i);
|
||||
if (!at24->client[i]) {
|
||||
dev_err(&client->dev, "address 0x%02x unavailable\n",
|
||||
client->addr + i);
|
||||
err = -EADDRINUSE;
|
||||
goto err_clients;
|
||||
}
|
||||
}
|
||||
i2c_set_clientdata(client, at24);
|
||||
|
||||
err = sysfs_create_bin_file(&client->dev.kobj, &at24->bin);
|
||||
if (err)
|
||||
goto err_clients;
|
||||
printk(KERN_ALERT "at24_probe %s done\n", client->name);
|
||||
|
||||
i2c_set_clientdata(client, at24);
|
||||
|
||||
dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n",
|
||||
at24->bin.size, client->name,
|
||||
writable ? "writable" : "read-only", at24->write_max);
|
||||
if (use_smbus == I2C_SMBUS_WORD_DATA ||
|
||||
use_smbus == I2C_SMBUS_BYTE_DATA) {
|
||||
dev_notice(&client->dev, "Falling back to %s reads, "
|
||||
"performance will suffer\n", use_smbus ==
|
||||
I2C_SMBUS_WORD_DATA ? "word" : "byte");
|
||||
}
|
||||
|
||||
/* export data to kernel code */
|
||||
if (chip.setup)
|
||||
chip.setup(&at24->macc, chip.context);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
err_clients:
|
||||
for (i = 1; i < num_addresses; i++)
|
||||
if (at24->client[i])
|
||||
i2c_unregister_device(at24->client[i]);
|
||||
for (i = 1; i < num_addresses; i++)
|
||||
if (at24->client[i])
|
||||
i2c_unregister_device(at24->client[i]);
|
||||
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int at24_remove(struct i2c_client *client)
|
||||
{
|
||||
struct at24_data *at24;
|
||||
int i;
|
||||
struct at24_data *at24;
|
||||
int i;
|
||||
|
||||
at24 = i2c_get_clientdata(client);
|
||||
sysfs_remove_bin_file(&client->dev.kobj, &at24->bin);
|
||||
at24 = i2c_get_clientdata(client);
|
||||
sysfs_remove_bin_file(&client->dev.kobj, &at24->bin);
|
||||
|
||||
for (i = 1; i < at24->num_addresses; i++)
|
||||
i2c_unregister_device(at24->client[i]);
|
||||
for (i = 1; i < at24->num_addresses; i++)
|
||||
i2c_unregister_device(at24->client[i]);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
static struct i2c_board_info i2c_devs = {
|
||||
I2C_BOARD_INFO("24c64-ctc", 0x57),
|
||||
I2C_BOARD_INFO("24c64-ctc", 0x57),
|
||||
};
|
||||
|
||||
static struct i2c_adapter *adapter = NULL;
|
||||
@ -590,65 +533,65 @@ static struct i2c_client *client = NULL;
|
||||
|
||||
static int ctc_at24c64_init(void)
|
||||
{
|
||||
printk(KERN_ALERT "ctc_at24c64_init\n");
|
||||
printk(KERN_ALERT "ctc_at24c64_init\n");
|
||||
|
||||
adapter = i2c_get_adapter(0);
|
||||
if(adapter == NULL){
|
||||
printk(KERN_ALERT "i2c_get_adapter == NULL\n");
|
||||
return -1;
|
||||
}
|
||||
adapter = i2c_get_adapter(0);
|
||||
if(adapter == NULL){
|
||||
printk(KERN_ALERT "i2c_get_adapter == NULL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
client = i2c_new_device(adapter, &i2c_devs);
|
||||
if(client == NULL){
|
||||
printk(KERN_ALERT "i2c_new_device == NULL\n");
|
||||
i2c_put_adapter(adapter);
|
||||
adapter = NULL;
|
||||
return -1;
|
||||
}
|
||||
client = i2c_new_device(adapter, &i2c_devs);
|
||||
if(client == NULL){
|
||||
printk(KERN_ALERT "i2c_new_device == NULL\n");
|
||||
i2c_put_adapter(adapter);
|
||||
adapter = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ctc_at24c64_exit(void)
|
||||
{
|
||||
printk(KERN_ALERT "ctc_at24c64_exit\n");
|
||||
if(client){
|
||||
i2c_unregister_device(client);
|
||||
}
|
||||
if(adapter){
|
||||
i2c_put_adapter(adapter);
|
||||
}
|
||||
printk(KERN_ALERT "ctc_at24c64_exit\n");
|
||||
if(client){
|
||||
i2c_unregister_device(client);
|
||||
}
|
||||
if(adapter){
|
||||
i2c_put_adapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
static struct i2c_driver at24_ctc_driver = {
|
||||
.driver = {
|
||||
.name = "at24-ctc",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = at24_probe,
|
||||
.remove = at24_remove,
|
||||
.id_table = at24_ctc_ids,
|
||||
.driver = {
|
||||
.name = "at24-ctc",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = at24_probe,
|
||||
.remove = at24_remove,
|
||||
.id_table = at24_ctc_ids,
|
||||
};
|
||||
|
||||
static int __init at24_ctc_init(void)
|
||||
{
|
||||
if (!io_limit) {
|
||||
pr_err("at24_ctc: io_limit must not be 0!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!io_limit) {
|
||||
pr_err("at24_ctc: io_limit must not be 0!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
io_limit = rounddown_pow_of_two(io_limit);
|
||||
io_limit = rounddown_pow_of_two(io_limit);
|
||||
|
||||
ctc_at24c64_init();
|
||||
|
||||
return i2c_add_driver(&at24_ctc_driver);
|
||||
return i2c_add_driver(&at24_ctc_driver);
|
||||
}
|
||||
module_init(at24_ctc_init);
|
||||
|
||||
static void __exit at24_ctc_exit(void)
|
||||
{
|
||||
ctc_at24c64_exit();
|
||||
i2c_del_driver(&at24_ctc_driver);
|
||||
i2c_del_driver(&at24_ctc_driver);
|
||||
}
|
||||
module_exit(at24_ctc_exit);
|
||||
|
||||
@ -656,3 +599,4 @@ MODULE_DESCRIPTION("Driver for most I2C EEPROMs");
|
||||
MODULE_AUTHOR("David Brownell and Wolfram Sang");
|
||||
MODULE_LICENSE("GPL");
|
||||
/* XXX */
|
||||
|
||||
|
@ -845,7 +845,7 @@ enum led_brightness e582_48x6q_led_get(struct led_classdev *led_cdev)
|
||||
if (ret != 0)
|
||||
{
|
||||
printk(KERN_CRIT "Error: read %s led attr failed\n", led_cdev->name);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
led_value = ((led_value & mask) >> shift);
|
||||
@ -1189,7 +1189,8 @@ static ssize_t e582_48x6q_sfp_write_enable(struct device *dev, struct device_att
|
||||
ret = e582_48x6q_smbus_write_reg(i2c_sfp_client, dir_bank, 0x0);
|
||||
if (ret != 0)
|
||||
{
|
||||
return sprintf(buf, "Error: read sfp data:%s set dir-ctl failed\n", attr->attr.name);
|
||||
printk(KERN_CRIT "Error: read sfp data:%s set dir-ctl failed\n", attr->attr.name);
|
||||
return size;
|
||||
}
|
||||
|
||||
input_bank = (reg_no/8) + 0x8;
|
||||
@ -1221,7 +1222,7 @@ static ssize_t e582_48x6q_sfp_write_enable(struct device *dev, struct device_att
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(sfp_presence, S_IRUGO, e582_48x6q_sfp_read_presence, NULL);
|
||||
static DEVICE_ATTR(sfp_enable, S_IRUGO|S_IWUGO, e582_48x6q_sfp_read_enable, e582_48x6q_sfp_write_enable);
|
||||
static DEVICE_ATTR(sfp_enable, S_IRUGO|S_IWUSR, e582_48x6q_sfp_read_enable, e582_48x6q_sfp_write_enable);
|
||||
static int e582_48x6q_init_sfp(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#endif
|
||||
#include "dal_kernel.h"
|
||||
#include "dal_mpool.h"
|
||||
|
||||
#include <linux/slab.h>
|
||||
MODULE_AUTHOR("Centec Networks Inc.");
|
||||
MODULE_DESCRIPTION("DAL kernel module");
|
||||
MODULE_LICENSE("GPL");
|
||||
@ -47,7 +47,9 @@ MODULE_PARM_DESC(dma_pool_size,
|
||||
|
||||
#define CTC_VENDOR_VID 0xc001
|
||||
#define CTC_HUMBER_DEVICE_ID 0x6048
|
||||
#define CTC_GOLDENGATE_DEVICE_ID 0xcb10
|
||||
#define CTC_GOLDENGATE_DEVICE_ID 0xc010
|
||||
#define CTC_PCIE_VENDOR_ID 0xcb10
|
||||
#define CTC_DUET2_DEVICE_ID 0x7148
|
||||
|
||||
#define MEM_MAP_RESERVE SetPageReserved
|
||||
#define MEM_MAP_UNRESERVE ClearPageReserved
|
||||
@ -82,7 +84,7 @@ typedef struct dal_kernel_dev_s
|
||||
uintptr logic_address;
|
||||
|
||||
/* Physical address */
|
||||
uintptr phys_address;
|
||||
unsigned long long phys_address;
|
||||
} dal_kern_dev_t;
|
||||
|
||||
typedef struct _dma_segment
|
||||
@ -126,8 +128,8 @@ static unsigned int* dma_virt_base[DAL_MAX_CHIP_NUM];
|
||||
#ifndef DMA_MEM_MODE_PLATFORM
|
||||
static unsigned int* dma_virt_base_tmp[DAL_MAX_CHIP_NUM];
|
||||
#endif
|
||||
static uintptr dma_phy_base[DAL_MAX_CHIP_NUM];
|
||||
static unsigned int dma_mem_size = 0x800000;
|
||||
static unsigned long long dma_phy_base[DAL_MAX_CHIP_NUM];
|
||||
static unsigned int dma_mem_size = 0xc00000;
|
||||
static unsigned int msi_irq_base[DAL_MAX_CHIP_NUM];
|
||||
static unsigned int msi_irq_num[DAL_MAX_CHIP_NUM];
|
||||
static unsigned int msi_used = 0;
|
||||
@ -141,7 +143,9 @@ MODULE_PARM_DESC(dal_debug, "Set debug level (default 0)");
|
||||
static struct pci_device_id dal_id_table[] =
|
||||
{
|
||||
{PCI_DEVICE(CTC_VENDOR_VID, CTC_GREATBELT_DEVICE_ID)},
|
||||
{PCI_DEVICE(0xcb10, 0xc010)},
|
||||
{PCI_DEVICE(CTC_PCIE_VENDOR_ID, CTC_GOLDENGATE_DEVICE_ID)},
|
||||
{PCI_DEVICE((CTC_PCIE_VENDOR_ID+1), (CTC_GOLDENGATE_DEVICE_ID+1))},
|
||||
{PCI_DEVICE(CTC_PCIE_VENDOR_ID, CTC_DUET2_DEVICE_ID)},
|
||||
{0, },
|
||||
};
|
||||
|
||||
@ -186,7 +190,11 @@ static struct file_operations dal_intr_fops[CTC_MAX_INTR_NUM] =
|
||||
.poll = linux_dal_poll7,
|
||||
},
|
||||
};
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
|
||||
#include <linux/slab.h>
|
||||
#define virt_to_bus virt_to_phys
|
||||
#define bus_to_virt phys_to_virt
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* macros
|
||||
*****************************************************************************/
|
||||
@ -450,9 +458,12 @@ dal_interrupt_register(unsigned int irq, int prio, void (* isr)(void*), void* da
|
||||
{
|
||||
if (irq == dal_isr[intr_num_tmp].irq)
|
||||
{
|
||||
dal_isr[intr_num_tmp].count++;
|
||||
printk("Interrupt irq %d register count %d.\n", irq, dal_isr[intr_num_tmp].count);
|
||||
return 0;
|
||||
if (0 == msi_used)
|
||||
{
|
||||
dal_isr[intr_num_tmp].count++;
|
||||
printk("Interrupt irq %d register count %d.\n", irq, dal_isr[intr_num_tmp].count);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if ((0 == dal_isr[intr_num_tmp].irq) && (CTC_MAX_INTR_NUM == intr_num))
|
||||
{
|
||||
@ -558,14 +569,6 @@ _dal_set_msi_enabe(unsigned int lchip, unsigned int irq_num)
|
||||
|
||||
if (irq_num == 1)
|
||||
{
|
||||
if (msi_irq_base[lchip])
|
||||
{
|
||||
dal_interrupt_unregister(msi_irq_base[lchip]);
|
||||
pci_disable_msi(dal_dev[lchip].pci_dev);
|
||||
msi_used = 0;
|
||||
msi_irq_base[lchip] = 0;
|
||||
msi_irq_num[lchip] = 0;
|
||||
}
|
||||
ret = pci_enable_msi(dal_dev[lchip].pci_dev);
|
||||
if (ret)
|
||||
{
|
||||
@ -616,6 +619,7 @@ int
|
||||
dal_set_msi_cap(unsigned long arg)
|
||||
{
|
||||
int ret = 0;
|
||||
int index = 0;
|
||||
dal_msi_info_t msi_info;
|
||||
|
||||
if (copy_from_user(&msi_info, (void*)arg, sizeof(dal_msi_info_t)))
|
||||
@ -626,8 +630,21 @@ dal_set_msi_cap(unsigned long arg)
|
||||
printk("####dal_set_msi_cap lchip %d base %d num:%d\n", msi_info.lchip, msi_info.irq_base, msi_info.irq_num);
|
||||
if (msi_info.irq_num > 0)
|
||||
{
|
||||
msi_used = 1;
|
||||
ret = _dal_set_msi_enabe(msi_info.lchip, msi_info.irq_num);
|
||||
if (0 == msi_used)
|
||||
{
|
||||
msi_used = 1;
|
||||
ret = _dal_set_msi_enabe(msi_info.lchip, msi_info.irq_num);
|
||||
}
|
||||
else if ((1 == msi_used) && (msi_info.irq_num != msi_irq_num[msi_info.lchip]))
|
||||
{
|
||||
for (index = 0; index < msi_irq_num[msi_info.lchip]; index++)
|
||||
{
|
||||
dal_interrupt_unregister(msi_irq_base[msi_info.lchip]+index);
|
||||
}
|
||||
_dal_set_msi_disable(msi_info.lchip);
|
||||
msi_used = 1;
|
||||
ret = _dal_set_msi_enabe(msi_info.lchip, msi_info.irq_num);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1062,6 +1079,10 @@ int
|
||||
dal_create_irq_mapping(unsigned long arg)
|
||||
{
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
|
||||
|
||||
#ifndef NO_IRQ
|
||||
#define NO_IRQ (-1)
|
||||
#endif
|
||||
dal_irq_mapping_t irq_map;
|
||||
|
||||
if (copy_from_user(&irq_map, (void*)arg, sizeof(dal_irq_mapping_t)))
|
||||
@ -1094,7 +1115,7 @@ dal_pci_read(unsigned long arg)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
_dal_pci_read((unsigned char)cmdpara_chip.chip_id, (unsigned int)cmdpara_chip.reg_addr,
|
||||
_dal_pci_read((unsigned char)cmdpara_chip.lchip, (unsigned int)cmdpara_chip.reg_addr,
|
||||
(unsigned int*)(&(cmdpara_chip.value)));
|
||||
|
||||
if (copy_to_user((dal_chip_parm_t*)arg, (void*)&cmdpara_chip, sizeof(dal_chip_parm_t)))
|
||||
@ -1127,7 +1148,7 @@ dal_pci_write(unsigned long arg)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
_dal_pci_write((unsigned char)cmdpara_chip.chip_id, (unsigned int)cmdpara_chip.reg_addr,
|
||||
_dal_pci_write((unsigned char)cmdpara_chip.lchip, (unsigned int)cmdpara_chip.reg_addr,
|
||||
(unsigned int)cmdpara_chip.value);
|
||||
|
||||
return 0;
|
||||
@ -1166,7 +1187,7 @@ dal_user_read_pci_conf(unsigned long arg)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (dal_pci_conf_read(dal_cfg.chip_id, dal_cfg.offset, &dal_cfg.value))
|
||||
if (dal_pci_conf_read(dal_cfg.lchip, dal_cfg.offset, &dal_cfg.value))
|
||||
{
|
||||
printk("dal_pci_conf_read failed.\n");
|
||||
return -EFAULT;
|
||||
@ -1190,14 +1211,14 @@ dal_user_write_pci_conf(unsigned long arg)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return dal_pci_conf_write(dal_cfg.chip_id, dal_cfg.offset, dal_cfg.value);
|
||||
return dal_pci_conf_write(dal_cfg.lchip, dal_cfg.offset, dal_cfg.value);
|
||||
}
|
||||
|
||||
static int
|
||||
linux_get_device(unsigned long arg)
|
||||
{
|
||||
dal_user_dev_t user_dev;
|
||||
int chip_id = 0;
|
||||
int lchip = 0;
|
||||
|
||||
if (copy_from_user(&user_dev, (void*)arg, sizeof(user_dev)))
|
||||
{
|
||||
@ -1205,20 +1226,16 @@ linux_get_device(unsigned long arg)
|
||||
}
|
||||
|
||||
user_dev.chip_num = dal_chip_num;
|
||||
chip_id = user_dev.chip_id;
|
||||
lchip = user_dev.lchip;
|
||||
|
||||
if (chip_id < dal_chip_num)
|
||||
if (lchip < dal_chip_num)
|
||||
{
|
||||
user_dev.phy_base0 = (unsigned int)dal_dev[chip_id].phys_address;
|
||||
#ifdef PHYS_ADDR_IS_64BIT
|
||||
user_dev.phy_base1 = (unsigned int)(dal_dev[chip_id].phys_address >> 32);
|
||||
#else
|
||||
user_dev.phy_base1 = 0;
|
||||
#endif
|
||||
user_dev.phy_base0 = (unsigned int)dal_dev[lchip].phys_address;
|
||||
user_dev.phy_base1 = (unsigned int)(dal_dev[lchip].phys_address >> 32);
|
||||
|
||||
user_dev.bus_no = dal_dev[chip_id].pci_dev->bus->number;
|
||||
user_dev.dev_no = dal_dev[chip_id].pci_dev->device;
|
||||
user_dev.fun_no = dal_dev[chip_id].pci_dev->devfn;
|
||||
user_dev.bus_no = dal_dev[lchip].pci_dev->bus->number;
|
||||
user_dev.dev_no = dal_dev[lchip].pci_dev->device;
|
||||
user_dev.fun_no = dal_dev[lchip].pci_dev->devfn;
|
||||
}
|
||||
|
||||
if (copy_to_user((dal_user_dev_t*)arg, (void*)&user_dev, sizeof(user_dev)))
|
||||
@ -1256,11 +1273,7 @@ linux_get_dma_info(unsigned long arg)
|
||||
}
|
||||
|
||||
dma_para.phy_base = (unsigned int)dma_phy_base[dma_para.lchip];
|
||||
#ifdef PHYS_ADDR_IS_64BIT
|
||||
dma_para.phy_base_hi = dma_phy_base[dma_para.lchip] >> 32;
|
||||
#else
|
||||
dma_para.phy_base_hi = 0;
|
||||
#endif
|
||||
dma_para.size = dma_mem_size;
|
||||
|
||||
if (copy_to_user((dma_info_t*)arg, (void*)&dma_para, sizeof(dma_info_t)))
|
||||
@ -1348,10 +1361,10 @@ dal_cache_inval(unsigned long arg)
|
||||
|
||||
#if 0
|
||||
dma_sync_single_for_cpu(NULL, intr_para.ptr, intr_para.length, DMA_BIDIRECTIONAL);
|
||||
#endif
|
||||
|
||||
|
||||
dma_cache_sync(NULL, (void*)intr_para.ptr, intr_para.length, DMA_BIDIRECTIONAL);
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1371,10 +1384,10 @@ dal_cache_flush(unsigned long arg)
|
||||
|
||||
#if 0
|
||||
dma_sync_single_for_cpu(NULL, intr_para.ptr, intr_para.length, DMA_BIDIRECTIONAL);
|
||||
#endif
|
||||
|
||||
|
||||
dma_cache_sync(NULL, (void*)intr_para.ptr, intr_para.length, DMA_BIDIRECTIONAL);
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1386,31 +1399,30 @@ linux_dal_probe(struct pci_dev* pdev, const struct pci_device_id* id)
|
||||
int ret = 0;
|
||||
unsigned int temp = 0;
|
||||
unsigned int lchip = 0;
|
||||
unsigned int chip_id = 0;
|
||||
|
||||
printk(KERN_WARNING "********found dal device*****\n");
|
||||
|
||||
for (chip_id = 0; chip_id < DAL_MAX_CHIP_NUM; chip_id ++)
|
||||
for (lchip = 0; lchip < DAL_MAX_CHIP_NUM; lchip ++)
|
||||
{
|
||||
if (NULL == dal_dev[chip_id].pci_dev)
|
||||
if (NULL == dal_dev[lchip].pci_dev)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (chip_id >= DAL_MAX_CHIP_NUM)
|
||||
if (lchip >= DAL_MAX_CHIP_NUM)
|
||||
{
|
||||
printk("Exceed max local chip num\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dev = &dal_dev[chip_id];
|
||||
dev = &dal_dev[lchip];
|
||||
if (NULL == dev)
|
||||
{
|
||||
printk("Cannot obtain PCI resources\n");
|
||||
}
|
||||
|
||||
lchip = chip_id;
|
||||
lchip = lchip;
|
||||
dal_chip_num += 1;
|
||||
|
||||
dev->pci_dev = pdev;
|
||||
@ -1454,7 +1466,6 @@ linux_dal_probe(struct pci_dev* pdev, const struct pci_device_id* id)
|
||||
if (dma_mem_size)
|
||||
{
|
||||
dal_alloc_dma_pool(lchip, dma_mem_size);
|
||||
#ifdef PHYS_ADDR_IS_64BIT
|
||||
|
||||
/*add check Dma memory pool cannot cross 4G space*/
|
||||
if ((0==(dma_phy_base[lchip]>>32)) && (0!=((dma_phy_base[lchip]+dma_mem_size)>>32)))
|
||||
@ -1462,7 +1473,6 @@ linux_dal_probe(struct pci_dev* pdev, const struct pci_device_id* id)
|
||||
printk("Dma malloc memory cross 4G space!!!!!! \n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
printk(KERN_WARNING "linux_dal_probe end*****\n");
|
||||
@ -1473,12 +1483,12 @@ linux_dal_probe(struct pci_dev* pdev, const struct pci_device_id* id)
|
||||
void
|
||||
linux_dal_remove(struct pci_dev* pdev)
|
||||
{
|
||||
unsigned int chip_id = 0;
|
||||
unsigned int lchip = 0;
|
||||
unsigned int flag = 0;
|
||||
|
||||
for (chip_id = 0; chip_id < DAL_MAX_CHIP_NUM; chip_id ++)
|
||||
for (lchip = 0; lchip < DAL_MAX_CHIP_NUM; lchip ++)
|
||||
{
|
||||
if (pdev == dal_dev[chip_id].pci_dev)
|
||||
if (pdev == dal_dev[lchip].pci_dev)
|
||||
{
|
||||
flag = 1;
|
||||
break;
|
||||
@ -1487,11 +1497,11 @@ linux_dal_remove(struct pci_dev* pdev)
|
||||
|
||||
if (1 == flag)
|
||||
{
|
||||
dal_free_dma_pool(chip_id);
|
||||
dal_free_dma_pool(lchip);
|
||||
pci_release_regions(pdev);
|
||||
pci_disable_device(pdev);
|
||||
|
||||
dal_dev[chip_id].pci_dev = NULL;
|
||||
dal_dev[lchip].pci_dev = NULL;
|
||||
dal_chip_num--;
|
||||
}
|
||||
|
||||
@ -1504,7 +1514,7 @@ linux_dal_ioctl(struct file* file,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
#else
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 13))
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36))
|
||||
static int
|
||||
linux_dal_ioctl(struct file* file,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
@ -1820,3 +1830,4 @@ linux_dal_exit(void)
|
||||
module_init(linux_dal_init);
|
||||
module_exit(linux_dal_exit);
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ typedef unsigned int uintptr;
|
||||
#define DAL_ONE_MB (1024*1024)
|
||||
struct dal_chip_parm_s
|
||||
{
|
||||
unsigned int chip_id; /*tmp should be uint8*/
|
||||
unsigned int lchip; /*tmp should be uint8*/
|
||||
unsigned int fpga_id; /*tmp add*/
|
||||
unsigned int reg_addr;
|
||||
unsigned int value;
|
||||
@ -78,7 +78,7 @@ typedef struct dal_irq_mapping_s dal_irq_mapping_t;
|
||||
struct dal_user_dev_s
|
||||
{
|
||||
unsigned int chip_num; /*output: local chip number*/
|
||||
unsigned int chip_id; /*input: local chip id*/
|
||||
unsigned int lchip; /*input: local chip id*/
|
||||
unsigned int phy_base0; /* low 32bits physical base address */
|
||||
unsigned int phy_base1; /* high 32bits physical base address */
|
||||
unsigned int bus_no;
|
||||
@ -100,7 +100,7 @@ typedef struct dma_info_s dma_info_t;
|
||||
|
||||
struct dal_pci_cfg_ioctl_s
|
||||
{
|
||||
unsigned int chip_id; /* Device ID */
|
||||
unsigned int lchip; /* Device ID */
|
||||
unsigned int offset;
|
||||
unsigned int value;
|
||||
};
|
||||
@ -168,3 +168,4 @@ typedef enum dal_version_e dal_version_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#include "dal_mpool.h"
|
||||
|
||||
#ifdef __KERNEL__
|
||||
@ -27,6 +26,8 @@ static sal_mutex_t* dal_mpool_lock;
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
|
||||
|
||||
dal_mpool_mem_t* g_free_block_ptr = NULL;
|
||||
|
||||
/* System cache line size */
|
||||
@ -34,8 +35,9 @@ dal_mpool_mem_t* g_free_block_ptr = NULL;
|
||||
#define DAL_CACHE_LINE_BYTES 256
|
||||
#endif
|
||||
|
||||
static dal_mpool_mem_t* p_desc_pool = NULL;
|
||||
static dal_mpool_mem_t* p_data_pool = NULL;
|
||||
#define DAL_MAX_CHIP_NUM 32
|
||||
static dal_mpool_mem_t* p_desc_pool[DAL_MAX_CHIP_NUM] = {0};
|
||||
static dal_mpool_mem_t* p_data_pool[DAL_MAX_CHIP_NUM] = {0};
|
||||
|
||||
int
|
||||
dal_mpool_init(void)
|
||||
@ -74,7 +76,7 @@ _dal_mpool_create(void* base, int size, int type)
|
||||
}
|
||||
|
||||
dal_mpool_mem_t*
|
||||
dal_mpool_create(void* base, int size)
|
||||
dal_mpool_create(unsigned char lchip, void* base, int size)
|
||||
{
|
||||
dal_mpool_mem_t* head = NULL;
|
||||
int mod = (int)(((unsigned long)base) & (DAL_CACHE_LINE_BYTES - 1));
|
||||
@ -98,8 +100,8 @@ dal_mpool_create(void* base, int size)
|
||||
}
|
||||
|
||||
/* init for desc linkptr */
|
||||
p_desc_pool = _dal_mpool_create(base, DAL_MPOOL_MAX_DESX_SIZE, DAL_MPOOL_TYPE_DESC);
|
||||
if (NULL == p_desc_pool)
|
||||
p_desc_pool[lchip] = _dal_mpool_create(base, DAL_MPOOL_MAX_DESX_SIZE, DAL_MPOOL_TYPE_DESC);
|
||||
if (NULL == p_desc_pool[lchip])
|
||||
{
|
||||
MPOOL_UNLOCK();
|
||||
DAL_FREE(head->next);
|
||||
@ -108,14 +110,14 @@ dal_mpool_create(void* base, int size)
|
||||
}
|
||||
|
||||
/* init for data linkptr */
|
||||
p_data_pool = _dal_mpool_create(((char*)base+DAL_MPOOL_MAX_DESX_SIZE), (size - DAL_MPOOL_MAX_DESX_SIZE), DAL_MPOOL_TYPE_DATA);
|
||||
if (NULL == p_data_pool)
|
||||
p_data_pool[lchip] = _dal_mpool_create(((char*)base+DAL_MPOOL_MAX_DESX_SIZE), (size - DAL_MPOOL_MAX_DESX_SIZE), DAL_MPOOL_TYPE_DATA);
|
||||
if (NULL == p_data_pool[lchip])
|
||||
{
|
||||
MPOOL_UNLOCK();
|
||||
DAL_FREE(head->next);
|
||||
DAL_FREE(head);
|
||||
DAL_FREE(p_desc_pool->next);
|
||||
DAL_FREE(p_desc_pool);
|
||||
DAL_FREE(p_desc_pool[lchip]->next);
|
||||
DAL_FREE(p_desc_pool[lchip]);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -160,7 +162,7 @@ _dal_mpool_alloc_comon(dal_mpool_mem_t* ptr, int size, int type)
|
||||
}
|
||||
|
||||
void*
|
||||
dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type)
|
||||
dal_mpool_alloc(unsigned char lchip, dal_mpool_mem_t* pool, int size, int type)
|
||||
{
|
||||
dal_mpool_mem_t* ptr = NULL;
|
||||
dal_mpool_mem_t* new_ptr = NULL;
|
||||
@ -186,7 +188,7 @@ dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type)
|
||||
}
|
||||
break;
|
||||
case DAL_MPOOL_TYPE_DESC:
|
||||
ptr = p_desc_pool;
|
||||
ptr = p_desc_pool[lchip];
|
||||
new_ptr = _dal_mpool_alloc_comon(ptr, size, type);
|
||||
if (NULL == new_ptr)
|
||||
{
|
||||
@ -195,7 +197,7 @@ dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type)
|
||||
}
|
||||
break;
|
||||
case DAL_MPOOL_TYPE_DATA:
|
||||
ptr = p_data_pool;
|
||||
ptr = p_data_pool[lchip];
|
||||
new_ptr = _dal_mpool_alloc_comon(ptr, size, type);
|
||||
if (NULL == new_ptr)
|
||||
{
|
||||
@ -210,6 +212,10 @@ dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type)
|
||||
}
|
||||
|
||||
MPOOL_UNLOCK();
|
||||
if( NULL == new_ptr )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new_ptr->address;
|
||||
}
|
||||
@ -242,7 +248,7 @@ _dal_mpool_free(dal_mpool_mem_t* ptr, void* addr, int type)
|
||||
}
|
||||
|
||||
void
|
||||
dal_mpool_free(dal_mpool_mem_t* pool, void* addr)
|
||||
dal_mpool_free(unsigned char lchip, dal_mpool_mem_t* pool, void* addr)
|
||||
{
|
||||
dal_mpool_mem_t* ptr = pool;
|
||||
|
||||
@ -255,11 +261,11 @@ dal_mpool_free(dal_mpool_mem_t* pool, void* addr)
|
||||
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_USELESS);
|
||||
break;
|
||||
case DAL_MPOOL_TYPE_DESC:
|
||||
ptr = p_desc_pool;
|
||||
ptr = p_desc_pool[lchip];
|
||||
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_DESC);
|
||||
break;
|
||||
case DAL_MPOOL_TYPE_DATA:
|
||||
ptr = p_data_pool;
|
||||
ptr = p_data_pool[lchip];
|
||||
_dal_mpool_free(ptr, addr, DAL_MPOOL_TYPE_DATA);
|
||||
break;
|
||||
default:
|
||||
@ -271,7 +277,7 @@ dal_mpool_free(dal_mpool_mem_t* pool, void* addr)
|
||||
}
|
||||
|
||||
int
|
||||
dal_mpool_destroy(dal_mpool_mem_t* pool)
|
||||
dal_mpool_destroy(unsigned char lchip, dal_mpool_mem_t* pool)
|
||||
{
|
||||
dal_mpool_mem_t* ptr, * next;
|
||||
|
||||
@ -283,13 +289,13 @@ dal_mpool_destroy(dal_mpool_mem_t* pool)
|
||||
DAL_FREE(ptr);
|
||||
}
|
||||
|
||||
for (ptr = p_desc_pool; ptr; ptr = next)
|
||||
for (ptr = p_desc_pool[lchip]; ptr; ptr = next)
|
||||
{
|
||||
next = ptr->next;
|
||||
DAL_FREE(ptr);
|
||||
}
|
||||
|
||||
for (ptr = p_data_pool; ptr; ptr = next)
|
||||
for (ptr = p_data_pool[lchip]; ptr; ptr = next)
|
||||
{
|
||||
next = ptr->next;
|
||||
DAL_FREE(ptr);
|
||||
@ -341,3 +347,4 @@ dal_mpool_debug(dal_mpool_mem_t* pool)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,16 +47,16 @@ extern int
|
||||
dal_mpool_init(void);
|
||||
|
||||
extern dal_mpool_mem_t*
|
||||
dal_mpool_create(void* base_ptr, int size);
|
||||
dal_mpool_create(unsigned char lchip, void* base_ptr, int size);
|
||||
|
||||
extern void*
|
||||
dal_mpool_alloc(dal_mpool_mem_t* pool, int size, int type);
|
||||
dal_mpool_alloc(unsigned char lchip, dal_mpool_mem_t* pool, int size, int type);
|
||||
|
||||
extern void
|
||||
dal_mpool_free(dal_mpool_mem_t* pool, void* addr);
|
||||
dal_mpool_free(unsigned char lchip, dal_mpool_mem_t* pool, void* addr);
|
||||
|
||||
extern int
|
||||
dal_mpool_destroy(dal_mpool_mem_t* pool);
|
||||
dal_mpool_destroy(unsigned char lchip, dal_mpool_mem_t* pool);
|
||||
|
||||
extern int
|
||||
dal_mpool_usage(dal_mpool_mem_t* pool, int type);
|
||||
@ -69,3 +69,4 @@ dal_mpool_debug(dal_mpool_mem_t* pool);
|
||||
|
||||
#endif /* !_DMA_MPOOL_H */
|
||||
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Centec e582 48x6q platform modules
|
||||
After=local-fs.target
|
||||
Before=pmon.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=-/etc/init.d/platform-modules-e582-48x6q start
|
||||
ExecStop=-/etc/init.d/platform-modules-e582-48x6q stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -2,10 +2,10 @@ sonic-centec-platform-modules (1.1) unstable; urgency=low
|
||||
|
||||
* Add support for centec e582-48x2q4z
|
||||
|
||||
-- xuwj <xuwj@centecnetworks.com> Thus, 25 Jan 2018 13:43:40 +0800
|
||||
-- yangbs <yangbs@centecnetworks.com> Thu, 25 Jan 2018 13:43:40 +0800
|
||||
|
||||
sonic-centec-platform-modules (1.0) unstable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
||||
-- xuwj <xuwj@centecnetworks.com> Mon, 22 Jan 2018 13:43:40 +0800
|
||||
-- yangbs <yangbs@centecnetworks.com> Mon, 22 Jan 2018 13:43:40 +0800
|
||||
|
@ -7,11 +7,11 @@ Standards-Version: 3.9.3
|
||||
|
||||
Package: platform-modules-e582-48x2q4z
|
||||
Architecture: amd64
|
||||
Depends: linux-image-3.16.0-5-amd64
|
||||
Depends: linux-image-4.9.0-7-amd64
|
||||
Description: kernel modules for platform devices such as fan, led, sfp
|
||||
|
||||
Package: platform-modules-e582-48x6q
|
||||
Architecture: amd64
|
||||
Depends: linux-image-3.16.0-5-amd64
|
||||
Depends: linux-image-4.9.0-7-amd64
|
||||
Description: kernel modules for platform devices such as fan, led, sfp
|
||||
|
||||
|
@ -1,2 +1,6 @@
|
||||
48x2q4z/cfg/48x2q4z-modules.conf etc/modules-load.d
|
||||
48x2q4z/cfg/config_db.json etc/sonic
|
||||
48x2q4z/cfg/config_db_l2l3.json etc/sonic
|
||||
48x2q4z/scripts/48x2q4z_platform.sh usr/bin
|
||||
48x2q4z/scripts/48x2q4z_platform_monitor.py usr/bin
|
||||
48x2q4z/service/48x2q4z_platform.service lib/systemd/system
|
||||
|
@ -0,0 +1,3 @@
|
||||
depmod -a
|
||||
systemctl enable 48x2q4z_platform.service
|
||||
systemctl start 48x2q4z_platform.service
|
@ -1,6 +1,6 @@
|
||||
48x6q/cfg/48x6q-modules.conf etc/modules-load.d
|
||||
48x6q/cfg/minigraph.xml etc/sonic
|
||||
48x6q/cfg/config_db.json etc/sonic
|
||||
48x6q/cfg/config_db_l2l3.json etc/sonic
|
||||
48x6q/scripts/48x6q_platform.sh usr/bin
|
||||
48x6q/scripts/48x6q_platform_monitor.py usr/bin
|
||||
48x6q/service/48x6q_platform.service lib/systemd/system
|
||||
|
@ -0,0 +1,3 @@
|
||||
depmod -a
|
||||
systemctl enable 48x6q_platform.service
|
||||
systemctl start 48x6q_platform.service
|
Loading…
Reference in New Issue
Block a user