Skip to content

[device]: Fix a bug that psuutil cannot access gpio sysfs to get PSU status #1789

Merged
jleveque merged 8 commits intomasterfrom
unknown repository
Jun 21, 2018
Merged

[device]: Fix a bug that psuutil cannot access gpio sysfs to get PSU status #1789
jleveque merged 8 commits intomasterfrom
unknown repository

Conversation

@mudsut4ke
Copy link
Copy Markdown
Contributor

- What I did
Fix bug that found on #1781

- How I did it
Update code to support dynamic sysfs gpio base.

- How to verify it
In SONiC run psuutil cli to test the following case:
PSU1: Absence
PSU1: Presence, no-power
PSU2: Absence
PSU1: Presence, no-power

except Exception as error:
logging.error("Unable to export gpio ", pinnum)
logging.error("Unable to export gpio ", str(gpio_base+pinnum))
sys.exit(0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why exit 0 here? the plugin should not do exit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lguohan OK I'll remove it

retval = fd.read()
except Exception as error:
logging.error("Unable to open ", gpio_file, "file !")
sys.exit(0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the plugin should not do exit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lguohan OK I'll remove it

fd.write(str(gpio_base+pinnum))
except Exception as error:
logging.error("Unable to export gpio ", pinnum)
logging.error("Unable to export gpio ", str(gpio_base+pinnum))
Copy link
Copy Markdown
Contributor

@jleveque jleveque Jun 13, 2018

Choose a reason for hiding this comment

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

This is invalid syntax. Please change to

logging.error("Unable to export gpio " + str(gpio_base+pinnum))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, I will change it.

logging.error("Unable to get gpio base")


def init_psu_gpio(self, pinnum):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this init_psu_gpio should move to your driver, we should not do init psu gpio on-the-fly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jleveque, We will update init_psu_gpio after we updated our driver

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pphuchar Please add this to our platform driver

retval = fd.read()
except Exception as error:
logging.error("Unable to open ", gpio_file, "file !")
logging.error("Unable to open " + gpio_file + "file !")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we should further raise in the plugin, retval = 'ERR' is not the convention to convene error to the caller.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK , I will add raise statement to report the error

@@ -53,7 +63,7 @@ def read_psu_statuses(self, pinnum):
with open(gpio_file, 'r') as fd:
retval = fd.read()
except Exception as error:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we should not catch general exception here, we should only catch exception we can handle in this case the io or file exception.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, I will change it

Copy link
Copy Markdown
Contributor

@jleveque jleveque left a comment

Choose a reason for hiding this comment

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

As per Guohan's comments above.

@jleveque jleveque merged commit aaac497 into sonic-net:master Jun 21, 2018
@mudsut4ke mudsut4ke deleted the Add-psuutil-seastone2-dx010 branch June 22, 2018 03:06
tiantianlv pushed a commit to tiantianlv/sonic-buildimage that referenced this pull request Jul 30, 2018
stephenxs added a commit to stephenxs/sonic-buildimage that referenced this pull request Jul 29, 2021
f54b7d0b [Dynamic Buffer Calc][202012]Bug fix: Don't create lossless buffer profile for active ports without speed configured (sonic-net#1820)
ac7f5cff Td2: Reclaim buffer from unused ports (sonic-net#1830)
04105a4b [debugcounterorch] check if counter type is supported before querying (sonic-net#1789)
a67d8af6 [202012][portsorch] fix errors when moving port from one lag to another. (sonic-net#1819)

Signed-off-by: Stephen Sun <stephens@nvidia.com>
volodymyrsamotiy added a commit to volodymyrsamotiy/sonic-buildimage that referenced this pull request Sep 3, 2021
* d240291 Update port_rates & rif_rates lua scripts to convert poll_interval to MS (sonic-net#1855)
* a71a5d3 [acl mirror action] Mirror session ref count fix at acl rule attachment (sonic-net#1761)
* 197f427 Fix vs test failure in test_buffer_traditional (sonic-net#1881)
* 8471f42 Revert "[debugcounterorch] check if counter type is supported before querying… (sonic-net#1789)" (sonic-net#1884)

Signed-off-by: Volodymyr Samotiy <volodymyrs@nvidia.com>
prsunny pushed a commit that referenced this pull request Sep 3, 2021
* d240291 Update port_rates & rif_rates lua scripts to convert poll_interval to MS (#1855)
* a71a5d3 [acl mirror action] Mirror session ref count fix at acl rule attachment (#1761)
* 197f427 Fix vs test failure in test_buffer_traditional (#1881)
* 8471f42 Revert "[debugcounterorch] check if counter type is supported before querying… (#1789)" (#1884)

Signed-off-by: Volodymyr Samotiy <volodymyrs@nvidia.com>
volodymyrsamotiy added a commit to volodymyrsamotiy/sonic-buildimage that referenced this pull request Sep 13, 2021
* d03ba4f [202012] [portstat, intfstat] added rates and utilization  (sonic-net#1812)
* 499ad3f [config reload] Fix config reload failure due to sonic.target job cancellation (sonic-net#1814)
* 96d658c [202012][sonic installer] Add swap setup support (sonic-net#1815)
* a9c6970 platform pre-check for reboot in 202012 branch (sonic-net#1788)
* 0e0478b Unify the number format in the ourput of portstat and pfcstat in all cases (sonic-net#1795)
* 2d1e00e [ecnconfig] Fix exception seen during display and add unit tests (sonic-net#1784) (sonic-net#1789)

Signed-off-by: Volodymyr Samotiy <volodymyrs@nvidia.com>
vivekrnv added a commit to vivekrnv/sonic-buildimage that referenced this pull request Sep 13, 2021
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>

d03ba4fa [202012] [portstat, intfstat] added rates and utilization  (sonic-net#1812)
499ad3f4 [config reload] Fix config reload failure due to sonic.target job cancellation (sonic-net#1814)
96d658c2 [202012][sonic installer] Add swap setup support (sonic-net#1815)
a9c69702 platform pre-check for reboot in 202012 branch (sonic-net#1788)
0e0478ba Unify the number format in the ourput of portstat and pfcstat in all cases (sonic-net#1795)
2d1e00ed [ecnconfig] Fix exception seen during display and add unit tests (sonic-net#1784) (sonic-net#1789)
lguohan pushed a commit that referenced this pull request Sep 14, 2021
* d03ba4f [202012] [portstat, intfstat] added rates and utilization  (#1812)
* 499ad3f [config reload] Fix config reload failure due to sonic.target job cancellation (#1814)
* 96d658c [202012][sonic installer] Add swap setup support (#1815)
* a9c6970 platform pre-check for reboot in 202012 branch (#1788)
* 0e0478b Unify the number format in the ourput of portstat and pfcstat in all cases (#1795)
* 2d1e00e [ecnconfig] Fix exception seen during display and add unit tests (#1784) (#1789)

Signed-off-by: Volodymyr Samotiy <volodymyrs@nvidia.com>
theasianpianist pushed a commit to theasianpianist/sonic-buildimage that referenced this pull request Feb 5, 2022
sonic-net#1789)

* [debugcounterorch] check if counter type is supported before querying object availability count
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
lipxu added a commit to lipxu/sonic-buildimage that referenced this pull request Mar 11, 2026
… image

Add SAI_STATS_EXT_SWITCH_SUPPORTED=0 to sai.profile for Arista 7060cx
(BCM56960/Tomahawk-1) to disable sai_get_stats_ext for switch objects.
The legacy SAI binary crashes when FlexCounter calls sai_get_stats_ext
on switch objects during polling.

The runtime guard is implemented in sonic-sairedis PR sonic-net#1789.

Signed-off-by: Liping Xu <xuliping@microsoft.com>
lipxu added a commit to lipxu/sonic-buildimage that referenced this pull request Mar 16, 2026
… image

Add SAI_STATS_EXT_SWITCH_SUPPORTED=0 to sai.profile for Arista 7060cx
(BCM56960/Tomahawk-1) to disable sai_get_stats_ext for switch objects.
The legacy SAI binary crashes when FlexCounter calls sai_get_stats_ext
on switch objects during polling.

The runtime guard is implemented in sonic-sairedis PR sonic-net#1789.

Signed-off-by: Liping Xu <xuliping@microsoft.com>
StormLiangMS pushed a commit that referenced this pull request Mar 17, 2026
… image (#26014)

* BROADCOM_LEGACY_SAI_COMPAT: Fix sai_get_stats_ext crash on TH1 legacy image

Add SAI_STATS_EXT_SWITCH_SUPPORTED=0 to sai.profile for Arista 7060cx
(BCM56960/Tomahawk-1) to disable sai_get_stats_ext for switch objects.
The legacy SAI binary crashes when FlexCounter calls sai_get_stats_ext
on switch objects during polling.

The runtime guard is implemented in sonic-sairedis PR #1789.

Signed-off-by: Liping Xu <xuliping@microsoft.com>

* BROADCOM_LEGACY_SAI_COMPAT: Add missing Q32 HWSKU sai.profile.j2 keys for TH1

Arista-7060CX-32S-Q32 uses a Jinja2 template (sai.profile.j2) rather than
a static sai.profile. Add SAI_STATS_ST_CAPABILITY_SUPPORTED=0 and
SAI_STATS_EXT_SWITCH_SUPPORTED=0 to cover Q32 as well as the other
Arista-7060CX-32S HWSKUs.

Signed-off-by: Liping Xu <xuliping@microsoft.com>

* BROADCOM_LEGACY_SAI_COMPAT: Fix Q32 sai.profile.j2 - restore single quotes, keep SAI keys

Restore original Jinja2 single-quote style (changed unintentionally in the
previous commit). Only intended change is adding SAI_STATS_ST_CAPABILITY_SUPPORTED=0
and SAI_STATS_EXT_SWITCH_SUPPORTED=0 for TH1/BCM56960.

Signed-off-by: Liping Xu <xuliping@microsoft.com>

---------

Signed-off-by: Liping Xu <xuliping@microsoft.com>
mssonicbld added a commit to mssonicbld/sonic-buildimage that referenced this pull request Mar 17, 2026
… image

#### Why I did it

On Arista 7060cx (BCM56960/Tomahawk-1) running the broadcom-legacy image, syncd crashes inside `sai_get_stats_ext` during FlexCounter polling for switch objects. The legacy SAI binary does not support `sai_get_stats_ext` for switch objects on TH1.

Root cause: sonic-sairedis PR sonic-net#1775 set `use_sai_stats_ext = true` for `COUNTER_TYPE_SWITCH` in `FlexCounter::createCounterContext()`. This is needed for TH5 but causes a crash on TH1 with the legacy SAI binary.

##### Work item tracking
- Microsoft ADO **(number only)**:

#### How I did it

Add `SAI_STATS_EXT_SWITCH_SUPPORTED=0` to `sai.profile` for all Arista 7060cx HWSKUs (BCM56960/Tomahawk-1). The runtime guard in syncd (sonic-sairedis PR sonic-net#1789) reads this key and sets `use_sai_stats_ext = false` for switch counter contexts on this platform.

Files changed:
- `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S/sai.profile`
- `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-C32/sai.profile`
- `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-D48C8/sai.profile`
- `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-Q24C8/sai.profile`
- `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-T96C8/sai.profile`

#### How to verify it

1. Build a broadcom-legacy SONiC image for Arista 7060cx
2. Boot the device and enable FlexCounter for switch objects
3. Confirm syncd does not crash during FlexCounter polling
4. Confirm switch counter stats are still collected (via non-ext path)

#### Which release branch to backport (provide reason below if selected)

These are bug fixes for broadcom-legacy platform (TH1). The crashes are present in 202511.

- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
- [x] 202511

#### Tested branch (Please provide the tested image version)

- [x] <!-- image version 1 --> 20251110.15 (broadcom-legacy, Arista 7060cx)

#### Description for the changelog

BROADCOM_LEGACY_SAI_COMPAT: Add sai.profile key to disable sai_get_stats_ext for switch objects on Arista 7060cx (TH1) to prevent syncd crash during FlexCounter polling on broadcom-legacy image.

#### Link to config_db schema for YANG module changes

N/A — sai.profile change only, no config_db schema impact.

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

🐧

Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
mssonicbld added a commit that referenced this pull request Mar 17, 2026
…tically (#26221)

#### Why I did it
src/sonic-sairedis
```
* 4758c3cc - (HEAD -> master, origin/master, origin/HEAD) BROADCOM_LEGACY_SAI_COMPAT: Fix sai_get_stats_ext crash on Tomahawk-1 (BCM56960) legacy platforms (#1789) (20 hours ago) [Liping Xu]
* 78470325 - BROADCOM_LEGACY_SAI_COMPAT: Fix sai_query_stats_st_capability crash on Tomahawk-1 (BCM56960) legacy platforms (#1788) (23 hours ago) [Liping Xu]
```
#### How I did it
#### How to verify it
#### Description for the changelog
mssonicbld added a commit that referenced this pull request Mar 17, 2026
… image (#26217)

#### Why I did it

On Arista 7060cx (BCM56960/Tomahawk-1) running the broadcom-legacy image, syncd crashes inside `sai_get_stats_ext` during FlexCounter polling for switch objects. The legacy SAI binary does not support `sai_get_stats_ext` for switch objects on TH1.

Root cause: sonic-sairedis PR #1775 set `use_sai_stats_ext = true` for `COUNTER_TYPE_SWITCH` in `FlexCounter::createCounterContext()`. This is needed for TH5 but causes a crash on TH1 with the legacy SAI binary.

##### Work item tracking
- Microsoft ADO **(number only)**:

#### How I did it

Add `SAI_STATS_EXT_SWITCH_SUPPORTED=0` to `sai.profile` for all Arista 7060cx HWSKUs (BCM56960/Tomahawk-1). The runtime guard in syncd (sonic-sairedis PR #1789) reads this key and sets `use_sai_stats_ext = false` for switch counter contexts on this platform.

Files changed:
- `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S/sai.profile`
- `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-C32/sai.profile`
- `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-D48C8/sai.profile`
- `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-Q24C8/sai.profile`
- `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-T96C8/sai.profile`

#### How to verify it

1. Build a broadcom-legacy SONiC image for Arista 7060cx
2. Boot the device and enable FlexCounter for switch objects
3. Confirm syncd does not crash during FlexCounter polling
4. Confirm switch counter stats are still collected (via non-ext path)

#### Which release branch to backport (provide reason below if selected)

These are bug fixes for broadcom-legacy platform (TH1). The crashes are present in 202511.

- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
- [x] 202511

#### Tested branch (Please provide the tested image version)

- [x] <!-- image version 1 --> 20251110.15 (broadcom-legacy, Arista 7060cx)

#### Description for the changelog

BROADCOM_LEGACY_SAI_COMPAT: Add sai.profile key to disable sai_get_stats_ext for switch objects on Arista 7060cx (TH1) to prevent syncd crash during FlexCounter polling on broadcom-legacy image.

#### Link to config_db schema for YANG module changes

N/A — sai.profile change only, no config_db schema impact.

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

🐧

Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
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.

5 participants