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

fixed sfputil error #3579

Merged
merged 2 commits into from
Oct 9, 2019
Merged

fixed sfputil error #3579

merged 2 commits into from
Oct 9, 2019

Conversation

JohnsonYJLu
Copy link
Contributor

modify module and python file

Signed-off-by: johnson <JOHNSON.LU@deltaww.com>
Comment on lines -569 to +580
/*QSFP1~8*/
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_1);
data = (u32)(reverse_8bits(ret) & 0xff);
/*QSFP9~16*/
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_2);
data |= (u32)(reverse_8bits(ret) & 0xff) << 8;
/*QSFP17~24*/
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_3);
data |= (u32)(reverse_8bits(ret) & 0xff) << 16;
/*QSFP25~32*/
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_4);
data |= (u32)(reverse_8bits(ret) & 0xff) << 24;
data = (u32)ret & 0xff;
/*QSFP17~24*/
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_3);
data |= ((u32)ret & 0xff) << 8;
/*QSFP9~16*/
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_2);
data |= (u32)(ret & 0xff) << 16;
/*QSFP1~8*/
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_1);
data |= (u32)(ret & 0xff) << 24;
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about reading from _1 to _4 but shift the data position first and | with return value for each reading, something like below?
data = (data<<8)|((u32)(ret&0xff))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attribute is show all present result like 0xFFFF from port1 to port 32.

Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of moving ret value with different shifting value, shifting the data 8bit to the left each time before or-ing the ret value will give same shifting for each ret value. then only 8bit shifter not three different shifter (8bit, 16bit, and 24bit).
'''
data=0;
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_1);
data <<8;
data |= (u32)ret&0xff;
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_2);
data <<8;
data |= (u32)ret&0xff;
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_3);
data <<8;
data |= (u32)ret&0xff;
ret = i2c_smbus_read_byte_data(pdata1[swpld1].client, QSFP_PRESENCE_4);
data <<8;
data |= (u32)ret&0xff;
'''
you can make it more simpler with macro definition too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

but this is recommendation not blocking

Signed-off-by: johnson <JOHNSON.LU@deltaww.com>
@lguohan lguohan merged commit 41e855c into sonic-net:master Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants