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

CISCO: Provide support for platform hooks in syncd.sh #7331

Closed
wants to merge 2 commits into from
Closed

CISCO: Provide support for platform hooks in syncd.sh #7331

wants to merge 2 commits into from

Conversation

VenkatCisco
Copy link
Contributor

Why I did it

This is a platform agnostic & vendor agnostic change to files/scripts/syncd.sh to check if 'platform' entry exists in the DEVICE_METADATA table. If it exits it checks if there is a file to source and hence does the needful.

How to verify it

This is a PR followup from the code-review discussion we had with Guhon/Rita and team. This also addresses one of the comment that was raised to convert to sourcing a file instead of executing the same., so the logic within is run in the same shell.

How I did it#### Which release branch to backport (provide reason below if selected)

  • [x ] 201811
  • [x ] 201911
  • 202006
  • 202012

Description for the changelog

A picture of a cute animal (not mandatory but encouraged)

@VenkatCisco VenkatCisco requested a review from lguohan as a code owner April 15, 2021 04:12
@@ -28,6 +28,10 @@ function startplatform() {
debug "Firmware update procedure ended"
fi

PLATFORM_DIR=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not use $sonic_asic_platform?

Copy link
Collaborator

Choose a reason for hiding this comment

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

if we want to do this one, we should inject the hook for all functions startplatform, waitplatform, stopplatform1, and stopplatform2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

and we should also refactor the existing code to use this platform hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why not use $sonic_asic_platform?

$sonic_asic_platform does not provide platform agnostic approach to otherwise a Platform Independent SONiC code under files/scripts path. Given that this is a run time check, using DEVICE_METADATA seems more as a generic approach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and we should also refactor the existing code to use this platform hook.

I agree with refactoring the existing code. The whole code has vendor hooks and is not maintainable. I can look into that approach.

Can that be considered as a different exercise given we have dependencies with other vendors using this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

startplatform, waitplatform, stopplatform1, and stopplatform2.

Presently, we need platform hooks for startplatform() API only. This is an easily extendable hook for any other function. We see an opportunity to restructure files/scripts/syncd.sh to pursue the following instead of making vendor specific calls from each function:

function startplatform () {
F="/usr/share/sonic/device/$PLATFORM_DIR/scripts/startplatform_routines.sh"
[ -x $F ] && $F start $DEV
}

function stopplatform() {
F="/usr/share/sonic/device/$PLATFORM_DIR/scripts/stopplatform_routines.sh"
[ -x $F ] && $F start $DEV
}

...
PLATFORM_DIR=sonic-cfggen -H -v DEVICE_METADATA.localhost.platform

case "$1" in
start|wait|stop)
$1
;;
*)
echo "Usage: $0 {start|wait|stop}"
exit 1
;;
esac

Copy link
Collaborator

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

as comments.

@VenkatCisco
Copy link
Contributor Author

as comments.

you mean 'add comments'. Done.

@garigipati31
Copy link

Hi Guhon, please let me know if there is anything to be addressed further.

@anshuv-mfst
Copy link

PR Scrum meeting 5/4:
Guohan: this should be asic specific and not platform specific. Please replace platform DIR with sonic_asic_platform.
Customization is asic specific.

@anshuv-mfst
Copy link

Hi @lguohan - please review and approve, thanks.

@VenkatCisco
Copy link
Contributor Author

Closing ; Tracked via #7635

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.

4 participants