Skip to content

Commit e2838b9

Browse files
mssonicbldbradh352
authored andcommitted
Initialize the last fec ber computed values if not found (sonic-net#3621)
<!-- Please make sure you have read and understood the contribution guildlines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md 1. Make sure your commit includes a signature generted with `git commit -s` 2. Make sure your commit title follows the correct format: [component]: description 3. Make sure your commit message contains enough details about the change and related tests 4. Make sure your pull request adds related reviewers, asignees, labels Please also provide the following information in this pull request: --> **What I did** `SAI_PORT_STAT_IF_FEC_CORRECTED_BITS_last` and `SAI_PORT_STAT_IF_FEC_NOT_CORRECTABLE_FARMES_last` counter values could be NOT present in redis, so initialize these values to ZERO **Why I did it** To prevent following error seen during warm boot ``` root@sonic:/# redis-cli --eval ./usr/share/swss/port_rates.lua oid:0x100000000000a , 2 COUNTERS 10 (error) ERR user_script:204: attempt to concatenate local 'fec_corr_bits_last' (a boolean value) script: b46cd0b446729aab6bbd20e0d4aa977e3da8f5f1, on @user_script:204. root@sonic:/# redis-cli --eval ./usr/share/swss/port_rates.lua oid:0x100000000000a , 2 COUNTERS 10 (error) ERR user_script:204: attempt to concatenate local 'fec_corr_bits_last' (a boolean value) script: b46cd0b446729aab6bbd20e0d4aa977e3da8f5f1, on @user_script:204. root@sonic:/# redis-cli --eval ./usr/share/swss/port_rates.lua oid:0x100000000000a , 2 COUNTERS 10 (error) ERR user_script:206: attempt to perform arithmetic on local 'fec_corr_bits_last' (a boolean value) script: cb98161ae9433f9bf8265cffd7d2eaaf6ac9282f, on @user_script:206. root@sonic:/# ``` **How I verified it** After fix the last computer FEC ber values are stored in redis DB ``` root@sonic:/# redis-cli --eval ./usr/share/swss/port_rates.lua oid:0x100000000000a , 2 COUNTERS 10 1) "0.18" 2) "0.82" 3) "10" 4) "DONE" root@str2-7050cx3-acs-14:/# redis-cli -n 2 hgetall "RATES:oid:0x100000000000a" 1) "SAI_PORT_STAT_IF_IN_UCAST_PKTS_last" 2) "0" 3) "SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS_last" 4) "0" 5) "SAI_PORT_STAT_IF_OUT_UCAST_PKTS_last" 6) "0" 7) "SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS_last" 8) "0" 9) "SAI_PORT_STAT_IF_IN_OCTETS_last" 10) "0" 11) "SAI_PORT_STAT_IF_OUT_OCTETS_last" 12) "0" 13) "RX_BPS" 14) "0" 15) "RX_PPS" 16) "0" 17) "TX_BPS" 18) "0" 19) "TX_PPS" 20) "0" 21) "SAI_PORT_STAT_IF_FEC_CORRECTED_BITS_last" 22) "0" 23) "SAI_PORT_STAT_IF_FEC_NOT_CORRECTABLE_FARMES_last" 24) "0" 25) "FEC_PRE_BER" 26) "0" 27) "FEC_POST_BER" 28) "0" root@str2-7050cx3-acs-14:/# ``` **Details if related**
1 parent c24374c commit e2838b9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

orchagent/port_rates.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,17 @@ local function compute_rate(port)
200200
local fec_corr_bits_last = redis.call('HGET', rates_table_name .. ':' .. port, 'SAI_PORT_STAT_IF_FEC_CORRECTED_BITS_last')
201201
local fec_uncorr_frames_last = redis.call('HGET', rates_table_name .. ':' .. port, 'SAI_PORT_STAT_IF_FEC_NOT_CORRECTABLE_FARMES_last')
202202

203+
-- Initialize to 0 if last counter values does not exist (during first boot for eg)
204+
fec_corr_bits_last = tonumber(fec_corr_bits_last) or 0
205+
fec_uncorr_frames_last = tonumber(fec_uncorr_frames_last) or 0
206+
203207
local serdes_rate_total = lanes_count * serdes_speed * delta / 1000
204208

205209
fec_corr_bits_ber_new = (fec_corr_bits - fec_corr_bits_last) / serdes_rate_total
206210
fec_uncorr_bits_ber_new = (fec_uncorr_frames - fec_uncorr_frames_last) * rs_average_frame_ber / serdes_rate_total
207211
else
208212
logit("FEC counters or lane info not found on " .. port)
209213
end
210-
211214
else
212215
redis.call('HSET', state_table, 'INIT_DONE', 'COUNTERS_LAST')
213216
end

0 commit comments

Comments
 (0)