Skip to content

fixed sfputil error#3579

Merged
lguohan merged 2 commits intosonic-net:masterfrom
JohnsonYJLu:ag9032v2a
Oct 9, 2019
Merged

fixed sfputil error#3579
lguohan merged 2 commits intosonic-net:masterfrom
JohnsonYJLu:ag9032v2a

Conversation

@JohnsonYJLu
Copy link
Contributor

modify module and python file

Signed-off-by: johnson <[email protected]>
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

@lguohan lguohan merged commit 41e855c into sonic-net:master Oct 9, 2019
mssonicbld added a commit that referenced this pull request Oct 19, 2024
…atically (#20546)

#### Why I did it
src/sonic-utilities
```
* 4a6d121 - (HEAD -> master, origin/master, origin/HEAD) [doc] correct the fec histogram output for show int counters fec-histogram (#3579) (9 hours ago) [vdahiya12]
```
#### How I did it
#### How to verify it
#### Description for the changelog
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