Skip to content

Commit

Permalink
Add switch api for clause 22 mdio access (#1507)
Browse files Browse the repository at this point in the history
    Why I did it
    There are 2 mdio access modes: clause 45 and clause 22. The existing sai
    switch api "switch_mdio_read/switch_mdio_write" does not distinguish the
    2 modes.

    How I did it
    The new sai switch api "switch_mdio_cl22_ead/switch_mdio_cl22_write" are
    added for clause 22 mdio access only.

    How to verify it
    On a platform with mdio clause 22 device connected to NPU mdio bus,
    PAI/gearbox will only work with the new new sai switch api when there is
    no other means to configure the mdio access mode.

Signed-off-by: Jiahua Wang <jiahua.wang@broadcom.com>
  • Loading branch information
jiahua-wang authored Oct 10, 2022
1 parent 19f10ac commit 1b268a8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
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)(
_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;

} 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

0 comments on commit 1b268a8

Please sign in to comment.