Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform Driver Development Framework (PDDF): 1) Changes to psu base class (1.0 APIs) to support PDDF CLI utils, 2) Adding fan_base class to support PDDF fan CLI utils (comments incorporated) #62

Merged
merged 3 commits into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'sonic_platform_base.sonic_eeprom',
'sonic_platform_base.sonic_sfp',
'sonic_psu',
'sonic_fan',
'sonic_sfp',
],
classifiers=[
Expand Down
Empty file added sonic_fan/__init__.py
Empty file.
84 changes: 84 additions & 0 deletions sonic_fan/fan_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python
#
# fan_base.py
#
# Base class for implementing platform-specific
# FAN control functionality for SONiC
#

try:
import abc
except ImportError as e:
raise ImportError (str(e) + " - required module not found")

class FanBase(object):
__metaclass__ = abc.ABCMeta

def get_num_fans(self):
"""
Retrieves the number of FANs supported on the device

:return: An integer, the number of FANs supported on the device
"""
return 0

def get_status(self, index):
"""
Retrieves the operational status of FAN defined
by index 1-based <index>

:param index: An integer, 1-based index of the PSU of which to query status
:return: Boolean,
- True if FAN is running with some speed
- False if FAN has stopped running
"""
return False

def get_presence(self, index):
"""
Retrieves the presence status of a FAN defined
by 1-based index <index>

:param index: An integer, 1-based index of the FAN of which to query status
:return: Boolean, True if FAN is plugged, False if not
"""
return False

def get_direction(self, index):
"""
Retrieves the airflow direction of a FAN defined
by 1-based index <index>

:param index: An integer, 1-based index of the FAN of which to query status
:return: string, denoting FAN airflow direction
"""
return ""

def get_speed(self, index):
"""
Retrieves the speed of a Front FAN in the tray in revolutions per minute defined
by 1-based index <index>

:param index: An integer, 1-based index of the FAN of which to query speed
:return: integer, denoting front FAN speed
"""
return 0

def get_speed_rear(self, index):
"""
Retrieves the speed of a rear FAN in the tray in revolutions per minute defined
by 1-based index <index>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my understanding is that although there could have multi fans(usually 2) in a tray, but each fan has its own tachometer, so these fans in the same tray should still be treated as separated fans, In my view, this function is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While mentioning the platform inventory, one fan-tray is usually considered as one fan unit. ODM too, provide the APIs to retrieve 'rear-fan' speed. 'lm-sensors' (or sensors command) denotes rear fan of FAN tray 1 as fan11, rear fan of FAN tray 2 as fan22 etc.

Open Config model FAN related CLIs also provide the fan speed in term of front and rear speed.

Set speed FAN APIs also set speed of both the fans in a single call. Hence a separate API is provided for rear FAN speed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on some vendors platform, they do treat fans in the same tray as separated fans and hide the rear/front info from user, in this case, this function is not applicable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Keboliu,
If some vendors treat 'rear' fans as separate, indexing them is left to discretion of the vendors. e.g Accton uses,
fan1 (front) --------- fan11 (rear)
fan2 (front) --------- fan12(rear) etc

Some other platform may use fan1 (tray1-front), fan2(tray1-rear), fan3 (tray2-front), fan4 (tray2-rear) etc.

If separate indexing is being used, vendors can use 'get_speed' API. If tray is numbered and fans inside a tray are mentioned as 'front' and 'rear' then let 'get_speed_rear' API be used. Since some vendors also use tray numbering, can't we keep both APIs?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with keeping both APIs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function may require more thorough commenting to ensure vendors understand that get_speed_rear() is only to be implemented for the rear fan of a 2-fan tray.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added extra comment to mention the same.


:param index: An integer, 1-based index of the FAN of which to query speed
:return: integer, denoting rear FAN speed
"""
return 0

def set_speed(self, val):
"""
Sets the speed of all the FANs to a value denoted by the duty-cycle percentage val

:param val: An integer, <0-100> denoting FAN duty cycle percentage
:return: Boolean, True if operation is successful, False if not
"""
return False
72 changes: 72 additions & 0 deletions sonic_psu/psu_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,75 @@ def get_psu_presence(self, index):
"""
return False

def get_model(self, idx):
"""
Retrieves the model number/name of a power supply unit (PSU) defined
by 1-based index <idx>
:param idx: An integer, 1-based index of the PSU of which to query model number
:return: String, denoting model number/name
"""
return ""

def get_mfr_id(self, idx):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you give an example string for this id? Not sure the difference between mfr_id and serial number.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mfr_id is the 'Manufacturer's ID'. Either name or some abbreviation which denotes the manufacturer. e.g.

  1. On Delta platforms, PSU mfr_id is 'DELTA'
  2. On some Accton platforms, PSU mfr_id is '3Y POWER'
  3. On soem Quanta platforms, PSU mfr_id is 'ARTESYN'

"""
Retrieves the manufacturing id of a power supply unit (PSU) defined
by 1-based index <idx>
:param idx: An integer, 1-based index of the PSU of which to query mfr id
:return: String, denoting manufacturing id
"""
return ""

def get_serial(self, idx):
"""
Retrieves the serial number of a power supply unit (PSU) defined
by 1-based index <idx>
:param idx: An integer, 1-based index of the PSU of which to query serial number
:return: String, denoting serial number of the PSU unit
"""
return ""

def get_direction(self, idx):
"""
Retrieves the airflow direction of a power supply unit (PSU) defined
by 1-based index <idx>
:param idx: An integer, 1-based index of the PSU of which to query airflow direction
:return: String, denoting the airflow direction
"""
return ""

def get_output_voltage(self, idx):
"""
Retrieves the ouput volatage in milli volts of a power supply unit (PSU) defined
by 1-based index <idx>
:param idx: An integer, 1-based index of the PSU of which to query o/p volatge
:return: An integer, value of o/p voltage in mV if PSU is good, else zero
"""
return 0

def get_output_current(self, idx):
"""
Retrieves the output current in milli amperes of a power supply unit (PSU) defined
by 1-based index <idx>
:param idx: An integer, 1-based index of the PSU of which to query o/p current
:return: An integer, value of o/p current in mA if PSU is good, else zero
"""
return 0

def get_output_power(self, idx):
"""
Retrieves the output power in micro watts of a power supply unit (PSU) defined
by 1-based index <idx>
:param idx: An integer, 1-based index of the PSU of which to query o/p power
:return: An integer, value of o/p power in micro Watts if PSU is good, else zero
Copy link
Collaborator

@keboliu keboliu Sep 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the return value should be a float? same comments for the above voltage, current get functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. However, psu driver takes care of converting the float value into milli or micro unit depending upon the required granularity. The SysFS interface reads the converted values.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's your decision on return values? Still in integer or change to float?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have decided to go with integer values here with milli volts, amps etc granularity.

"""
return 0

def get_fan_rpm(self, idx, fan_idx):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"get_fan_speed" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since fan speed unit is RPM, this name is chosen for the API. I can change this to 'get_fan_speed' if you think that represents the objective better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you look at the function names in fan_base, they are using 'speed', I would suggest using 'speed' for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I will update the PR

"""
Retrieves the speed of fan, in rpm, denoted by 1-based <fan_idx> of a power
supply unit (PSU) defined by 1-based index <idx>
:param idx: An integer, 1-based index of the PSU of which to query fan speed
:param fan_idx: An integer, 1-based index of the PSU-fan of which to query speed
:return: An integer, value of PSU-fan speed in rpm if PSU-fan is good, else zero
"""
return 0