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 mdio register read/write via rpc #1084

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jimmyzhai
Copy link
Contributor

No description provided.

Copy link
Collaborator

@kcudnik kcudnik left a comment

Choose a reason for hiding this comment

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

address comments

Comment on lines +254 to +261
typedef enum _sai_redis_switch_register_fn_t
{
SAI_REDIS_SWITCH_REGISTER_FN_NULL = 0,
SAI_REDIS_SWITCH_REGISTER_FN_MDIO_CL22_READ,
SAI_REDIS_SWITCH_REGISTER_FN_MDIO_CL22_WRITE,
SAI_REDIS_SWITCH_REGISTER_FN_MDIO_CL45_READ,
SAI_REDIS_SWITCH_REGISTER_FN_MDIO_CL45_WRITE,
} sai_redis_switch_register_fn_t;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why this is not the peart of SAI ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

no need for zero

static constexpr uint32_t IPC_TIMEOUT_SEC = 2; // in seconds
static constexpr char IPC_SERVER[] = "/var/run/redis/syncd.sock";

class Ipc: public swss::Selectable
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be ipcserver ?
also move public swss::Selectable to next line

Comment on lines +55 to +58
if (m_sock >= 0)
{
close(m_sock);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

move implemntation to cpp file

Comment on lines +61 to +67
std::shared_ptr<RpcStub> rpcAt(int rpc) const;
void registerRpc(const std::shared_ptr<RpcStub> &stub);

int sendto(const IpcMsg *msg, const struct sockaddr *dest_addr, socklen_t addrlen);
int recvfrom(IpcMsg *msg, int size, struct sockaddr *src_addr, socklen_t *addrlen);
int send(const IpcMsg *msg);
int recv(IpcMsg *msg, int size);
Copy link
Collaborator

Choose a reason for hiding this comment

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

all pamameters inlcuding constructor should be 1 per line and have prefix specifier In or Out etc, take a look at ohter files .h

std::unordered_map<int, std::shared_ptr<RpcStub>> m_rpcMap;
};

class IpcClient: public Ipc
Copy link
Collaborator

Choose a reason for hiding this comment

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

move to separate file IpcClient.cpp

uint32_t reg_data[0];
};

class RpcMdio: public RpcStub {
Copy link
Collaborator

Choose a reason for hiding this comment

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

file hsould be named as class name

if (m_ipcServer && m_switches.size() == 1)
{
m_ipcServer->setSwitchId(objectRid);
m_ipcServer->setSwitchApi(dynamic_cast<VendorSai*>(m_vendorSai.get())->get_switch_api());
Copy link
Collaborator

Choose a reason for hiding this comment

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

dont use get_swutch_api, provide VendorSai instead and expose mdio api functions

* If IPC server is enabled, it needs to remember switch object rid and
* switch api, used by the calling of switch_mdio_read/write.
*/
if (m_ipcServer && m_switches.size() == 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this will onlyu work for first switch and possible if many will be created then this will not be executed

@@ -1270,3 +1270,10 @@ sai_status_t VendorSai::logSet(

return sai_log_set(api, log_level);
}

const sai_switch_api_t* VendorSai::get_switch_api(void) const
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remove and expose proper apis for mdio

Copy link
Collaborator

Choose a reason for hiding this comment

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

in SaiInterface.h

@@ -30,6 +30,8 @@ namespace syncd

sai_status_t uninitialize(void) override;

const sai_switch_api_t* get_switch_api(void) const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants