#include <inttypes.h>
#include <pthread.h>
+#include <rte_bitops.h>
#include <rte_byteorder.h>
#include <rte_memory.h>
#include <rte_malloc.h>
#define time_after_eq(a, b) ((long)((a) - (b)) >= 0)
#define time_before_eq(a, b) time_after_eq(b, a)
-/*---bitmap support apis---*/
-static inline int axgbe_test_bit(int nr, volatile unsigned long *addr)
-{
- int res;
-
- rte_mb();
- res = ((*addr) & (1UL << nr)) != 0;
- rte_mb();
- return res;
-}
-
-static inline void axgbe_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
- __sync_fetch_and_or(addr, (1UL << nr));
-}
-
-static inline void axgbe_clear_bit(int nr, volatile unsigned long *addr)
-{
- __sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-static inline int axgbe_test_and_clear_bit(int nr, volatile unsigned long *addr)
-{
- unsigned long mask = (1UL << nr);
-
- return __sync_fetch_and_and(addr, ~mask) & mask;
-}
-
static inline unsigned long msecs_to_timer_cycles(unsigned int m)
{
return rte_get_timer_hz() * (m / 1000);
axgbe_dev_enable_tx(dev);
axgbe_dev_enable_rx(dev);
- axgbe_clear_bit(AXGBE_STOPPED, &pdata->dev_state);
- axgbe_clear_bit(AXGBE_DOWN, &pdata->dev_state);
+ rte_bit_relaxed_clear32(AXGBE_STOPPED, &pdata->dev_state);
+ rte_bit_relaxed_clear32(AXGBE_DOWN, &pdata->dev_state);
if ((dev_data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_SCATTER) ||
max_pkt_len > pdata->rx_buf_size)
dev_data->scattered_rx = 1;
rte_intr_disable(&pdata->pci_dev->intr_handle);
- if (axgbe_test_bit(AXGBE_STOPPED, &pdata->dev_state))
+ if (rte_bit_relaxed_get32(AXGBE_STOPPED, &pdata->dev_state))
return;
- axgbe_set_bit(AXGBE_STOPPED, &pdata->dev_state);
+ rte_bit_relaxed_set32(AXGBE_STOPPED, &pdata->dev_state);
axgbe_dev_disable_tx(dev);
axgbe_dev_disable_rx(dev);
pdata->phy_if.phy_stop(pdata);
pdata->hw_if.exit(pdata);
memset(&dev->data->dev_link, 0, sizeof(struct rte_eth_link));
- axgbe_set_bit(AXGBE_DOWN, &pdata->dev_state);
+ rte_bit_relaxed_set32(AXGBE_DOWN, &pdata->dev_state);
}
/* Clear all resources like TX/RX queues. */
pdata = eth_dev->data->dev_private;
/* initial state */
- axgbe_set_bit(AXGBE_DOWN, &pdata->dev_state);
- axgbe_set_bit(AXGBE_STOPPED, &pdata->dev_state);
+ rte_bit_relaxed_set32(AXGBE_DOWN, &pdata->dev_state);
+ rte_bit_relaxed_set32(AXGBE_STOPPED, &pdata->dev_state);
pdata->eth_dev = eth_dev;
pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
unsigned int xpcs_window_mask;
/* Flags representing axgbe_state */
- unsigned long dev_state;
+ uint32_t dev_state;
struct axgbe_hw_if hw_if;
struct axgbe_phy_if phy_if;
{
int ret;
- axgbe_set_bit(AXGBE_LINK_INIT, &pdata->dev_state);
+ rte_bit_relaxed_set32(AXGBE_LINK_INIT, &pdata->dev_state);
pdata->link_check = rte_get_timer_cycles();
ret = pdata->phy_if.phy_impl.an_config(pdata);
ret = __axgbe_phy_config_aneg(pdata);
if (ret)
- axgbe_set_bit(AXGBE_LINK_ERR, &pdata->dev_state);
+ rte_bit_relaxed_set32(AXGBE_LINK_ERR, &pdata->dev_state);
else
- axgbe_clear_bit(AXGBE_LINK_ERR, &pdata->dev_state);
+ rte_bit_relaxed_clear32(AXGBE_LINK_ERR, &pdata->dev_state);
pthread_mutex_unlock(&pdata->an_mutex);
unsigned int reg = 0;
unsigned long autoneg_start_time;
- if (axgbe_test_bit(AXGBE_LINK_ERR, &pdata->dev_state)) {
+ if (rte_bit_relaxed_get32(AXGBE_LINK_ERR, &pdata->dev_state)) {
pdata->phy.link = 0;
goto adjust_link;
}
}
}
axgbe_phy_status_result(pdata);
- if (axgbe_test_bit(AXGBE_LINK_INIT, &pdata->dev_state))
- axgbe_clear_bit(AXGBE_LINK_INIT, &pdata->dev_state);
+ if (rte_bit_relaxed_get32(AXGBE_LINK_INIT, &pdata->dev_state))
+ rte_bit_relaxed_clear32(AXGBE_LINK_INIT,
+ &pdata->dev_state);
} else {
- if (axgbe_test_bit(AXGBE_LINK_INIT, &pdata->dev_state)) {
+ if (rte_bit_relaxed_get32(AXGBE_LINK_INIT, &pdata->dev_state)) {
axgbe_check_link_timeout(pdata);
if (link_aneg)