Use MAC from EEPROM for Interfaces#329
Merged
lguohan merged 3 commits intosonic-net:masterfrom Jul 3, 2018
Merged
Conversation
Merge current master to 201803
Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
qiluo-msft
approved these changes
Jun 12, 2018
Contributor
|
Please fix the test. #Closed |
qiluo-msft
reviewed
Jun 12, 2018
syncd/scripts/syncd_init_common.sh
Outdated
|
|
||
| # Read MAC address and align the last 6 bits. | ||
| MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}') | ||
| MAC_ADDRESS=$(od -vt x1 -An /sys/bus/i2c/devices/8-0051/eeprom | xargs printf "0x%s " | xargs printf "%02x:" | awk 'BEGIN { FS=":"; i=8+1+2+1} {while(i<NF) {type=$i; len=("0x"$(i+1));if(type!="24") {i=i+2+len} else {print substr($0, (i+1)*3+1, len*3-1); break}}}') |
Contributor
There was a problem hiding this comment.
Consider to use python -c to simplify the manipulation. #Closed
qiluo-msft
requested changes
Jun 12, 2018
Contributor
qiluo-msft
left a comment
There was a problem hiding this comment.
Fixing testing is required. Code improvement is not necessary but highly suggested.
Contributor
Author
|
ok |
Contributor
Author
|
retest this please |
Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
| # Read MAC address and align the last 6 bits. | ||
| MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}') | ||
| MAC_ADDRESS=$(sonic-cfggen -d -v DEVICE_METADATA.localhost.mac) | ||
| last_byte=$(python -c "print '$MAC_ADDRESS'[-2:]") |
Contributor
Author
There was a problem hiding this comment.
probably I can remove last byte masking as it is already done for the MAC in DB
qiluo-msft
approved these changes
Jun 27, 2018
lguohan
pushed a commit
that referenced
this pull request
Oct 13, 2018
* Use MAC from EEPROM for Interfaces Signed-off-by: Andriy Moroz <c_andriym@mellanox.com> * Use platform MAC from DB Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
volodymyrsamotiy
pushed a commit
to volodymyrsamotiy/sonic-sairedis
that referenced
this pull request
Jul 30, 2019
* Use MAC from EEPROM for Interfaces Signed-off-by: Andriy Moroz <c_andriym@mellanox.com> * Use platform MAC from DB Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
pettershao-ragilenetworks
pushed a commit
to pettershao-ragilenetworks/sonic-sairedis
that referenced
this pull request
Nov 18, 2022
* Use MAC from EEPROM for Interfaces Signed-off-by: Andriy Moroz <c_andriym@mellanox.com> * Use platform MAC from DB Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Andriy Moroz c_andriym@mellanox.com
- What I did
Updated syncd init script to pass MAC from EEPROM to SAI for Mellanox platforms. Interfaces will be created with this MAC
- How I did it
updated syncd init script (syncd_init_common.sh)
- How to verify it
Start SONiC and make sure MACs on Interfaces are similar to one returned by command
od -vt x1 -An /sys/bus/i2c/devices/8-0051/eeprom | xargs printf "0x%s " | xargs printf "%02x:" | awk 'BEGIN { FS=":"; i=8+1+2+1} {while(i<NF) {type=$i; len=("0x"$(i+1));if(type!="24") {i=i+2+len} else {print substr($0, (i+1)3+1, len3-1); break}}}'
some bits in last byte may differ