From e8eacb3185ddc51a96fc7c50a1d122abd4c98cf8 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Wed, 22 Jun 2022 10:29:55 +0800 Subject: [PATCH] add comments to describe the usage of functions to judge the port type Signed-off-by: Kebo Liu --- sfputil/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sfputil/main.py b/sfputil/main.py index c337bf1cdf..cebd91d2ba 100644 --- a/sfputil/main.py +++ b/sfputil/main.py @@ -291,13 +291,19 @@ def is_sfp_present(port_name): return bool(presence) -# Determine whether it is a RJ45 port +# Below defined two flavors of functions to determin whether a port is a RJ45 port. +# They serve different types of SFP utilities. One type of SFP utility consume the +# info stored in the STATE_DB, these utilities shall call 'is_rj45_port_from_db' +# to judge the port type. Another type of utilities will call the platform API +# directly to access SFP, for them shall use 'is_rj45_port_from_api'. def is_rj45_port_from_db(port_name, db): + # Determine whether a port is a RJ45 port by checking TRANSCEIVER_INFO in STATE_DB intf_type = db.get(db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(port_name), 'type') return intf_type == RJ45_PORT_TYPE def is_rj45_port_from_api(port_name): + # Determine whether a port is a RJ45 port by calling platform API. physical_port = logical_port_to_physical_port_index(port_name) sfp = platform_chassis.get_sfp(physical_port)