[PATCH v7] ethdev: fix strict aliasing lead to link cannot be up
Ferruh Yigit
ferruh.yigit at amd.com
Fri Apr 19 17:15:53 CEST 2024
On 4/18/2024 8:28 AM, Chengwen Feng wrote:
> @@ -1701,12 +1696,10 @@ static inline void
> rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
> struct rte_eth_link *link)
> {
> - RTE_ATOMIC(uint64_t) *src = (uint64_t __rte_atomic *)&(dev->data->dev_link);
> - uint64_t *dst = (uint64_t *)link;
> -
> - RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
> -
> - *dst = rte_atomic_load_explicit(src, rte_memory_order_seq_cst);
> + rte_atomic_store_explicit(&link->val64,
> + rte_atomic_load_explicit(&dev->data->dev_link.val64,
> + rte_memory_order_seq_cst),
> + rte_memory_order_seq_cst);
>
Hi Chengwen,
Overall looks good to me, but to increase readability what do you think
to extract function call in the function param, like
```
struct rte_eth_link new_link;
new_link->val64 = rte_atomic_load_explicit(..dev_link.val64, ..);
rte_atomic_store_explicit(&link->val64, new_link->val64, ..);
```
More information about the dev
mailing list