Skip to content

Instantly share code, notes, and snippets.

@nmicic
Created October 3, 2023 22:19
Show Gist options
  • Select an option

  • Save nmicic/39fef3032d20573fdeb002b9353b211b to your computer and use it in GitHub Desktop.

Select an option

Save nmicic/39fef3032d20573fdeb002b9353b211b to your computer and use it in GitHub Desktop.
crypto_chip_detect.sh
#!/bin/sh
# To run:
#
# chmod +x crypto_chip_detect.sh;
# ./crypto_chip_detect.sh support_summary
#
# In short script check Alloc-Free for crypto counters which will be very low for working cards - usually less then 100 or more around 10.
# Note threshold is set to 3000, in some corener cases during very high load may go to this value, but will go back in second back to low value.
# BUT, if you see 4 lines: Issue deteceted delta for same card then it is 100% crypto chip issue.
# This threshold is assumed as we are little bit bellow 4K buffers. In 21.28.mX buffers are increased to 4k. In older version this could be close to 1K.
# If not sure get multiple SSD to confirm.
test ! -f $1 && echo "ERROR file doesn't exist:" $1 && exit
SSD=$1
cat /dev/null > ucad_out.txt
grep -A 100 'Crypto Sub-system: UCAD' $SSD | grep -e ^Card -e Free -e Alloc | awk -F'|' '{print $1"\n" $2}' | sed -e "s/^ //g" | grep -v ' 0' | grep -v Window | grep -v Init | grep -v poll | grep -v ^$ > ucad_out.txt;
cat ucad_out.txt | awk 'BEGIN{threshold=3000;} {if(/Card/){card=$0;print}
if(/^ESP Pkts Alloc/){ESPPktsAlloc=$NF;print};if(/^ESP Pkts Free/){ESPPktsFree=$NF;print;delta=ESPPktsAlloc-ESPPktsFree;if(delta>threshold){print "Issue deteceted delta: " delta " Card: " card}}
if(/^DMA Callback Alloc/){DMACallbackAlloc=$NF;print};if(/^DMA Callback Free/){DMACallbackFree=$NF;print;delta=DMACallbackAlloc-DMACallbackFree;if(delta>threshold){print "Issue deteceted delta: " delta " Card: " card}}
if(/^DMA TX Buf Alloc/){DMATXBufAlloc=$NF;print};if(/^DMA TX Buf Free/){DMATXBufFree=$NF;print;delta=DMATXBufAlloc-DMATXBufFree;if(delta>threshold){print "Issue deteceted delta: " delta " Card: " card}}
if(/^DMA RX Buf Alloc/){DMARXBufAlloc=$NF;print};if(/^DMA RX Buf Free/){DMARXBufFree=$NF;print;delta=DMARXBufAlloc-DMARXBufFree;if(delta>threshold){print "Issue deteceted delta: " delta " Card: " card}}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment