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

Add switch api for clause 22 mdio access #1507

Merged
merged 5 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
42 changes: 42 additions & 0 deletions inc/saiswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -3096,6 +3096,46 @@ typedef sai_status_t (*sai_switch_mdio_write_fn)(
_In_ uint32_t number_of_registers,
_In_ const uint32_t *reg_val);

/**
* @brief Switch MDIO clause 22 read API
*
* Provides clause 22 read access API for devices connected to MDIO from NPU SAI.
*
* @objects switch_id SAI_OBJECT_TYPE_SWITCH
*
* @param[in] switch_id Switch Id
* @param[in] device_addr Device address(PHY/lane/port MDIO address)
* @param[in] start_reg_addr Starting register address to read
* @param[in] number_of_registers Number of consecutive registers to read
* @param[out] reg_val Register read values
*/
typedef sai_status_t (*sai_switch_mdio_cl22_read_fn)(
Copy link
Contributor

Choose a reason for hiding this comment

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

Type sai_switch_mdio_cl22_read_fn is same as sai_switch_mdio_read_fn. It looks not needed to define it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the first commit: 912c4c4 The new cl22 functions had the type you suggested. But it would not pass the parse.pl sanity check. I changed the cl22 function to the new type in the last commit: 0fb1c06

_In_ sai_object_id_t switch_id,
_In_ uint32_t device_addr,
_In_ uint32_t start_reg_addr,
_In_ uint32_t number_of_registers,
_Out_ uint32_t *reg_val);

/**
* @brief Switch MDIO clause write API
*
* Provides clause 22 write access API for devices connected to MDIO from NPU SAI.
*
* @objects switch_id SAI_OBJECT_TYPE_SWITCH
*
* @param[in] switch_id Switch Id
* @param[in] device_addr Device address(PHY/lane/port MDIO address)
* @param[in] start_reg_addr Starting register address to write
* @param[in] number_of_registers Number of consecutive registers to write
* @param[in] reg_val Register write values
*/
typedef sai_status_t (*sai_switch_mdio_cl22_write_fn)(
_In_ sai_object_id_t switch_id,
_In_ uint32_t device_addr,
_In_ uint32_t start_reg_addr,
_In_ uint32_t number_of_registers,
_In_ const uint32_t *reg_val);

/**
* @brief Create switch
*
Expand Down Expand Up @@ -3272,6 +3312,8 @@ typedef struct _sai_switch_api_t
sai_remove_switch_tunnel_fn remove_switch_tunnel;
sai_set_switch_tunnel_attribute_fn set_switch_tunnel_attribute;
sai_get_switch_tunnel_attribute_fn get_switch_tunnel_attribute;
sai_switch_mdio_cl22_read_fn switch_mdio_cl22_read;
sai_switch_mdio_cl22_write_fn switch_mdio_cl22_write;
Copy link
Contributor

Choose a reason for hiding this comment

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

It can be:

sai_switch_mdio_read_fn          switch_mdio_cl22_read
sai_switch_mdio_write_fn         switch_mdio_cl22_write

Copy link
Contributor Author

@jiahua-wang jiahua-wang Aug 4, 2022

Choose a reason for hiding this comment

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

In the first commit: 912c4c4 The new cl22 functions had the type you suggested. But it would not pass the parse.pl sanity check. I changed the cl22 function to the new type in the last commit: 0fb1c06


} sai_switch_api_t;

Expand Down
4 changes: 4 additions & 0 deletions meta/style.pm
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ sub CheckFunctionsParams
next if $fname eq "sai_switch_register_read_fn";
next if $fname eq "sai_switch_mdio_write_fn";
next if $fname eq "sai_switch_mdio_read_fn";
next if $fname eq "sai_switch_mdio_cl22_write_fn";
next if $fname eq "sai_switch_mdio_cl22_read_fn";

my @paramsFlags = lc($comment) =~ /\@param\[(\w+)]/gis;
my @fnparamsFlags = lc($fn) =~ /_(\w+)_.+?(?:\.\.\.|\w+)\s*[,\)]/gis;
Expand Down Expand Up @@ -448,6 +450,8 @@ sub CheckFunctionNaming
send_hostif_packet
switch_mdio_read
switch_mdio_write
switch_mdio_cl22_read
switch_mdio_cl22_write
switch_register_read
switch_register_write);

Expand Down