drivers: net: tc6: Saturate RCA and RBA when read directly from OA_BUFSTS
The RCA and RBA fields in OA_BUFSTS register are stored with 8 bits each. On the other hand, when one receives those values in footer, the value is saturated to 5 bits due to 32 bit size constrain of the footer itself. To avoid any mismatches - the values read from OA_BUFSTS are saturated as well. Signed-off-by: Lukasz Majewski <lukma@denx.de>
This commit is contained in:
parent
d378e64508
commit
59980d5c98
|
@ -237,6 +237,26 @@ int oa_tc6_update_buf_info(struct oa_tc6 *tc6)
|
|||
tc6->rca = FIELD_GET(OA_BUFSTS_RCA, val);
|
||||
tc6->txc = FIELD_GET(OA_BUFSTS_TXC, val);
|
||||
|
||||
/*
|
||||
* There is a mismatch in the max value of RBA(RCA) and TXC provided by the
|
||||
* OA TC6 standard.
|
||||
*
|
||||
* The OA_BUFSTS register has 8 bits for RBA(RCA) and TXC (max value is 0x30)
|
||||
*
|
||||
* However, with footer, the RBA(RCA) and TXC are saturated to 0x1F maximal
|
||||
* value (due to 32 bit constrain of footer size).
|
||||
*
|
||||
* To avoid any issues, the number read directly from OA_BUFSTS is saturated
|
||||
* as well.
|
||||
*/
|
||||
if (tc6->rca >= OA_TC6_FTR_RCA_MAX) {
|
||||
tc6->rca = OA_TC6_FTR_RCA_MAX;
|
||||
}
|
||||
|
||||
if (tc6->txc >= OA_TC6_FTR_TXC_MAX) {
|
||||
tc6->txc = OA_TC6_FTR_TXC_MAX;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,8 @@
|
|||
#define OA_TC6_HDR_SIZE 4
|
||||
#define OA_TC6_FTR_SIZE 4
|
||||
#define OA_TC6_BUF_ALLOC_TIMEOUT K_MSEC(10)
|
||||
#define OA_TC6_FTR_RCA_MAX GENMASK(4, 0)
|
||||
#define OA_TC6_FTR_TXC_MAX GENMASK(4, 0)
|
||||
|
||||
/**
|
||||
* @brief OA TC6 data.
|
||||
|
|
Loading…
Reference in a new issue