diff --git a/doc/SAI-Proposal-PoE.md b/doc/SAI-Proposal-PoE.md new file mode 100755 index 0000000000..79ef54e49f --- /dev/null +++ b/doc/SAI-Proposal-PoE.md @@ -0,0 +1,591 @@ +PoE support for SAI + +| Title | PoE | +| ----------- | ---------------------- | +| Authors | Daniela Murin, Marvell | +| Status | In review | +| Type | Standards track | +| Created | 02/25/2024 | +| SAI-Version | 1.13 | + +# Overview + +Power over Ethernet, or PoE, describes any of the 802.3(AF, AT, BT) standards that deliver electrical power along with data on twisted-pair Ethernet cables. This allows a single cable to provide both data connection and electricity to power the networked devices such as wireless access points (WAPs), IP cameras and VoIP phones etc. + +# Proposal + +The current SAI does not support PoE. We will implement PoE in a way that any vendor can provide their own PoE hardware and software solution. + +## Abbreviations and Information + +| **Term** | **Definition** | +| -------------- | ------------------------------------------------------------------------------------------------- | +| PoE | Power over Ethernet | +| PSE | Power Sourcing Equipment | +| PD | Powered Device, can power the device through an PD-capable Ethernet port | +| PoE Port | Ethernet port that can deliver power and info to devices, located on the front panel of the board | + +# Key Ideas behind PoE + +1. PoE provides a hardware solution for providing a data connection and electricity to power connected devices +2. The PoE software provides an interface to configure (program) and query the PoE controller and its internal peripherals such as ports etc +3. Users can see PoE information and configure PoE features according to their needs + +# PoE Hardware Design Example + +![poe-physical-design](figures/PoE_Physical_Design.png) + +# SAI POE Components + +## New PoE SAI objects + +Three new SAI objects are introduced. + +### PoE Device ID + +This object is used to hold the global configuration and PoE hardware status. In many cases, one PoE device instance will have access to all the PoE hardware and components. + +### PoE PSE ID + +This object is used to access data from the Power Sourcing Equipment devices in the board. Such as PSE temperatures, versions, and statuses. There can be multiple PSEs in one board. + +### PoE Port ID + +This object is used to access data on a port level. PoE ports supply power using an ethernet cable. PoE port object gives access to read data and configure these ports. + +## New SAI Switch Type PoE + +A new abstraction type for PoE is created which allows multiple vendors to implement their own PoE software and hardware solutions. + +``` +/** + * @brief Attribute data for #SAI_SWITCH_ATTR_TYPE + */ +typedef enum _sai_switch_type_t +{ + /** Switch type is Switching Network processing unit */ + SAI_SWITCH_TYPE_NPU, + + /** Switch type is PHY */ + SAI_SWITCH_TYPE_PHY, + + /** Switch type is VOQ based NPU */ + SAI_SWITCH_TYPE_VOQ, + + /** Switch type is Fabric switch device */ + SAI_SWITCH_TYPE_FABRIC, + + /** Switch type is PoE (Power over Ethernet) */ + SAI_SWITCH_TYPE_POE, + +} sai_switch_type_t; +``` + +## Example of how to initialize PoE + +An example of how to initlizate PoE and access its components. + +### Create a PoE Device Object + +The PoE device object is used to access and configure board-wide system information and operations. Information about the kind of PoE hardware should be provided on the NOS level and used to initalize the driver. + +``` + /** + * @brief Device Information for switch initialization. + * + * Hardware information format is based on POE SAI implementations by vendors. + * Format is vendor specific. + * Example: Like PCI location, I2C address, UART etc. + * In case of NULL, use the default PoE associated switch id. + * + * @type char + * @flags CREATE_ONLY + * @default "" + */ + SAI_POE_DEVICE_ATTR_HARDWARE_INFO = SAI_POE_DEVICE_ATTR_START, +``` + +``` +/** + * Create a PoE device object + */ + +/* Allows the PoE software to initialize itself based on the PoE hardware */ +attr_list[0].id = SAI_POE_DEVICE_ATTR_HARDWARE_INFO; +strncpy(attr.value.chardata, "integrated-mcu", sizeof("integrated-mcu"); /* string is only relevant to the driver, can be anything*/ + +attr_count = 1; +sai_create_poe_device_fn(&poe_device_id, switch_id, attr_count, attr_list); +``` + +### Get PoE device data + +Get the current power consumption, in milliwatts, of the board. + +``` + /** + * @brief total power consumption + * + * @type sai_uint32_t + * @flags READ_ONLY + */ + SAI_POE_DEVICE_ATTR_POWER_CONSUMPTION, +``` + +``` +/* + * Get the current power consumption, in milliwatts, of the board + */ + +attr.id = SAI_POE_DEVICE_ATTR_POWER_CONSUMPTION; +attr_count = 1; +sai_get_poe_device_attribute_fn(poe_device_id, attr_count, &attr); +``` + +## Example of how to initialize PoE PSE devices + +The NOS must provide a list of PSE devices. We use this list to create PoE PSE objects. The PoE device object must be provided to bind the PoE PSE to the PoE device. + +``` + /** + * @brief POE PSE ID (index) + * + * @type sai_uint32_t + * @flags MANDATORY_ON_CREATE | CREATE_ONLY + */ + SAI_POE_PSE_ATTR_ID = SAI_POE_PSE_ATTR_START, + + /** + * @brief POE device ID + * + * @type sai_object_id_t + * @flags MANDATORY_ON_CREATE | CREATE_ONLY + * @objects SAI_OBJECT_TYPE_POE_DEVICE + */ + SAI_POE_PSE_ATTR_DEVICE_ID, +``` + +``` +/* get poe pse(s) from NOS platform file, every board must have it's own information */ +poe_pse_index_list = get_poe_pse_info(); + +for (uint32_t i = 0; i < poe_pse_index_list .size; i++) +{ + attr_list[0].id = SAI_POE_PSE_ATTR_ID; + attr_list[0].value.u32 = poe_pse_index_list.value_list[i]; /* from a platform file */ + + attr_list[1].id = SAI_POE_PSE_ATTR_DEVICE_ID; + attr_list[1].value.oid = poe_device_id; + attr_count = 2; + + sai_create_poe_pse_fn( + &poe_pse_id[i], + switch_id, + attr_count, + attr_list); +} +``` + +### Get PoE PSE Data Example + +``` + /** + * @brief temperature (in Celsius) of the PSE + * + * @type sai_int16_t + * @flags READ_ONLY + */ + SAI_POE_PSE_ATTR_TEMPERATURE, +``` + +``` +/* + * Get the poe pse temperature, in Celsius + */ + +attr.id = SAI_POE_PSE_ATTR_TEMPERATURE; +attr_count = 1; +sai_get_poe_device_attribute_fn(poe_pse_id, attr_count, &attr); +``` + +## Example of how to initialize PoE Ports + +The NOS must provide a list of PoE ports. We use this list to create PoE port objects. The PoE device object must be provided to bind the PoE port to the PoE device. + +``` + /** + * @brief POE port front panel ID + * + * @type sai_uint32_t + * @flags MANDATORY_ON_CREATE | CREATE_ONLY + */ + SAI_POE_PORT_ATTR_FRONT_PANEL_ID = SAI_POE_PORT_ATTR_START, + + /** + * @brief POE device ID + * + * @type sai_object_id_t + * @flags MANDATORY_ON_CREATE | CREATE_ONLY + * @objects SAI_OBJECT_TYPE_POE_DEVICE + */ + SAI_POE_PORT_ATTR_DEVICE_ID, +``` + +``` +/* get poe port from NOS platform file, every board must have it's own information */ +poe_front_panel_index_list = get_poe_port_info(); + +for (uint32_t i = 0; i < poe_front_panel_index_list.size; i++) +{ + attr_list[0].id = SAI_POE_PORT_ATTR_FRONT_PANEL_ID; + attr_list[0].value.u32 = poe_front_panel_index_list.value_list[i]; /* from a platform file */ + + attr_list[1].id = SAI_POE_ATTR_DEVICE_ID; + attr_list[1].value.oid = poe_device_id; + attr_count = 2; + + sai_create_poe_port_fn( + &poe_port_id[i], + switch_id, + attr_count, + attr_list); +} +``` + +### Get PoE Port Data Example + +``` +/** + * @brief PoE port enabled/disabled state, as set by the user + * + * @type bool + * @flags CREATE_AND_SET + * @default false + */ + SAI_POE_PORT_ATTR_ADMIN_ENABLED_STATE, +``` + +``` +/* + * Get the poe port admin enabled state (either enabled or disabled by the user) + */ + +attr.id = SAI_POE_PORT_ATTR_ADMIN_ENABLED_STATE; +attr_count = 1; +sai_get_poe_device_attribute_fn(poe_device_id, attr_count, &attr); +``` + +### Set PoE Port Data Example + +``` +/** + * @brief PoE port power limit mode + * + * @type sai_uint32_t + * @flags CREATE_AND_SET + * @default maximum value that the port can provide + */ + SAI_POE_PORT_ATTR_POWER_LIMIT, +``` + +``` +i/* + * Set the power limit of a port, in milliwatts + */ + +attr.id = SAI_POE_PORT_ATTR_POWER_LIMIT; +attr.value.u32 = 10500; /* 10500 milliwatts (10.5 watts) maximum power limit */ +attr_count = 1; +sai_set_poe_device_attribute_fn(poe_port_id, &attr); +``` + +### SAI Attributes + +SAI attributes may be queried using the `sai_api_query`() function and the following SAI POE APIs that were added to `sai_api_t`: + +``` +SAI_API_POE = 51, /**< sai_poe_api_t */ +``` + +### PoE Device Information + +The get_poe_device_attribute() and set_poe_device_attribute() functions can be used to access the following attributes. + +- total power +- power consumption +- poe software version (firmware) +- power limit mode + +``` +/** + * @brief the total power in the device, in watts + * + * @type sai_uint32_t + * @flags READ_ONLY + */ + SAI_POE_DEVICE_ATTR_TOTAL_POWER, + + /** + * @brief total power consumption, in milliwatts + * + * @type sai_uint32_t + * @flags READ_ONLY + */ + SAI_POE_DEVICE_ATTR_POWER_CONSUMPTION, + + /** + * @brief poe device version and information (poe firmware version) + * + * @type char + * @flags READ_ONLY + */ + SAI_POE_DEVICE_ATTR_VERSION, + + /** + * @brief power limit mode + * + * @type sai_poe_device_limit_mode_t + * @flags CREATE_AND_SET + * @default SAI_POE_DEVICE_TYPE_LIMIT_MODE_CLASS_LIMIT + */ + SAI_POE_DEVICE_ATTR_POWER_LIMIT_MODE, +``` + +``` +/** poe device power limit mode + * port limit - max power limit per port is configured by the user + * class limit - max power is set automatically according the class of the connected device + */ +typedef enum _sai_poe_device_type_limit_mode_t +{ + SAI_POE_DEVICE_TYPE_LIMIT_MODE_PORT_LIMIT = 0, + SAI_POE_DEVICE_TYPE_LIMIT_MODE_CLASS_LIMIT = 1 +} sai_poe_device_limit_mode_t; +``` + +### PoE PSE Information + +The get_poe_pse_attribute() and set_poe_pse_attribute() functions can be used to access the following attributes. + +- pse software version +- pse hardware version +- pse temperature +- pse status + +``` +/** + * @brief poe pse PSE software version + * + * @type char + * @flags READ_ONLY + */ + SAI_POE_PSE_ATTR_PSE_SOFTWARE_VERSION, + + /** + * @brief poe pse PSE hardware version + * + * @type char + * @flags READ_ONLY + */ + SAI_POE_PSE_ATTR_PSE_HARDWARE_VERSION, + + /** + * @brief temperature (in Celsius) of the PSE + * + * @type sai_int16_t + * @flags READ_ONLY + */ + SAI_POE_PSE_ATTR_TEMPERATURE, + + /** + * @brief statuses for each PSEs + * + * @type sai_poe_device_pse_status_id_t + * @flags READ_ONLY + */ + SAI_POE_PSE_ATTR_PSE_STATUS, +``` + +``` +/** + * @brief poe device pse (power sourcing equipment) status + */ +typedef enum _sai_poe_device_pse_status_t +{ + SAI_POE_DEVICE_PSE_STATUS_TYPE_ACTIVE = 0, + SAI_POE_DEVICE_PSE_STATUS_TYPE_FAIL = 1, + SAI_POE_DEVICE_PSE_STATUS_TYPE_NOT_PRESENT = 2 +} sai_poe_device_pse_status_t; +``` + +### PoE Port Information + +The get_poe_port_attribute() and set_poe_port_attribute() functions can be used to access the following attributes. + +- poe port standard +- poe port admin enable/disable +- poe port priority +- poe port consumption +- poe port status + +``` +/** + * @brief PoE port standard (af/at/bt...) + * + * @type sai_poe_port_standard_t + * @flags READ_ONLY + * @default SAI_POE_PORT_STANDARD_TYPE_AT + */ + SAI_POE_PORT_ATTR_STANDARD, + + /** + * @brief PoE port enabled/disabled state, as set by the user + * + * @type bool + * @flags CREATE_AND_SET + * @default false + */ + SAI_POE_PORT_ATTR_ADMIN_ENABLED_STATE, + + /** + * @brief PoE port power limit mode + * + * @type sai_uint32_t + * @flags CREATE_AND_SET + * @default maximum value that the port can provide + */ + SAI_POE_PORT_ATTR_POWER_LIMIT, + + /** + * @brief PoE port priority + * + * @type sai_poe_port_power_priority_t + * @flags CREATE_AND_SET + * @default SAI_POE_PORT_POWER_PRIORITY_TYPE_HIGH + */ + SAI_POE_PORT_ATTR_POWER_PRIORITY, + + /** + * @brief PoE port consumption information + * + * @type sai_poe_port_power_consumption_t + * @flags READ_ONLY + */ + SAI_POE_PORT_ATTR_CONSUMPTION, + + /** + * @brief PoE port status of the port status + * + * @type sai_poe_port_status_t + * @flags READ_ONLY + */ + + SAI_POE_PORT_ATTR_STATUS, + + /** + * @brief PoE port detailed status of the port status (string) + * + * @type char + * @flags READ_ONLY + */ + + SAI_POE_PORT_ATTR_DETAILED_STATUS, +``` + +``` +/** + * @brief poe port standard + */ +typedef enum _sai_poe_port_standard_t +{ + SAI_POE_PORT_STANDARD_TYPE_AF = 0, + SAI_POE_PORT_STANDARD_TYPE_AT = 1, + SAI_POE_PORT_STANDARD_TYPE_60W = 2, + SAI_POE_PORT_STANDARD_TYPE_BT_TYPE3 = 3, + SAI_POE_PORT_STANDARD_TYPE_BT_TYPE4 = 4 +} sai_poe_port_standard_t; + +/** + * @brief poe port power priority + */ +typedef enum _sai_poe_port_power_priority_t +{ + SAI_POE_PORT_POWER_PRIORITY_TYPE_LOW = 0, + SAI_POE_PORT_POWER_PRIORITY_TYPE_HIGH = 1, + SAI_POE_PORT_POWER_PRIORITY_TYPE_CRITICAL = 2 +} sai_poe_port_power_priority_t; + +/** + * @brief poe port status + */ +typedef enum _sai_poe_port_status_t +{ + SAI_POE_PORT_STATUS_TYPE_OFF = 0, + SAI_POE_PORT_STATUS_TYPE_SEARCHING = 1, + SAI_POE_PORT_STATUS_TYPE_DELIVERING_POWER = 2, + SAI_POE_PORT_STATUS_TYPE_FAULT = 3 +} sai_poe_port_status_t; + +``` + +``` +/** + * @brief Defines a port consumption structure + * + * Data that is needed and available when a port is delivering power + * + */ +typedef struct _sai_poe_port_power_consumption_t +{ + /** + * @brief active channel: a/b/ab + */ + sai_poe_port_active_channel_type_t active_channel; + + /** + * @brief voltage in milliVolts + */ + uint32_t voltage_in_mv; + + /** + * @brief current in milliAmpere + */ + uint32_t current_in_ma; + + /** + * @brief consumption in milliWatts + */ + uint32_t consumption_in_mw; + + /** + * @brief single or dual signature port + */ + sai_poe_port_signature_type_t signature_type; + + /** + * @brief bt port class method type regular/auto + */ + sai_poe_port_class_method_type_t class_method; + + /** + * @brief measured class for channel a + */ + uint8_t measured_class_a; + + /** + * @brief assigned (final) class for channel a + */ + uint8_t assigned_class_a; + + /** + * @brief dual signature bt port - measured class for channel b + */ + uint8_t measured_class_b; + + /** + * @brief dual signature bt port - assigned (final) class for channel b + */ + uint8_t assigned_class_b; + +} sai_poe_port_power_consumption_t; +``` diff --git a/doc/figures/PoE_Physical_Design.png b/doc/figures/PoE_Physical_Design.png new file mode 100755 index 0000000000..e0e94c3d95 Binary files /dev/null and b/doc/figures/PoE_Physical_Design.png differ diff --git a/inc/sai.h b/inc/sai.h index 0fabbca9d1..f332933646 100644 --- a/inc/sai.h +++ b/inc/sai.h @@ -79,6 +79,7 @@ #include "saigenericprogrammable.h" #include "saitwamp.h" #include "saiversion.h" +#include "saipoe.h" /** * @defgroup SAI SAI - Entry point specific API definitions. @@ -146,6 +147,7 @@ typedef enum _sai_api_t SAI_API_ARS = 48, /** + +/** + * @brief POE device power limit mode + * + * port limit - max power limit per port is configured by the user + * class limit - max power is set automatically according the class of the connected device + */ +typedef enum _sai_poe_device_limit_mode_t +{ + SAI_POE_DEVICE_LIMIT_MODE_PORT = 0, + SAI_POE_DEVICE_LIMIT_MODE_CLASS = 1 +} sai_poe_device_limit_mode_t; + +/** + * @brief POE device PSE (power sourcing equipment) status + */ +typedef enum _sai_poe_pse_status_t +{ + SAI_POE_PSE_STATUS_TYPE_ACTIVE, + SAI_POE_PSE_STATUS_TYPE_FAIL, + SAI_POE_PSE_STATUS_TYPE_NOT_PRESENT, +} sai_poe_pse_status_t; + +/** + * @brief POE port (IEEE) standard + */ +typedef enum _sai_poe_port_standard_t +{ + SAI_POE_PORT_STANDARD_TYPE_AF, + SAI_POE_PORT_STANDARD_TYPE_AT, + SAI_POE_PORT_STANDARD_TYPE_60W, + SAI_POE_PORT_STANDARD_TYPE_BT_TYPE3, + SAI_POE_PORT_STANDARD_TYPE_BT_TYPE4, +} sai_poe_port_standard_t; + +/** + * @brief POE port power priority + */ +typedef enum _sai_poe_port_power_priority_t +{ + SAI_POE_PORT_POWER_PRIORITY_TYPE_LOW, + SAI_POE_PORT_POWER_PRIORITY_TYPE_HIGH, + SAI_POE_PORT_POWER_PRIORITY_TYPE_CRITICAL, +} sai_poe_port_power_priority_t; + +/** + * @brief POE port status + */ +typedef enum _sai_poe_port_status_t +{ + SAI_POE_PORT_STATUS_TYPE_OFF, + SAI_POE_PORT_STATUS_TYPE_SEARCHING, + SAI_POE_PORT_STATUS_TYPE_DELIVERING_POWER, + SAI_POE_PORT_STATUS_TYPE_FAULT, +} sai_poe_port_status_t; + +/** + * @brief POE device attributes + */ +typedef enum _sai_poe_device_attr_t +{ + /** + * @brief Start of attributes + */ + SAI_POE_DEVICE_ATTR_START, + + /** + * @brief Device Information for POE initialization. + * + * Hardware information format is based on POE SAI implementations by vendors. + * Format is vendor specific. + * Example: Like PCI location, I2C address, UART etc. + * + * @type char + * @flags CREATE_ONLY + * @default "" + */ + SAI_POE_DEVICE_ATTR_HARDWARE_INFO = SAI_POE_DEVICE_ATTR_START, + + /** + * @brief A list of all the PSE devices + * + * @type sai_object_list_t + * @flags READ_ONLY + * @objects SAI_OBJECT_TYPE_POE_PSE + */ + SAI_POE_DEVICE_ATTR_POE_PSE_LIST, + + /** + * @brief A list of all the POE ports + * + * @type sai_object_list_t + * @flags READ_ONLY + * @objects SAI_OBJECT_TYPE_POE_PORT + */ + SAI_POE_DEVICE_ATTR_POE_PORT_LIST, + + /** + * @brief The total power in the device, in watts + * + * @type sai_uint32_t + * @flags READ_ONLY + */ + SAI_POE_DEVICE_ATTR_TOTAL_POWER, + + /** + * @brief Total power consumption, in MILLI watts + * + * @type sai_uint32_t + * @flags READ_ONLY + */ + SAI_POE_DEVICE_ATTR_POWER_CONSUMPTION, + + /** + * @brief POE device version and information (POE firmware version) + * + * @type char + * @flags READ_ONLY + */ + SAI_POE_DEVICE_ATTR_VERSION, + + /** + * @brief Power limit mode + * + * @type sai_poe_device_limit_mode_t + * @flags CREATE_AND_SET + * @default SAI_POE_DEVICE_LIMIT_MODE_CLASS + */ + SAI_POE_DEVICE_ATTR_POWER_LIMIT_MODE, + + /** + * @brief End of attributes + */ + SAI_POE_DEVICE_ATTR_END, + + /** Custom range base value */ + SAI_POE_DEVICE_ATTR_CUSTOM_RANGE_START = 0x10000000, + + /** End of custom range base */ + SAI_POE_DEVICE_ATTR_CUSTOM_RANGE_END + +} sai_poe_device_attr_t; + +/** + * @brief POE PSE attributes + */ +typedef enum _sai_poe_pse_attr_t +{ + /** + * @brief Start of attributes + */ + SAI_POE_PSE_ATTR_START, + + /** + * @brief POE PSE ID (index) + * + * @type sai_uint32_t + * @flags MANDATORY_ON_CREATE | CREATE_ONLY + */ + SAI_POE_PSE_ATTR_ID = SAI_POE_PSE_ATTR_START, + + /** + * @brief POE device ID + * + * @type sai_object_id_t + * @flags MANDATORY_ON_CREATE | CREATE_ONLY + * @objects SAI_OBJECT_TYPE_POE_DEVICE + */ + SAI_POE_PSE_ATTR_DEVICE_ID, + + /** + * @brief POE PSE software version + * + * @type char + * @flags READ_ONLY + */ + SAI_POE_PSE_ATTR_SOFTWARE_VERSION, + + /** + * @brief POE PSE hardware version + * + * @type char + * @flags READ_ONLY + */ + SAI_POE_PSE_ATTR_HARDWARE_VERSION, + + /** + * @brief Temperature (in Celsius) of the PSE + * + * @type sai_int16_t + * @flags READ_ONLY + */ + SAI_POE_PSE_ATTR_TEMPERATURE, + + /** + * @brief Status of the PSE + * + * @type sai_poe_pse_status_t + * @flags READ_ONLY + */ + SAI_POE_PSE_ATTR_STATUS, + + /** + * @brief End of attributes + */ + SAI_POE_PSE_ATTR_END, + + /** Custom range base value */ + SAI_POE_PSE_ATTR_CUSTOM_RANGE_START = 0x10000000, + + /** End of custom range base */ + SAI_POE_PSE_ATTR_CUSTOM_RANGE_END + +} sai_poe_pse_attr_t; + +/** + * @brief POE port attributes + */ +typedef enum _sai_poe_port_attr_t +{ + /** + * @brief Start of attributes + */ + SAI_POE_PORT_ATTR_START, + + /** + * @brief POE port front panel ID + * + * @type sai_uint32_t + * @flags MANDATORY_ON_CREATE | CREATE_ONLY + */ + SAI_POE_PORT_ATTR_FRONT_PANEL_ID = SAI_POE_PORT_ATTR_START, + + /** + * @brief POE device ID + * + * @type sai_object_id_t + * @flags MANDATORY_ON_CREATE | CREATE_ONLY + * @objects SAI_OBJECT_TYPE_POE_DEVICE + */ + SAI_POE_PORT_ATTR_DEVICE_ID, + + /** + * @brief POE port standard + * + * @type sai_poe_port_standard_t + * @flags READ_ONLY + */ + SAI_POE_PORT_ATTR_STANDARD, + + /** + * @brief POE port enabled/disabled state, as set by the user + * + * @type bool + * @flags CREATE_AND_SET + * @default false + */ + SAI_POE_PORT_ATTR_ADMIN_ENABLED_STATE, + + /** + * @brief POE port power limit mode + * + * @type sai_uint32_t + * @flags CREATE_AND_SET + * @default 0 + */ + SAI_POE_PORT_ATTR_POWER_LIMIT, + + /** + * @brief POE port priority + * + * @type sai_poe_port_power_priority_t + * @flags CREATE_AND_SET + * @default SAI_POE_PORT_POWER_PRIORITY_TYPE_HIGH + */ + SAI_POE_PORT_ATTR_POWER_PRIORITY, + + /** + * @brief POE port consumption information + * + * @type sai_poe_port_power_consumption_t + * @flags READ_ONLY + */ + SAI_POE_PORT_ATTR_CONSUMPTION, + + /** + * @brief POE port status + * + * @type sai_poe_port_status_t + * @flags READ_ONLY + */ + SAI_POE_PORT_ATTR_STATUS, + + /** + * @brief End of attributes + */ + SAI_POE_PORT_ATTR_END, + + /** Custom range base value */ + SAI_POE_PORT_ATTR_CUSTOM_RANGE_START = 0x10000000, + + /** End of custom range base */ + SAI_POE_PORT_ATTR_CUSTOM_RANGE_END + +} sai_poe_port_attr_t; + +/** + * @brief Create a POE device instance + * + * @param[out] poe_device_id POE device ID + * @param[in] switch_id Switch ID + * @param[in] attr_count Count + * @param[in] attr_list Attribute list values + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_create_poe_device_fn)( + _Out_ sai_object_id_t *poe_device_id, + _In_ sai_object_id_t switch_id, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +/** + * @brief Remove POE device instance. + * + * @param[in] poe_device_id POE device ID + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_remove_poe_device_fn)( + _In_ sai_object_id_t poe_device_id); + +/** + * @brief Set the attribute of POE instance. + * + * @param[in] poe_device_id POE device ID + * @param[in] attr Attribute value + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_set_poe_device_attribute_fn)( + _In_ sai_object_id_t poe_device_id, + _In_ const sai_attribute_t *attr); + +/** + * @brief Get the attribute of POE instance. + * + * @param[in] poe_device_id POE device ID + * @param[in] attr_count Number of the attribute + * @param[inout] attr_list Attribute value + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_get_poe_device_attribute_fn)( + _In_ sai_object_id_t poe_device_id, + _In_ uint32_t attr_count, + _Inout_ sai_attribute_t *attr_list); + +/** + * @brief Create a POE PSE instance + * + * @param[out] poe_pse_id POE PSE ID + * @param[in] switch_id Switch ID + * @param[in] attr_count Count + * @param[in] attr_list Attribute list values + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_create_poe_pse_fn)( + _Out_ sai_object_id_t *poe_pse_id, + _In_ sai_object_id_t switch_id, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +/** + * @brief Remove POE device PSE. + * + * @param[in] poe_pse_id POE PSE ID + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_remove_poe_pse_fn)( + _In_ sai_object_id_t poe_pse_id); + +/** + * @brief Set the attribute of POE PSE. + * + * @param[in] poe_pse_id POE PSE ID + * @param[in] attr Attribute value + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_set_poe_pse_attribute_fn)( + _In_ sai_object_id_t poe_pse_id, + _In_ const sai_attribute_t *attr); + +/** + * @brief Get the attribute of POE PSE. + * + * @param[in] poe_pse_id POE PSE ID + * @param[in] attr_count Number of the attribute + * @param[inout] attr_list Attribute value + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_get_poe_pse_attribute_fn)( + _In_ sai_object_id_t poe_pse_id, + _In_ uint32_t attr_count, + _Inout_ sai_attribute_t *attr_list); + +/** + * @brief Create POE port object + * + * @param[out] poe_port_id POE port id + * @param[in] switch_id Switch ID + * @param[in] attr_count Number of the attribute + * @param[in] attr_list Value of attributes + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_create_poe_port_fn)( + _Out_ sai_object_id_t *poe_port_id, + _In_ sai_object_id_t switch_id, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + +/** + * @brief Remove POE port + * + * @param[in] poe_port_id POE port id + * + * @return #SAI_STATUS_SUCCESS on success, failure status code on error + */ +typedef sai_status_t (*sai_remove_poe_port_fn)( + _In_ sai_object_id_t poe_port_id); + +/** + * @brief Set the attribute of POE port. + * + * @param[in] poe_port_id POE port id + * @param[in] attr Attribute value + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_set_poe_port_attribute_fn)( + _In_ sai_object_id_t poe_port_id, + _In_ const sai_attribute_t *attr); + +/** + * @brief Get the attribute of POE port. + * + * @param[in] poe_port_id POE port id + * @param[in] attr_count Attribute count + * @param[inout] attr_list Attribute value + * + * @return #SAI_STATUS_SUCCESS if operation is successful otherwise a different + * error code is returned. + */ +typedef sai_status_t (*sai_get_poe_port_attribute_fn)( + _In_ sai_object_id_t poe_port_id, + _In_ uint32_t attr_count, + _Inout_ sai_attribute_t *attr_list); + +/** + * @brief POE device method table retrieved with poe_api_query() + */ +typedef struct _sai_poe_api_t +{ + sai_create_poe_device_fn create_poe_device; + sai_remove_poe_device_fn remove_poe_device; + sai_set_poe_device_attribute_fn set_poe_device_attribute; + sai_get_poe_device_attribute_fn get_poe_device_attribute; + sai_create_poe_pse_fn create_poe_pse; + sai_remove_poe_pse_fn remove_poe_pse; + sai_set_poe_pse_attribute_fn set_poe_pse_attribute; + sai_get_poe_pse_attribute_fn get_poe_pse_attribute; + sai_create_poe_port_fn create_poe_port; + sai_remove_poe_port_fn remove_poe_port; + sai_set_poe_port_attribute_fn set_poe_port_attribute; + sai_get_poe_port_attribute_fn get_poe_port_attribute; +} sai_poe_api_t; + +#endif /** __SAIPOE_H_ */ + diff --git a/inc/saiport.h b/inc/saiport.h index f61d39a2fd..04d9155a91 100644 --- a/inc/saiport.h +++ b/inc/saiport.h @@ -2485,6 +2485,16 @@ typedef enum _sai_port_attr_t */ SAI_PORT_ATTR_CABLE_TYPE, + /** + * @brief On NPUs that support POE, read the associated POE port ID + * + * @type sai_object_id_t + * @flags READ_ONLY + * @objects SAI_OBJECT_TYPE_POE_PORT + * @allownull true + */ + SAI_PORT_ATTR_POE_PORT_ID, + /** * @brief End of attributes */ diff --git a/inc/saiswitch.h b/inc/saiswitch.h index ca9da70968..b395c9c9c5 100644 --- a/inc/saiswitch.h +++ b/inc/saiswitch.h @@ -310,6 +310,9 @@ typedef enum _sai_switch_type_t /** Switch type is Fabric switch device */ SAI_SWITCH_TYPE_FABRIC, + /** Switch type is POE (Power over Ethernet) */ + SAI_SWITCH_TYPE_POE, + } sai_switch_type_t; /** @@ -3000,6 +3003,16 @@ typedef enum _sai_switch_attr_t */ SAI_SWITCH_ATTR_AVAILABLE_SYSTEM_VOQS, + /** + * @brief POE device list + * + * @type sai_object_list_t + * @flags CREATE_AND_SET + * @objects SAI_OBJECT_TYPE_POE_DEVICE + * @default empty + */ + SAI_SWITCH_ATTR_POE_DEVICE_LIST, + /** * @brief End of attributes */ diff --git a/inc/saitypes.h b/inc/saitypes.h index dd5d25abcd..3ec3c9984a 100644 --- a/inc/saitypes.h +++ b/inc/saitypes.h @@ -295,6 +295,9 @@ typedef enum _sai_object_type_t SAI_OBJECT_TYPE_ACL_TABLE_CHAIN_GROUP = 105, SAI_OBJECT_TYPE_TWAMP_SESSION = 106, SAI_OBJECT_TYPE_TAM_COUNTER_SUBSCRIPTION = 107, + SAI_OBJECT_TYPE_POE_DEVICE = 108, + SAI_OBJECT_TYPE_POE_PSE = 109, + SAI_OBJECT_TYPE_POE_PORT = 110, /** Must remain in last position */ SAI_OBJECT_TYPE_MAX, @@ -1196,6 +1199,93 @@ typedef struct _sai_port_snr_list_t sai_port_snr_values_t *list; } sai_port_snr_list_t; +/** + * @brief POE port active channel (when delivering power) + */ +typedef enum _sai_poe_port_active_channel_type_t +{ + SAI_POE_PORT_ACTIVE_CHANNEL_TYPE_A, + SAI_POE_PORT_ACTIVE_CHANNEL_TYPE_B, + SAI_POE_PORT_ACTIVE_CHANNEL_TYPE_A_AND_B, +} sai_poe_port_active_channel_type_t; + +/** + * @brief POE port signature type (when delivering power) + */ +typedef enum _sai_poe_port_signature_type_t +{ + SAI_POE_PORT_SIGNATURE_TYPE_SINGLE, + SAI_POE_PORT_SIGNATURE_TYPE_DUAL, +} sai_poe_port_signature_type_t; + +/** + * @brief POE port classification method (when delivering power) + */ +typedef enum _sai_poe_port_class_method_type_t +{ + SAI_POE_PORT_CLASS_METHOD_TYPE_REGULAR, + SAI_POE_PORT_CLASS_METHOD_TYPE_AUTO_CLASS, +} sai_poe_port_class_method_type_t; + +/** + * @brief Defines a port consumption structure + * + * Data that is needed and available when a port is delivering power + */ +typedef struct _sai_poe_port_power_consumption_t +{ + /** + * @brief Active channel: a/b/ab + */ + sai_poe_port_active_channel_type_t active_channel; + + /** + * @brief Voltage in MILLI volts + */ + uint32_t voltage; + + /** + * @brief Current in MILLI ampere + */ + uint32_t current; + + /** + * @brief Consumption in MILLI watts + */ + uint32_t consumption; + + /** + * @brief Single or dual signature port + */ + sai_poe_port_signature_type_t signature_type; + + /** + * @brief IEEE 802.3bt port class method type regular/auto + */ + sai_poe_port_class_method_type_t class_method; + + /** + * @brief Measured class for channel a + */ + uint8_t measured_class_a; + + /** + * @brief Assigned (final) class for channel a + */ + uint8_t assigned_class_a; + + /** + * @brief Dual signature IEEE 802.3bt port - measured class for channel b + */ + uint8_t measured_class_b; + + /** + * @brief Dual signature IEEE 802.3bt port - assigned (final) class for channel b + */ + uint8_t assigned_class_b; + +} sai_poe_port_power_consumption_t; + /** * @brief Enum defining MPLS out segment type */ @@ -1528,6 +1618,10 @@ typedef union _sai_attribute_value_t /** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_PORT_SNR_LIST */ sai_port_snr_list_t portsnrlist; + + /** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION */ + sai_poe_port_power_consumption_t portpowerconsumption; + } sai_attribute_value_t; /** diff --git a/meta/acronyms.txt b/meta/acronyms.txt index eae234496d..2da34a0dc6 100644 --- a/meta/acronyms.txt +++ b/meta/acronyms.txt @@ -86,6 +86,7 @@ LSP - Label Switched Path MAC - Medium Access Control MDIO - Management Data Input/Output MDIX - Medium Dependent Interface Crossover +MILLI - milli (1/1000) MMU - Memory Management Unit MPLS - Multi Protocol Label Switching MTU - Maximum Transmission Unit @@ -104,14 +105,17 @@ PAM4 - Pulse Amplitude Modulation 4-level PBS - Peak Burst Size PCI - Peripheral Component Interconnect PCS - Physical Coding Sublayer +PD - Powered Device PFC - Priority Flow Control PHP - Penultimate Hop Pop PIR - Peak Information Rate PMD - Physical Medium Dependent PMOS - P-channel Metal Oxide Semiconductor PN - Packet Number +POE - Power over Ethernet PRBS - Pseudorandom binary sequence PSC - PHB Scheduling Class +PSE - Power Sourcing Equipment PSP - Penultimate Segment Pop PTP - Precision time protocol QOS - Quality of Service @@ -153,6 +157,7 @@ TOS - Type Of Service TPID - Tag Protocol Identifier TTL - Time to Leave TWAMP - Two-Way Active Measurement Protocol +UART - Universal Asynchronous Receiver/Transmitter UDF - User-Defined Field UDP - User Datagram Protocol USD - Ultimate Segment Decapsulation diff --git a/meta/saimetadatatypes.h b/meta/saimetadatatypes.h index b6b81f4236..19638015f4 100644 --- a/meta/saimetadatatypes.h +++ b/meta/saimetadatatypes.h @@ -490,6 +490,11 @@ typedef enum _sai_attr_value_type_t * @brief Attribute value is statistics data. */ SAI_ATTR_VALUE_TYPE_TWAMP_STATS_DATA, + + /** + * @brief Attribute value is the POE port consumption data. + */ + SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION, } sai_attr_value_type_t; /** diff --git a/meta/saisanitycheck.c b/meta/saisanitycheck.c index e46a1d886c..37e1ef7875 100644 --- a/meta/saisanitycheck.c +++ b/meta/saisanitycheck.c @@ -662,6 +662,7 @@ void check_attr_object_type_provided( case SAI_ATTR_VALUE_TYPE_INT32_LIST: case SAI_ATTR_VALUE_TYPE_UINT8: case SAI_ATTR_VALUE_TYPE_UINT16: + case SAI_ATTR_VALUE_TYPE_INT16: case SAI_ATTR_VALUE_TYPE_VLAN_LIST: case SAI_ATTR_VALUE_TYPE_UINT32: case SAI_ATTR_VALUE_TYPE_UINT64: @@ -729,6 +730,7 @@ void check_attr_object_type_provided( case SAI_ATTR_VALUE_TYPE_PORT_ERR_STATUS_LIST: case SAI_ATTR_VALUE_TYPE_IP_PREFIX_LIST: case SAI_ATTR_VALUE_TYPE_ACL_CHAIN_LIST: + case SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION: if (md->allowedobjecttypes != NULL) { @@ -2759,6 +2761,7 @@ void check_attr_is_primitive( case SAI_ATTR_VALUE_TYPE_OBJECT_ID: case SAI_ATTR_VALUE_TYPE_POINTER: case SAI_ATTR_VALUE_TYPE_UINT16: + case SAI_ATTR_VALUE_TYPE_INT16: case SAI_ATTR_VALUE_TYPE_UINT32: case SAI_ATTR_VALUE_TYPE_UINT32_RANGE: case SAI_ATTR_VALUE_TYPE_UINT64: @@ -2774,6 +2777,7 @@ void check_attr_is_primitive( case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: case SAI_ATTR_VALUE_TYPE_FABRIC_PORT_REACHABILITY: case SAI_ATTR_VALUE_TYPE_LATCH_STATUS: + case SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION: if (!md->isprimitive) {