Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sonic-net/sonic-sairedis
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 87d5a3ea3e877f2e311f711bf418123814256fc6
Choose a base ref
...
head repository: sonic-net/sonic-sairedis
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a1796a53cc7ad87fe715e49e70dc4cda6a838863
Choose a head ref
  • 1 commit
  • 11 files changed
  • 1 contributor

Commits on Aug 26, 2022

  1. Add support of mdio IPC server class using sai switch api and unix so…

    …cket (#1080)
    
    Why I did it
    When MDIO devices (external PHYs) are connected on MDIO bus from NPU, the MDIO access is through SAI switch mdio read/write APIs. The syncd calling the SAI APIs needs to act as an IPC server so that the gbsyncd programming the MDIO devices can use the APIs by the IPC mechanism.
    
    How I did it
    MdioIpcServer class is added to start a new thread, to create an unix socket, to listen on the socket, to accept connection and to read/reply IPC messages. The corresponding functions for MDIO clause 45 and clause 22 access are also added to VendorSai class.
    
    How to verify it
    We can use socat to simulate the IPC client, e.g.
    docker exec -it syncd socat - UNIX-CONNECT:/var/run/sswsyncd/mdio-ipc.srv
    to read MDIO clause 45 register at an address and an offset
    mdio <address> <reg offset>
    to write MDIO clause 45 register at an address and an offset with a value
    mdio <address> <reg offset> <value>
    to read MDIO clause 22 register at an address and an offset
    mdio-cl22 <address> <reg offset>
    to write MDIO clause 22 register at an address and an offset with a value
    mdio-cl22 <address> <reg offset> <value>
    
    Signed-off-by: Jiahua Wang <[email protected]>
    jiahua-wang authored and yxieca committed Aug 26, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a1796a5 View commit details
Showing with 728 additions and 0 deletions.
  1. +1 −0 configure.ac
  2. +48 −0 meta/SaiInterface.cpp
  3. +28 −0 meta/SaiInterface.h
  4. +5 −0 syncd/Makefile.am
  5. +472 −0 syncd/MdioIpcServer.cpp
  6. +60 −0 syncd/MdioIpcServer.h
  7. +14 −0 syncd/Syncd.cpp
  8. +3 −0 syncd/Syncd.h
  9. +64 −0 syncd/VendorSai.cpp
  10. +28 −0 syncd/VendorSai.h
  11. +5 −0 tests/aspell.en.pws
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ AX_CODE_COVERAGE
AX_ADD_AM_MACRO_STATIC([])

AM_CONDITIONAL(SONIC_ASIC_PLATFORM_BAREFOOT, test x$CONFIGURED_PLATFORM = xbarefoot)
AM_CONDITIONAL(SONIC_ASIC_PLATFORM_BROADCOM, test x$CONFIGURED_PLATFORM = xbroadcom)

AC_ARG_ENABLE(debug,
[ --enable-debug turn on debugging],
48 changes: 48 additions & 0 deletions meta/SaiInterface.cpp
Original file line number Diff line number Diff line change
@@ -197,3 +197,51 @@ sai_status_t SaiInterface::get(
return SAI_STATUS_FAILURE;
}
}

sai_status_t SaiInterface::switchMdioRead(
_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)
{
SWSS_LOG_ENTER();

return SAI_STATUS_FAILURE;
}

sai_status_t SaiInterface::switchMdioWrite(
_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)
{
SWSS_LOG_ENTER();

return SAI_STATUS_FAILURE;
}

sai_status_t SaiInterface::switchMdioCl22Read(
_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)
{
SWSS_LOG_ENTER();

return SAI_STATUS_FAILURE;
}

sai_status_t SaiInterface::switchMdioCl22Write(
_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)
{
SWSS_LOG_ENTER();

return SAI_STATUS_FAILURE;
}
28 changes: 28 additions & 0 deletions meta/SaiInterface.h
Original file line number Diff line number Diff line change
@@ -222,6 +222,34 @@ namespace sairedis
_In_ uint32_t attrCount,
_In_ const sai_attribute_t *attrList) = 0;

virtual sai_status_t switchMdioRead(
_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);

virtual sai_status_t switchMdioWrite(
_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);

virtual sai_status_t switchMdioCl22Read(
_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);

virtual sai_status_t switchMdioCl22Write(
_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);

public: // SAI API

virtual sai_status_t objectTypeGetAvailability(
5 changes: 5 additions & 0 deletions syncd/Makefile.am
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ libSyncd_a_SOURCES = \
FlexCounterManager.cpp \
GlobalSwitchId.cpp \
HardReiniter.cpp \
MdioIpcServer.cpp \
MetadataLogger.cpp \
NotificationHandler.cpp \
NotificationProcessor.cpp \
@@ -71,6 +72,10 @@ syncd_CXXFLAGS += -DSAITHRIFT=yes
syncd_LDADD += -lrpcserver -lthrift
endif

if SONIC_ASIC_PLATFORM_BROADCOM
libSyncd_a_CXXFLAGS += -DMDIO_ACCESS_USE_NPU
endif

libSyncdRequestShutdown_a_SOURCES = \
RequestShutdown.cpp \
RequestShutdownCommandLineOptions.cpp \
Loading