Skip to contentSkip to conversation

implement common rte bit operation APIs in PMDs

PATCH Superseded Joyce Kong 9 participants 141 messages Oct 15, 2019 – Feb 17, 2024 Page 2 of 2

Subsystems (2)
lore
Share & tools
lore
author
#103 lore raw

PATCH v7 3/6 net/axgbe: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/axgbe/axgbe_common.h | 29 +----------------------------
 drivers/net/axgbe/axgbe_ethdev.c | 14 +++++++-------
 drivers/net/axgbe/axgbe_ethdev.h |  2 +-
 drivers/net/axgbe/axgbe_mdio.c   | 15 ++++++++-------
 4 files changed, 17 insertions(+), 43 deletions(-)
drivers/net/axgbe/axgbe_common.h +1 -28
index fdb037dd5..a4a685181 100644
@@ -38,6 +38,7 @@
 #include <rte_common.h>
 #include <rte_cycles.h>
 #include <rte_io.h>
+#include <rte_pmd_bitops.h>
 
 #define BIT(nr)	                       (1 << (nr))
 #ifndef ARRAY_SIZE
@@ -1677,34 +1678,6 @@ do {									\
 #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);
drivers/net/axgbe/axgbe_ethdev.c +7 -7
index d0b6f091f..fe1f92843 100644
@@ -277,8 +277,8 @@ axgbe_dev_start(struct rte_eth_dev *dev)
 	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_clear_bit32_relaxed(AXGBE_STOPPED, &pdata->dev_state);
+	rte_clear_bit32_relaxed(AXGBE_DOWN, &pdata->dev_state);
 	return 0;
 }
 
@@ -292,17 +292,17 @@ axgbe_dev_stop(struct rte_eth_dev *dev)
 
 	rte_intr_disable(&pdata->pci_dev->intr_handle);
 
-	if (axgbe_test_bit(AXGBE_STOPPED, &pdata->dev_state))
+	if (rte_get_bit32_relaxed(AXGBE_STOPPED, &pdata->dev_state))
 		return;
 
-	axgbe_set_bit(AXGBE_STOPPED, &pdata->dev_state);
+	rte_set_bit32_relaxed(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_set_bit32_relaxed(AXGBE_DOWN, &pdata->dev_state);
 }
 
 /* Clear all resources like TX/RX queues. */
@@ -1031,8 +1031,8 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
 
 	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_set_bit32_relaxed(AXGBE_DOWN, &pdata->dev_state);
+	rte_set_bit32_relaxed(AXGBE_STOPPED, &pdata->dev_state);
 	pdata->eth_dev = eth_dev;
 
 	pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
drivers/net/axgbe/axgbe_ethdev.h +1 -1
index a1083b17b..259221964 100644
@@ -511,7 +511,7 @@ struct axgbe_port {
 	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;
drivers/net/axgbe/axgbe_mdio.c +8 -7
index 4b280b72d..2bb7f5263 100644
@@ -875,7 +875,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata)
 {
 	int ret;
 
-	axgbe_set_bit(AXGBE_LINK_INIT, &pdata->dev_state);
+	rte_set_bit32_relaxed(AXGBE_LINK_INIT, &pdata->dev_state);
 	pdata->link_check = rte_get_timer_cycles();
 
 	ret = pdata->phy_if.phy_impl.an_config(pdata);
@@ -937,9 +937,9 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
 
 	ret = __axgbe_phy_config_aneg(pdata);
 	if (ret)
-		axgbe_set_bit(AXGBE_LINK_ERR, &pdata->dev_state);
+		rte_set_bit32_relaxed(AXGBE_LINK_ERR, &pdata->dev_state);
 	else
-		axgbe_clear_bit(AXGBE_LINK_ERR, &pdata->dev_state);
+		rte_clear_bit32_relaxed(AXGBE_LINK_ERR, &pdata->dev_state);
 
 	pthread_mutex_unlock(&pdata->an_mutex);
 
@@ -1026,7 +1026,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)
 	unsigned int reg = 0;
 	unsigned long autoneg_start_time;
 
-	if (axgbe_test_bit(AXGBE_LINK_ERR, &pdata->dev_state)) {
+	if (rte_get_bit32_relaxed(AXGBE_LINK_ERR, &pdata->dev_state)) {
 		pdata->phy.link = 0;
 		goto adjust_link;
 	}
@@ -1070,10 +1070,11 @@ static void axgbe_phy_status(struct axgbe_port *pdata)
 			}
 		}
 		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_get_bit32_relaxed(AXGBE_LINK_INIT, &pdata->dev_state))
+			rte_clear_bit32_relaxed(AXGBE_LINK_INIT,
+						&pdata->dev_state);
 	} else {
-		if (axgbe_test_bit(AXGBE_LINK_INIT, &pdata->dev_state)) {
+		if (rte_get_bit32_relaxed(AXGBE_LINK_INIT, &pdata->dev_state)) {
 			axgbe_check_link_timeout(pdata);
 
 			if (link_aneg)
Signature · 1 line
2.17.1
author
#104 lore raw

PATCH v7 4/6 net/bnx2x: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/bnx2x/bnx2x.c    | 253 +++++++++++++++++------------------
 drivers/net/bnx2x/bnx2x.h    |  10 +-
 drivers/net/bnx2x/ecore_sp.h |  48 +++----
 3 files changed, 150 insertions(+), 161 deletions(-)
drivers/net/bnx2x/bnx2x.c +122 -131
index 0b4030e2b..2ea23b2eb 100644
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <zlib.h>
+#include <rte_pmd_bitops.h>
 #include <rte_string_fns.h>
 
 #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"
@@ -129,32 +130,6 @@ static void bnx2x_ack_sb(struct bnx2x_softc *sc, uint8_t igu_sb_id,
 			 uint8_t storm, uint16_t index, uint8_t op,
 			 uint8_t update);
 
-int bnx2x_test_bit(int nr, volatile unsigned long *addr)
-{
-	int res;
-
-	mb();
-	res = ((*addr) & (1UL << nr)) != 0;
-	mb();
-	return res;
-}
-
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-void bnx2x_clear_bit(int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-int bnx2x_test_and_clear_bit(int nr, volatile unsigned long *addr)
-{
-	unsigned long mask = (1UL << nr);
-	return __sync_fetch_and_and(addr, ~mask) & mask;
-}
-
 int bnx2x_cmpxchg(volatile int *addr, int old, int new)
 {
 	return __sync_val_compare_and_swap(addr, old, new);
@@ -1434,16 +1409,16 @@ static int
 bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 		 int mac_type, uint8_t wait_for_comp)
 {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
 	int rc;
 
 	/* wait for completion of requested */
 	if (wait_for_comp) {
-		bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+		rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 	}
 
 	/* Set the mac type of addresses we want to clear */
-	bnx2x_set_bit(mac_type, &vlan_mac_flags);
+	rte_set_bit32_relaxed(mac_type, &vlan_mac_flags);
 
 	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
 	if (rc < 0)
@@ -1454,8 +1429,7 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 
 static int
 bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
-			unsigned long *rx_accept_flags,
-			unsigned long *tx_accept_flags)
+			uint32_t *rx_accept_flags, uint32_t *tx_accept_flags)
 {
 	/* Clear the flags first */
 	*rx_accept_flags = 0;
@@ -1470,26 +1444,28 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 		break;
 
 	case BNX2X_RX_MODE_NORMAL:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		break;
 
 	case BNX2X_RX_MODE_ALLMULTI:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		break;
 
@@ -1500,19 +1476,23 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 		 * should receive matched and unmatched (in resolution of port)
 		 * unicast packets.
 		 */
-		bnx2x_set_bit(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		if (IS_MF_SI(sc)) {
-			bnx2x_set_bit(ECORE_ACCEPT_ALL_UNICAST, tx_accept_flags);
+			rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_UNICAST,
+					tx_accept_flags);
 		} else {
-			bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+			rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST,
+					      tx_accept_flags);
 		}
 
 		break;
@@ -1524,8 +1504,8 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 
 	/* Set ACCEPT_ANY_VLAN as we do not enable filtering by VLAN */
 	if (rx_mode != BNX2X_RX_MODE_NONE) {
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
 	}
 
 	return 0;
@@ -1554,7 +1534,7 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
 	ramrod_param.rdata = BNX2X_SP(sc, rx_mode_rdata);
 	ramrod_param.rdata_mapping =
 	    (rte_iova_t)BNX2X_SP_MAPPING(sc, rx_mode_rdata),
-	    bnx2x_set_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	    rte_set_bit32_relaxed(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
 	ramrod_param.ramrod_flags = ramrod_flags;
 	ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1573,8 +1553,8 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
 
 int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
 {
-	unsigned long rx_mode_flags = 0, ramrod_flags = 0;
-	unsigned long rx_accept_flags = 0, tx_accept_flags = 0;
+	uint32_t rx_mode_flags = 0, ramrod_flags = 0;
+	uint32_t rx_accept_flags = 0, tx_accept_flags = 0;
 	int rc;
 
 	rc = bnx2x_fill_accept_flags(sc, sc->rx_mode, &rx_accept_flags,
@@ -1583,9 +1563,9 @@ int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
 		return rc;
 	}
 
-	bnx2x_set_bit(RAMROD_RX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_TX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_RX, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_TX, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 
 	return bnx2x_set_q_rx_mode(sc, sc->fp[0].cl_id, rx_mode_flags,
 				 rx_accept_flags, tx_accept_flags,
@@ -1710,7 +1690,8 @@ static int bnx2x_func_wait_started(struct bnx2x_softc *sc)
 			    "Forcing STARTED-->TX_STOPPED-->STARTED");
 
 		func_params.f_obj = &sc->func_obj;
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
 
 		/* STARTED-->TX_STOPPED */
 		func_params.cmd = ECORE_F_CMD_TX_STOP;
@@ -1734,7 +1715,7 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
 
 	q_params.q_obj = &sc->sp_objs[fp->index].q_obj;
 	/* We want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
 	/* Stop the primary connection: */
 
@@ -1795,7 +1776,7 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
 	int rc;
 
 	/* prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_STOP;
 
@@ -1809,7 +1790,8 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
 	if (rc) {
 		PMD_DRV_LOG(NOTICE, sc, "FUNC_STOP ramrod failed. "
 			    "Running a dry transaction");
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
 		return ecore_func_state_change(sc, &func_params);
 	}
 
@@ -1821,7 +1803,7 @@ static int bnx2x_reset_hw(struct bnx2x_softc *sc, uint32_t load_code)
 	struct ecore_func_state_params func_params = { NULL };
 
 	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_HW_RESET;
@@ -1878,11 +1860,12 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
 	 * a race between the completion code and this code.
 	 */
 
-	if (bnx2x_test_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state)) {
-		bnx2x_set_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state);
-	} else {
+	if (rte_get_bit32_relaxed(ECORE_FILTER_RX_MODE_PENDING,
+				  &sc->sp_state))
+		rte_set_bit32_relaxed(ECORE_FILTER_RX_MODE_SCHED,
+				      &sc->sp_state);
+	else
 		bnx2x_set_storm_rx_mode(sc);
-	}
 
 	/* Clean up multicast configuration */
 	rparam.mcast_obj = &sc->mcast_obj;
@@ -1964,7 +1947,7 @@ static void bnx2x_disable_close_the_gate(struct bnx2x_softc *sc)
  */
 static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
 	struct ecore_mcast_ramrod_params rparam = { NULL };
 	struct ecore_vlan_mac_obj *mac_obj = &sc->sp_objs->mac_obj;
 	int rc;
@@ -1972,12 +1955,12 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 	/* Cleanup MACs' object first... */
 
 	/* Wait for completion of requested */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 	/* Perform a dry cleanup */
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
 
 	/* Clean ETH primary MAC */
-	bnx2x_set_bit(ECORE_ETH_MAC, &vlan_mac_flags);
+	rte_set_bit32_relaxed(ECORE_ETH_MAC, &vlan_mac_flags);
 	rc = mac_obj->delete_all(sc, &sc->sp_objs->mac_obj, &vlan_mac_flags,
 				 &ramrod_flags);
 	if (rc != 0) {
@@ -1986,7 +1969,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 
 	/* Cleanup UC list */
 	vlan_mac_flags = 0;
-	bnx2x_set_bit(ECORE_UC_LIST_MAC, &vlan_mac_flags);
+	rte_set_bit32_relaxed(ECORE_UC_LIST_MAC, &vlan_mac_flags);
 	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
 	if (rc != 0) {
 		PMD_DRV_LOG(NOTICE, sc,
@@ -1996,7 +1979,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 	/* Now clean mcast object... */
 
 	rparam.mcast_obj = &sc->mcast_obj;
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
 
 	/* Add a DEL command... */
 	rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_DEL);
@@ -4294,13 +4277,13 @@ static void bnx2x_handle_mcast_eqe(struct bnx2x_softc *sc)
 static void
 bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *elem)
 {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
 	int rc = 0;
 	uint32_t cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK;
 	struct ecore_vlan_mac_obj *vlan_mac_obj;
 
 	/* always push next commands out, don't wait here */
-	bnx2x_set_bit(RAMROD_CONT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_CONT, &ramrod_flags);
 
 	switch (le32toh(elem->message.data.eth_event.echo) >> BNX2X_SWCID_SHIFT) {
 	case ECORE_FILTER_MAC_PENDING:
@@ -4331,12 +4314,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *e
 
 static void bnx2x_handle_rx_mode_eqe(struct bnx2x_softc *sc)
 {
-	bnx2x_clear_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	rte_clear_bit32_relaxed(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
 	/* send rx_mode command again if was requested */
-	if (bnx2x_test_and_clear_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state)) {
+	if (rte_test_and_clear_bit32_relaxed(ECORE_FILTER_RX_MODE_SCHED,
+						&sc->sp_state))
 		bnx2x_set_storm_rx_mode(sc);
-	}
 }
 
 static void bnx2x_update_eq_prod(struct bnx2x_softc *sc, uint16_t prod)
@@ -4705,7 +4688,7 @@ static int bnx2x_init_hw(struct bnx2x_softc *sc, uint32_t load_code)
 	PMD_INIT_FUNC_TRACE(sc);
 
 	/* prepare the parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_HW_INIT;
@@ -4953,7 +4936,7 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
 {
 	struct bnx2x_fastpath *fp = &sc->fp[idx];
 	uint32_t cids[ECORE_MULTI_TX_COS] = { 0 };
-	unsigned long q_type = 0;
+	uint32_t q_type = 0;
 	int cos;
 
 	fp->sc = sc;
@@ -5000,8 +4983,8 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
 	bnx2x_update_fp_sb_idx(fp);
 
 	/* Configure Queue State object */
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_RX, &q_type);
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_TX, &q_type);
+	rte_set_bit32_relaxed(ECORE_Q_TYPE_HAS_RX, &q_type);
+	rte_set_bit32_relaxed(ECORE_Q_TYPE_HAS_TX, &q_type);
 
 	ecore_init_queue_obj(sc,
 			     &sc->sp_objs[idx].q_obj,
@@ -5815,7 +5798,7 @@ static int bnx2x_func_start(struct bnx2x_softc *sc)
 	    &func_params.params.start;
 
 	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_START;
@@ -6391,11 +6374,11 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
 	uint8_t cos;
 	int cxt_index, cxt_offset;
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->tx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC, &init_params->rx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC, &init_params->tx.flags);
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
 
 	/* HC rate */
 	init_params->rx.hc_rate =
@@ -6426,10 +6409,10 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
 static unsigned long
 bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
 	/* PF driver will always initialize the Queue to an ACTIVE state */
-	bnx2x_set_bit(ECORE_Q_FLG_ACTIVE, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_ACTIVE, &flags);
 
 	/*
 	 * tx only connections collect statistics (on the same index as the
@@ -6437,9 +6420,9 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 	 * connection is initialized.
 	 */
 
-	bnx2x_set_bit(ECORE_Q_FLG_STATS, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_STATS, &flags);
 	if (zero_stats) {
-		bnx2x_set_bit(ECORE_Q_FLG_ZERO_STATS, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_ZERO_STATS, &flags);
 	}
 
 	/*
@@ -6447,28 +6430,28 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 	 * CoS-ness doesn't survive the loopback
 	 */
 	if (sc->flags & BNX2X_TX_SWITCHING) {
-		bnx2x_set_bit(ECORE_Q_FLG_TX_SWITCH, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_TX_SWITCH, &flags);
 	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
 
 	return flags;
 }
 
 static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)
 {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
 	if (IS_MF_SD(sc)) {
-		bnx2x_set_bit(ECORE_Q_FLG_OV, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_OV, &flags);
 	}
 
 	if (leading) {
-		bnx2x_set_bit(ECORE_Q_FLG_LEADING_RSS, &flags);
-		bnx2x_set_bit(ECORE_Q_FLG_MCAST, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_LEADING_RSS, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_MCAST, &flags);
 	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_VLAN, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_VLAN, &flags);
 
 	/* merge with common flags */
 	return flags | bnx2x_get_common_flags(sc, TRUE);
@@ -6589,7 +6572,7 @@ bnx2x_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, uint8_t lea
 	q_params.q_obj = &BNX2X_SP_OBJ(sc, fp).q_obj;
 
 	/* we want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
 	/* prepare the INIT parameters */
 	bnx2x_pf_q_prep_init(sc, fp, &q_params.params.init);
@@ -6657,20 +6640,20 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
 
 	params.rss_obj = rss_obj;
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &params.ramrod_flags);
 
-	bnx2x_set_bit(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
 
 	/* RSS configuration */
-	bnx2x_set_bit(ECORE_RSS_IPV4, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV4_TCP, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6_TCP, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV4, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV4_TCP, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV6, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV6_TCP, &params.rss_flags);
 	if (rss_obj->udp_rss_v4) {
-		bnx2x_set_bit(ECORE_RSS_IPV4_UDP, &params.rss_flags);
+		rte_set_bit32_relaxed(ECORE_RSS_IPV4_UDP, &params.rss_flags);
 	}
 	if (rss_obj->udp_rss_v6) {
-		bnx2x_set_bit(ECORE_RSS_IPV6_UDP, &params.rss_flags);
+		rte_set_bit32_relaxed(ECORE_RSS_IPV6_UDP, &params.rss_flags);
 	}
 
 	/* Hash bits */
@@ -6685,7 +6668,7 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
 			params.rss_key[i] = (uint32_t) rte_rand();
 		}
 
-		bnx2x_set_bit(ECORE_RSS_SET_SRCH, &params.rss_flags);
+		rte_set_bit32_relaxed(ECORE_RSS_SET_SRCH, &params.rss_flags);
 	}
 
 	if (IS_PF(sc))
@@ -6730,7 +6713,7 @@ static int bnx2x_init_rss_pf(struct bnx2x_softc *sc)
 static int
 bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 		struct ecore_vlan_mac_obj *obj, uint8_t set, int mac_type,
-		unsigned long *ramrod_flags)
+		uint32_t *ramrod_flags)
 {
 	struct ecore_vlan_mac_ramrod_params ramrod_param;
 	int rc;
@@ -6742,11 +6725,12 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 	ramrod_param.ramrod_flags = *ramrod_flags;
 
 	/* fill a user request section if needed */
-	if (!bnx2x_test_bit(RAMROD_CONT, ramrod_flags)) {
+	if (!rte_get_bit32_relaxed(RAMROD_CONT, ramrod_flags)) {
 		rte_memcpy(ramrod_param.user_req.u.mac.mac, mac,
 				 ETH_ALEN);
 
-		bnx2x_set_bit(mac_type, &ramrod_param.user_req.vlan_mac_flags);
+		rte_set_bit32_relaxed(mac_type,
+				      &ramrod_param.user_req.vlan_mac_flags);
 
 /* Set the command: ADD or DEL */
 		ramrod_param.user_req.cmd = (set) ? ECORE_VLAN_MAC_ADD :
@@ -6769,11 +6753,11 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 
 static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)
 {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
 
 	PMD_DRV_LOG(DEBUG, sc, "Adding Ethernet MAC");
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 
 	/* Eth MAC is set on RSS leading client (fp[0]) */
 	return bnx2x_set_mac_one(sc, sc->link_params.mac_addr,
@@ -6905,24 +6889,26 @@ bnx2x_fill_report_data(struct bnx2x_softc *sc, struct bnx2x_link_report_data *da
 
 	/* Link is down */
 	if (!sc->link_vars.link_up || (sc->flags & BNX2X_MF_FUNC_DIS)) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			    &data->link_report_flags);
 	}
 
 	/* Full DUPLEX */
 	if (sc->link_vars.duplex == DUPLEX_FULL) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_FULL_DUPLEX,
 			    &data->link_report_flags);
 	}
 
 	/* Rx Flow Control is ON */
 	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_RX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_RX_FC_ON, &data->link_report_flags);
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_RX_FC_ON,
+				&data->link_report_flags);
 	}
 
 	/* Tx Flow Control is ON */
 	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_TX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_TX_FC_ON, &data->link_report_flags);
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_TX_FC_ON,
+				&data->link_report_flags);
 	}
 }
 
@@ -6941,9 +6927,9 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 
 	/* Don't report link down or exactly the same link status twice */
 	if (!memcmp(&cur_data, &sc->last_reported_link, sizeof(cur_data)) ||
-	    (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	    (rte_get_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			  &sc->last_reported_link.link_report_flags) &&
-	     bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	     rte_get_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			  &cur_data.link_report_flags))) {
 		return;
 	}
@@ -6958,15 +6944,16 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 	/* report new link params and remember the state for the next time */
 	rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
 
-	if (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	if (rte_get_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			 &cur_data.link_report_flags)) {
 		ELINK_DEBUG_P0(sc, "NIC Link is Down");
 	} else {
 		__rte_unused const char *duplex;
 		__rte_unused const char *flow;
 
-		if (bnx2x_test_and_clear_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
-					   &cur_data.link_report_flags)) {
+		if (rte_test_and_clear_bit32_relaxed
+				(BNX2X_LINK_REPORT_FULL_DUPLEX,
+				 &cur_data.link_report_flags)) {
 			duplex = "full";
 				ELINK_DEBUG_P0(sc, "link set to full duplex");
 		} else {
@@ -6980,20 +6967,24 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
  * enabled.
  */
 		if (cur_data.link_report_flags) {
-			if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			if (rte_get_bit32_relaxed(BNX2X_LINK_REPORT_RX_FC_ON,
 					 &cur_data.link_report_flags) &&
-			    bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			    rte_get_bit32_relaxed(BNX2X_LINK_REPORT_TX_FC_ON,
 					 &cur_data.link_report_flags)) {
 				flow = "ON - receive & transmit";
-			} else if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
-						&cur_data.link_report_flags) &&
-				   !bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			} else if (rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_RX_FC_ON,
+						 &cur_data.link_report_flags) &&
+				   !rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_TX_FC_ON,
 						 &cur_data.link_report_flags)) {
 				flow = "ON - receive";
-			} else if (!bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			} else if (!rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_RX_FC_ON,
 						 &cur_data.link_report_flags) &&
-				   bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
-						&cur_data.link_report_flags)) {
+				   rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_TX_FC_ON,
+						 &cur_data.link_report_flags)) {
 				flow = "ON - transmit";
 			} else {
 				flow = "none";	/* possible? */
drivers/net/bnx2x/bnx2x.h +3 -7
index 1dbc98197..63be72a5b 100644
@@ -1000,8 +1000,8 @@ struct bnx2x_sp_objs {
  * link parameters twice.
  */
 struct bnx2x_link_report_data {
-	uint16_t      line_speed;        /* Effective line speed */
-	unsigned long link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
+	uint16_t line_speed;        /* Effective line speed */
+	uint32_t link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
 };
 
 enum {
@@ -1232,7 +1232,7 @@ struct bnx2x_softc {
 	/* slow path */
 	struct bnx2x_dma      sp_dma;
 	struct bnx2x_slowpath *sp;
-	unsigned long       sp_state;
+	uint32_t	    sp_state;
 
 	/* slow path queue */
 	struct bnx2x_dma spq_dma;
@@ -1812,10 +1812,6 @@ static const uint32_t dmae_reg_go_c[] = {
 #define PCI_PM_D0    1
 #define PCI_PM_D3hot 2
 
-int  bnx2x_test_bit(int nr, volatile unsigned long * addr);
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long * addr);
-void bnx2x_clear_bit(int nr, volatile unsigned long * addr);
-int  bnx2x_test_and_clear_bit(int nr, volatile unsigned long * addr);
 int  bnx2x_cmpxchg(volatile int *addr, int old, int new);
 
 int bnx2x_dma_alloc(struct bnx2x_softc *sc, size_t size,
drivers/net/bnx2x/ecore_sp.h +25 -23

115 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#105 lore raw

PATCH v7 5/6 net/qede: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/qede/base/bcm_osal.c          | 22 +------------
 drivers/net/qede/base/bcm_osal.h          | 14 ++++-----
 drivers/net/qede/base/ecore.h             |  6 ++--
 drivers/net/qede/base/ecore_cxt.c         |  6 ++--
 drivers/net/qede/base/ecore_dcbx.c        |  8 ++---
 drivers/net/qede/base/ecore_dev.c         | 38 +++++++++++------------
 drivers/net/qede/base/ecore_dev_api.h     |  2 +-
 drivers/net/qede/base/ecore_l2.c          |  6 ++--
 drivers/net/qede/base/ecore_mcp.c         |  4 +--
 drivers/net/qede/base/ecore_sp_commands.c | 12 +++----
 drivers/net/qede/base/ecore_spq.c         |  2 +-
 drivers/net/qede/base/ecore_spq.h         | 10 +++---
 drivers/net/qede/qede_main.c              |  4 +--
 13 files changed, 56 insertions(+), 78 deletions(-)
drivers/net/qede/base/bcm_osal.c +1 -21
index 48d016e24..54e5e4f98 100644
@@ -46,26 +46,6 @@ u32 qede_osal_log2(u32 val)
 	return log;
 }
 
-inline void qede_set_bit(u32 nr, unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-inline void qede_clr_bit(u32 nr, unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-inline bool qede_test_bit(u32 nr, unsigned long *addr)
-{
-	bool res;
-
-	rte_mb();
-	res = ((*addr) & (1UL << nr)) != 0;
-	rte_mb();
-	return res;
-}
-
 static inline u32 qede_ffb(unsigned long word)
 {
 	unsigned long first_bit;
@@ -95,7 +75,7 @@ static inline u32 qede_ffz(unsigned long word)
 	return first_zero ? (first_zero - 1) : OSAL_BITS_PER_UL;
 }
 
-inline u32 qede_find_first_zero_bit(unsigned long *addr, u32 limit)
+inline u32 qede_find_first_zero_bit(u32 *addr, u32 limit)
 {
 	u32 i;
 	u32 nwords = 0;
drivers/net/qede/base/bcm_osal.h +6 -8
index 513f6a8b4..51598a62b 100644
@@ -18,6 +18,7 @@
 #include <rte_debug.h>
 #include <rte_ether.h>
 #include <rte_io.h>
+#include <rte_pmd_bitops.h>
 
 /* Forward declaration */
 struct ecore_dev;
@@ -308,23 +309,20 @@ typedef struct osal_list_t {
 #define OSAL_BITS_PER_UL_MASK		(OSAL_BITS_PER_UL - 1)
 
 /* Bitops */
-void qede_set_bit(u32, unsigned long *);
 #define OSAL_SET_BIT(bit, bitmap) \
-	qede_set_bit(bit, bitmap)
+	rte_set_bit32_relaxed(bit, bitmap)
 
-void qede_clr_bit(u32, unsigned long *);
 #define OSAL_CLEAR_BIT(bit, bitmap) \
-	qede_clr_bit(bit, bitmap)
+	rte_clear_bit32_relaxed(bit, bitmap)
 
-bool qede_test_bit(u32, unsigned long *);
-#define OSAL_TEST_BIT(bit, bitmap) \
-	qede_test_bit(bit, bitmap)
+#define OSAL_GET_BIT(bit, bitmap) \
+	rte_get_bit32_relaxed(bit, bitmap)
 
 u32 qede_find_first_bit(unsigned long *, u32);
 #define OSAL_FIND_FIRST_BIT(bitmap, length) \
 	qede_find_first_bit(bitmap, length)
 
-u32 qede_find_first_zero_bit(unsigned long *, u32);
+u32 qede_find_first_zero_bit(u32 *bitmap, u32 length);
 #define OSAL_FIND_FIRST_ZERO_BIT(bitmap, length) \
 	qede_find_first_zero_bit(bitmap, length)
 
drivers/net/qede/base/ecore.h +3 -3
index b2077bc46..498bb6f09 100644
@@ -422,8 +422,8 @@ struct ecore_hw_info {
 	u8 max_chains_per_vf;
 
 	u32 port_mode;
-	u32	hw_mode;
-	unsigned long device_capabilities;
+	u32 hw_mode;
+	u32 device_capabilities;
 
 	/* Default DCBX mode */
 	u8 dcbx_mode;
@@ -807,7 +807,7 @@ struct ecore_dev {
 
 	u8				path_id;
 
-	unsigned long			mf_bits;
+	u32				mf_bits;
 	enum ecore_mf_mode		mf_mode;
 #define IS_MF_DEFAULT(_p_hwfn)	\
 	(((_p_hwfn)->p_dev)->mf_mode == ECORE_MF_DEFAULT)
drivers/net/qede/base/ecore_cxt.c +3 -3
index 773b75ecd..dda47ea67 100644
@@ -154,7 +154,7 @@ struct ecore_ilt_client_cfg {
 struct ecore_cid_acquired_map {
 	u32 start_cid;
 	u32 max_count;
-	unsigned long *cid_map;
+	u32 *cid_map;
 };
 
 struct ecore_src_t2 {
@@ -1991,7 +1991,7 @@ static bool ecore_cxt_test_cid_acquired(struct ecore_hwfn *p_hwfn,
 	}
 
 	rel_cid = cid - (*pp_map)->start_cid;
-	if (!OSAL_TEST_BIT(rel_cid, (*pp_map)->cid_map)) {
+	if (!OSAL_GET_BIT(rel_cid, (*pp_map)->cid_map)) {
 		DP_NOTICE(p_hwfn, true,
 			  "CID %d [vifd %02x] not acquired", cid, vfid);
 		goto fail;
@@ -2102,7 +2102,7 @@ enum _ecore_status_t ecore_cxt_set_pf_params(struct ecore_hwfn *p_hwfn)
 
 		count = p_params->num_arfs_filters;
 
-		if (!OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS,
+		if (!OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS,
 				   &p_hwfn->p_dev->mf_bits))
 			p_hwfn->p_cxt_mngr->arfs_count = count;
 
drivers/net/qede/base/ecore_dcbx.c +4 -4
index ccd4383bb..31234f18c 100644
@@ -148,7 +148,7 @@ ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
 	p_data->arr[type].update = UPDATE_DCB_DSCP;
 
 	/* Do not add valn tag 0 when DCB is enabled and port is in UFP mode */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		p_data->arr[type].dont_add_vlan0 = true;
 
 	/* QM reconf data */
@@ -156,8 +156,8 @@ ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
 		p_hwfn->hw_info.offload_tc = tc;
 
 	/* Configure dcbx vlan priority in doorbell block for roce EDPM */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits) &&
-	    (type == DCBX_PROTOCOL_ROCE)) {
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits) &&
+	    type == DCBX_PROTOCOL_ROCE) {
 		ecore_wr(p_hwfn, p_ptt, DORQ_REG_TAG1_OVRD_MODE, 1);
 		ecore_wr(p_hwfn, p_ptt, DORQ_REG_PF_PCP, prio << 1);
 	}
@@ -293,7 +293,7 @@ ecore_dcbx_process_tlv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	}
 
 	/* If Eth TLV is not detected, use UFP TC as default TC */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC,
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC,
 			  &p_hwfn->p_dev->mf_bits) && !eth_tlv)
 		p_data->arr[DCBX_PROTOCOL_ETH].tc = p_hwfn->ufp_info.tc;
 
drivers/net/qede/base/ecore_dev.c +19 -19
index 86ecfb269..e18c2fa89 100644
@@ -805,7 +805,7 @@ static enum _ecore_status_t ecore_llh_hw_init_pf(struct ecore_hwfn *p_hwfn,
 		ecore_wr(p_hwfn, p_ptt, addr, p_hwfn->rel_pf_id);
 	}
 
-	if (OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
+	if (OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
 	    !ECORE_IS_FCOE_PERSONALITY(p_hwfn)) {
 		rc = ecore_llh_add_mac_filter(p_dev, 0,
 					      p_hwfn->hw_info.hw_mac_addr);
@@ -1044,7 +1044,7 @@ ecore_llh_add_filter(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	filter_details.enable = 1;
 	filter_details.value = ((u64)high << 32) | low;
 	filter_details.hdr_sel =
-		OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits) ?
+		OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits) ?
 		1 : /* inner/encapsulated header */
 		0;  /* outer/tunnel header */
 	filter_details.protocol_type = filter_prot_type;
@@ -1083,7 +1083,7 @@ enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return ECORE_AGAIN;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	OSAL_MEM_ZERO(&filter, sizeof(filter));
@@ -1220,7 +1220,7 @@ ecore_llh_add_protocol_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return ECORE_AGAIN;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_llh_protocol_filter_stringify(p_dev, type,
@@ -1287,7 +1287,7 @@ void ecore_llh_remove_mac_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	OSAL_MEM_ZERO(&filter, sizeof(filter));
@@ -1342,7 +1342,7 @@ void ecore_llh_remove_protocol_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_llh_protocol_filter_stringify(p_dev, type,
@@ -1396,8 +1396,8 @@ void ecore_llh_clear_ppfid_filters(struct ecore_dev *p_dev, u8 ppfid)
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
-	    !OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
+	    !OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_abs_ppfid(p_dev, ppfid, &abs_ppfid);
@@ -1423,8 +1423,8 @@ void ecore_llh_clear_all_filters(struct ecore_dev *p_dev)
 {
 	u8 ppfid;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
-	    !OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
+	    !OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		return;
 
 	for (ppfid = 0; ppfid < p_dev->p_llh_info->num_ppfid; ppfid++)
@@ -2674,7 +2674,7 @@ static enum _ecore_status_t ecore_calc_hw_mode(struct ecore_hwfn *p_hwfn)
 		return ECORE_INVAL;
 	}
 
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
 		hw_mode |= 1 << MODE_MF_SD;
 	else
 		hw_mode |= 1 << MODE_MF_SI;
@@ -3382,7 +3382,7 @@ static enum _ecore_status_t ecore_hw_init_port(struct ecore_hwfn *p_hwfn,
 		 * The ppfid should be set in the vector, except in BB which has
 		 * a bug in the LLH where the ppfid is actually engine based.
 		 */
-		if (OSAL_TEST_BIT(ECORE_MF_NEED_DEF_PF, &p_dev->mf_bits)) {
+		if (OSAL_GET_BIT(ECORE_MF_NEED_DEF_PF, &p_dev->mf_bits)) {
 			u8 pf_id = p_hwfn->rel_pf_id;
 
 			if (!ECORE_IS_BB(p_dev))
@@ -3715,11 +3715,11 @@ enum _ecore_status_t ecore_hw_init(struct ecore_dev *p_dev,
 		if (rc != ECORE_SUCCESS)
 			return rc;
 
-		if (IS_PF(p_dev) && (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING,
+		if (IS_PF(p_dev) && (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING,
 						   &p_dev->mf_bits) ||
-				     OSAL_TEST_BIT(ECORE_MF_8021AD_TAGGING,
+				     OSAL_GET_BIT(ECORE_MF_8021AD_TAGGING,
 						   &p_dev->mf_bits))) {
-			if (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING,
+			if (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING,
 					  &p_dev->mf_bits))
 				ether_type = ETHER_TYPE_VLAN;
 			else
@@ -4119,7 +4119,7 @@ enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev)
 		OSAL_MSLEEP(1);
 
 		if (IS_LEAD_HWFN(p_hwfn) &&
-		    OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
+		    OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
 		    !ECORE_IS_FCOE_PERSONALITY(p_hwfn))
 			ecore_llh_remove_mac_filter(p_dev, 0,
 						   p_hwfn->hw_info.hw_mac_addr);
@@ -5113,7 +5113,7 @@ ecore_hw_get_nvm_info(struct ecore_hwfn *p_hwfn,
 			p_hwfn->p_dev->mf_bits |= 1 << ECORE_MF_NEED_DEF_PF;
 		break;
 	}
-	DP_INFO(p_hwfn, "Multi function mode is 0x%lx\n",
+	DP_INFO(p_hwfn, "Multi function mode is 0x%x\n",
 		p_hwfn->p_dev->mf_bits);
 
 	if (ECORE_IS_CMT(p_hwfn->p_dev))
@@ -6218,7 +6218,7 @@ enum _ecore_status_t
 ecore_llh_set_function_as_default(struct ecore_hwfn *p_hwfn,
 				  struct ecore_ptt *p_ptt)
 {
-	if (OSAL_TEST_BIT(ECORE_MF_NEED_DEF_PF, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_NEED_DEF_PF, &p_hwfn->p_dev->mf_bits)) {
 		ecore_wr(p_hwfn, p_ptt,
 			 NIG_REG_LLH_TAGMAC_DEF_PF_VECTOR,
 			 1 << p_hwfn->abs_pf_id / 2);
@@ -6795,5 +6795,5 @@ void ecore_set_fw_mac_addr(__le16 *fw_msb,
 
 bool ecore_is_mf_fip_special(struct ecore_dev *p_dev)
 {
-	return !!OSAL_TEST_BIT(ECORE_MF_FIP_SPECIAL, &p_dev->mf_bits);
+	return !!OSAL_GET_BIT(ECORE_MF_FIP_SPECIAL, &p_dev->mf_bits);
 }
drivers/net/qede/base/ecore_dev_api.h +1 -1
index 5ea8427a0..9ddf502eb 100644
@@ -212,7 +212,7 @@ enum _ecore_status_t ecore_db_recovery_del(struct ecore_dev *p_dev,
 
 static OSAL_INLINE bool ecore_is_mf_ufp(struct ecore_hwfn *p_hwfn)
 {
-	return !!OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits);
+	return !!OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits);
 }
 
 #endif
drivers/net/qede/base/ecore_l2.c +3 -3
index b20d83762..af234dec8 100644
@@ -29,7 +29,7 @@
 
 struct ecore_l2_info {
 	u32 queues;
-	unsigned long **pp_qid_usage;
+	u32 **pp_qid_usage;
 
 	/* The lock is meant to synchronize access to the qid usage */
 	osal_mutex_t lock;
@@ -38,7 +38,7 @@ struct ecore_l2_info {
 enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn)
 {
 	struct ecore_l2_info *p_l2_info;
-	unsigned long **pp_qids;
+	u32 **pp_qids;
 	u32 i;
 
 	if (!ECORE_IS_L2_PERSONALITY(p_hwfn))
@@ -2116,7 +2116,7 @@ void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn,
 			       struct ecore_ptt *p_ptt,
 			       struct ecore_arfs_config_params *p_cfg_params)
 {
-	if (OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS, &p_hwfn->p_dev->mf_bits))
 		return;
 
 	if (p_cfg_params->mode != ECORE_FILTER_CONFIG_MODE_DISABLE) {
drivers/net/qede/base/ecore_mcp.c +2 -2
index 7518765a0..a7485967b 100644
@@ -1732,7 +1732,7 @@ static void ecore_mcp_update_stag(struct ecore_hwfn *p_hwfn,
 	p_hwfn->mcp_info->func_info.ovlan = (u16)shmem_info.ovlan_stag &
 						 FUNC_MF_CFG_OV_STAG_MASK;
 	p_hwfn->hw_info.ovlan = p_hwfn->mcp_info->func_info.ovlan;
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits)) {
 		if (p_hwfn->hw_info.ovlan != ECORE_MCP_VLAN_UNSET) {
 			ecore_wr(p_hwfn, p_ptt, NIG_REG_LLH_FUNC_TAG_VALUE,
 				 p_hwfn->hw_info.ovlan);
@@ -2026,7 +2026,7 @@ ecore_mcp_read_ufp_config(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
 	struct public_func shmem_info;
 	u32 port_cfg, val;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		return;
 
 	OSAL_MEMSET(&p_hwfn->ufp_info, 0, sizeof(p_hwfn->ufp_info));
drivers/net/qede/base/ecore_sp_commands.c +6 -6
index 9860a62b5..44ced135d 100644
@@ -335,16 +335,16 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	p_ramrod->dont_log_ramrods = 0;
 	p_ramrod->log_type_mask = OSAL_CPU_TO_LE16(0x8f);
 
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
 		p_ramrod->mf_mode = MF_OVLAN;
 	else
 		p_ramrod->mf_mode = MF_NPAR;
 
 	p_ramrod->outer_tag_config.outer_tag.tci =
 		OSAL_CPU_TO_LE16(p_hwfn->hw_info.ovlan);
-	if (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING, &p_hwfn->p_dev->mf_bits)) {
 		p_ramrod->outer_tag_config.outer_tag.tpid = ETH_P_8021Q;
-	} else if (OSAL_TEST_BIT(ECORE_MF_8021AD_TAGGING,
+	} else if (OSAL_GET_BIT(ECORE_MF_8021AD_TAGGING,
 		 &p_hwfn->p_dev->mf_bits)) {
 		p_ramrod->outer_tag_config.outer_tag.tpid = ETH_P_8021AD;
 		p_ramrod->outer_tag_config.enable_stag_pri_change = 1;
@@ -357,7 +357,7 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	/* enable_stag_pri_change should be set if port is in BD mode or,
 	 * UFP with Host Control mode.
 	 */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits)) {
 		if (p_hwfn->ufp_info.pri_type == ECORE_UFP_PRI_OS)
 			p_ramrod->outer_tag_config.enable_stag_pri_change = 1;
 		else
@@ -378,7 +378,7 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	ecore_tunn_set_pf_start_params(p_hwfn, p_tunn,
 				       &p_ramrod->tunnel_config);
 
-	if (OSAL_TEST_BIT(ECORE_MF_INTER_PF_SWITCH,
+	if (OSAL_GET_BIT(ECORE_MF_INTER_PF_SWITCH,
 			  &p_hwfn->p_dev->mf_bits))
 		p_ramrod->allow_npar_tx_switching = allow_npar_tx_switch;
 
@@ -638,7 +638,7 @@ enum _ecore_status_t ecore_sp_heartbeat_ramrod(struct ecore_hwfn *p_hwfn)
 	if (rc != ECORE_SUCCESS)
 		return rc;
 
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		p_ent->ramrod.pf_update.mf_vlan |=
 			OSAL_CPU_TO_LE16(((u16)p_hwfn->ufp_info.tc << 13));
 
drivers/net/qede/base/ecore_spq.c +1 -1
index 6c386821f..02f613688 100644
@@ -977,7 +977,7 @@ enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
 			 * for the first successive completed entries.
 			 */
 			SPQ_COMP_BMAP_SET_BIT(p_spq, echo);
-			while (SPQ_COMP_BMAP_TEST_BIT(p_spq,
+			while (SPQ_COMP_BMAP_GET_BIT(p_spq,
 						      p_spq->comp_bitmap_idx)) {
 				SPQ_COMP_BMAP_CLEAR_BIT(p_spq,
 							p_spq->comp_bitmap_idx);
drivers/net/qede/base/ecore_spq.h +5 -5
index 6142c399a..0958e5a0a 100644
@@ -121,17 +121,17 @@ struct ecore_spq {
 #define SPQ_RING_SIZE		\
 	(CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element))
 /* BITS_PER_LONG */
-#define SPQ_COMP_BMAP_SIZE	(SPQ_RING_SIZE / (sizeof(unsigned long) * 8))
-	unsigned long			p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
-	u8				comp_bitmap_idx;
+#define SPQ_COMP_BMAP_SIZE	(SPQ_RING_SIZE / (sizeof(u32) * 8))
+	u32			p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
+	u8			comp_bitmap_idx;
 #define SPQ_COMP_BMAP_SET_BIT(p_spq, idx)				\
 	(OSAL_SET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
 #define SPQ_COMP_BMAP_CLEAR_BIT(p_spq, idx)				\
 	(OSAL_CLEAR_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
-#define SPQ_COMP_BMAP_TEST_BIT(p_spq, idx)	\
-	(OSAL_TEST_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
+#define SPQ_COMP_BMAP_GET_BIT(p_spq, idx)	\
+	(OSAL_GET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
 	/* Statistics */
 	u32				unlimited_pending_count;
drivers/net/qede/qede_main.c +2 -2
index 8580cbcd7..bd63c0ac7 100644
@@ -382,8 +382,8 @@ qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info)
 
 	if (IS_PF(edev)) {
 		dev_info->b_inter_pf_switch =
-			OSAL_TEST_BIT(ECORE_MF_INTER_PF_SWITCH, &edev->mf_bits);
-		if (!OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS, &edev->mf_bits))
+			OSAL_GET_BIT(ECORE_MF_INTER_PF_SWITCH, &edev->mf_bits);
+		if (!OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS, &edev->mf_bits))
 			dev_info->b_arfs_capable = true;
 		dev_info->tx_switching = false;
 
Signature · 1 line
2.17.1
author
#106 lore raw

PATCH v7 6/6 net/hinic: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/hinic/Makefile            |  1 +
 drivers/net/hinic/base/hinic_compat.h | 33 +--------------------------
 drivers/net/hinic/hinic_pmd_ethdev.c  | 18 ++++++++-------
 drivers/net/hinic/hinic_pmd_ethdev.h  |  2 +-
 drivers/net/hinic/meson.build         |  2 ++
 5 files changed, 15 insertions(+), 41 deletions(-)
drivers/net/hinic/Makefile +1 -0
index 87fd843e4..f087baac5 100644
@@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 LIB = librte_pmd_hinic.a
 
 CFLAGS += -O3
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 ifeq ($(CONFIG_RTE_ARCH_ARM64),y)
drivers/net/hinic/base/hinic_compat.h +1 -32
index b72e8cfe2..7fab6dc29 100644
@@ -18,6 +18,7 @@
 #include <rte_spinlock.h>
 #include <rte_cycles.h>
 #include <rte_log.h>
+#include <rte_pmd_bitops.h>
 
 typedef uint8_t   u8;
 typedef int8_t    s8;
@@ -116,38 +117,6 @@ extern int hinic_logtype;
 
 #define HINIC_PAGE_SIZE_DPDK	6
 
-static inline int hinic_test_bit(int nr, volatile unsigned long *addr)
-{
-	int res;
-
-	res = ((*addr) & (1UL << nr)) != 0;
-	return res;
-}
-
-static inline void hinic_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-static inline void hinic_clear_bit(int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-static inline int hinic_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 int hinic_test_and_set_bit(int nr, volatile unsigned long *addr)
-{
-	unsigned long mask = (1UL << nr);
-
-	return __sync_fetch_and_or(addr, mask) & mask;
-}
-
 void *dma_zalloc_coherent(void *dev, size_t size, dma_addr_t *dma_handle,
 			  gfp_t flag);
 void *dma_zalloc_coherent_aligned(void *dev, size_t size,
drivers/net/hinic/hinic_pmd_ethdev.c +10 -8
index 803a39e2d..c53980f44 100644
@@ -269,7 +269,7 @@ static void hinic_dev_interrupt_handler(void *param)
 	struct rte_eth_dev *dev = param;
 	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	if (!hinic_test_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status)) {
+	if (!rte_get_bit32_relaxed(HINIC_DEV_INTR_EN, &nic_dev->dev_status)) {
 		PMD_DRV_LOG(WARNING, "Device's interrupt is disabled, ignore interrupt event, dev_name: %s, port_id: %d",
 			    nic_dev->proc_dev_name, dev->data->port_id);
 		return;
@@ -1076,7 +1076,7 @@ static int hinic_dev_start(struct rte_eth_dev *dev)
 	if (dev->data->dev_conf.intr_conf.lsc != 0)
 		(void)hinic_link_update(dev, 0);
 
-	hinic_set_bit(HINIC_DEV_START, &nic_dev->dev_status);
+	rte_set_bit32_relaxed(HINIC_DEV_START, &nic_dev->dev_status);
 
 	return 0;
 
@@ -1201,7 +1201,8 @@ static void hinic_dev_stop(struct rte_eth_dev *dev)
 	name = dev->data->name;
 	port_id = dev->data->port_id;
 
-	if (!hinic_test_and_clear_bit(HINIC_DEV_START, &nic_dev->dev_status)) {
+	if (!rte_test_and_clear_bit32_relaxed(HINIC_DEV_START,
+					      &nic_dev->dev_status)) {
 		PMD_DRV_LOG(INFO, "Device %s already stopped", name);
 		return;
 	}
@@ -1246,7 +1247,7 @@ static void hinic_disable_interrupt(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	int ret, retries = 0;
 
-	hinic_clear_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
+	rte_clear_bit32_relaxed(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
 
 	/* disable msix interrupt in hardware */
 	hinic_set_msix_state(nic_dev->hwdev, 0, HINIC_MSIX_DISABLE);
@@ -2845,7 +2846,8 @@ static void hinic_dev_close(struct rte_eth_dev *dev)
 {
 	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	if (hinic_test_and_set_bit(HINIC_DEV_CLOSE, &nic_dev->dev_status)) {
+	if (rte_test_and_set_bit32_relaxed(HINIC_DEV_CLOSE,
+					   &nic_dev->dev_status)) {
 		PMD_DRV_LOG(WARNING, "Device %s already closed",
 			    dev->data->name);
 		return;
@@ -3042,7 +3044,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 			    eth_dev->data->name);
 		goto enable_intr_fail;
 	}
-	hinic_set_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
+	rte_set_bit32_relaxed(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
 
 	/* initialize filter info */
 	filter_info = &nic_dev->filter;
@@ -3054,7 +3056,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 	TAILQ_INIT(&nic_dev->filter_fdir_rule_list);
 	TAILQ_INIT(&nic_dev->hinic_flow_list);
 
-	hinic_set_bit(HINIC_DEV_INIT, &nic_dev->dev_status);
+	rte_set_bit32_relaxed(HINIC_DEV_INIT, &nic_dev->dev_status);
 	PMD_DRV_LOG(INFO, "Initialize %s in primary successfully",
 		    eth_dev->data->name);
 
@@ -3110,7 +3112,7 @@ static int hinic_dev_uninit(struct rte_eth_dev *dev)
 	struct hinic_nic_dev *nic_dev;
 
 	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
-	hinic_clear_bit(HINIC_DEV_INIT, &nic_dev->dev_status);
+	rte_clear_bit32_relaxed(HINIC_DEV_INIT, &nic_dev->dev_status);
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
drivers/net/hinic/hinic_pmd_ethdev.h +1 -1
index 3e3f3b360..114f1df92 100644
@@ -171,7 +171,7 @@ struct hinic_nic_dev {
 	unsigned int flags;
 	struct nic_service_cap nic_cap;
 	u32 rx_mode_status;	/* promisc or allmulticast */
-	unsigned long dev_status;
+	u32 dev_status;
 
 	char proc_dev_name[HINIC_DEV_NAME_LEN];
 	/* PF0->COS4, PF1->COS5, PF2->COS6, PF3->COS7,
drivers/net/hinic/meson.build +2 -0
index bc7e24639..8c7ee9dfc 100644
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Huawei Technologies Co., Ltd
 
+allow_experimental_apis = true
+
 subdir('base')
 objs = [base_objs]
 
Signature · 1 line
2.17.1
author
#107 lore raw

v8 cover implement common bit operation APIs

In reply to Joyce Kong

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family and use it for all the PMDs(we started with a few selectively).

v8:
1. Change 'rte_pmd_bitops.h' to 'rte_bitops.h' allowing for future extension into other cases other than PMD only.
2. Replace 'unsigned long' with 'uint32_t' to fix compling errors, the reason is the fact that 32-bit and 64-bit systems have different sized 'unsigned long', which caused incompatibility.

v7:
1. Change the API's head file to 'rte_pmd_bitops.h' as a common- but-not-public file.
2. Replace C11 atomic operations with 'volatile'. As the use cases are limited to PMDs, a 'volatile' is sufficient.

v5,v6:
Trim 'unsigned long' in PMDs down to 'uint32_t', as on mainstream 64-bit OS, 'unsigned long' is 64-bit in size, but the 32-bit OS expects 32-bit 'unsigned long' argument.

v4:
Introduce uint32_t/uint64_t *addr when definiting bit operation APIs.

v3:
1. Change the API's head file back to rte_bitops.h, then implement both 32-bit and 64-bit operations with and without C11 atomic memory ordering.
2. Add multi-core test case for bit operations which implemented with memory ordering.
3. Modify the doc of both APIs and test cases.

v2:
1. Add doxygen comments for the rte bit operation API.
2. Add test cases for common rte bit operation API.
3. Change the header file to rte_io_bitops.h and the operation to rte_io_set_bit() etc., as the API uses barriers inside and the barriers are only needed for IO operations.
4. Use an well defined uint_NN_t type.

Joyce Kong (6):
lib/eal: implement the family of common bit operation APIs test/bitops: add bit operation test case net/axgbe: use common rte bit operation APIs instead net/bnx2x: use common rte bit operation APIs instead net/qede: use common rte bit operation APIs instead net/hinic: use common rte bit operation APIs instead

 MAINTAINERS                               |   5 +
 app/test/Makefile                         |   1 +
 app/test/autotest_data.py                 |   6 +
 app/test/meson.build                      |   2 +
 app/test/test_bitops.c                    | 137 +++++++++++
 doc/api/doxy-api-index.md                 |   5 +-
 drivers/net/axgbe/axgbe_common.h          |  29 +--
 drivers/net/axgbe/axgbe_ethdev.c          |  14 +-
 drivers/net/axgbe/axgbe_ethdev.h          |   2 +-
 drivers/net/axgbe/axgbe_mdio.c            |  15 +-
 drivers/net/bnx2x/bnx2x.c                 | 271 +++++++++++-----------
 drivers/net/bnx2x/bnx2x.h                 |  10 +-
 drivers/net/bnx2x/ecore_sp.c              |  68 +++---
 drivers/net/bnx2x/ecore_sp.h              | 106 ++++-----
 drivers/net/hinic/Makefile                |   1 +
 drivers/net/hinic/base/hinic_compat.h     |  33 +--
 drivers/net/hinic/hinic_pmd_ethdev.c      |  18 +-
 drivers/net/hinic/hinic_pmd_ethdev.h      |   2 +-
 drivers/net/hinic/meson.build             |   2 +
 drivers/net/qede/base/bcm_osal.c          |  22 +-
 drivers/net/qede/base/bcm_osal.h          |  14 +-
 drivers/net/qede/base/ecore.h             |   6 +-
 drivers/net/qede/base/ecore_cxt.c         |   6 +-
 drivers/net/qede/base/ecore_dcbx.c        |   8 +-
 drivers/net/qede/base/ecore_dev.c         |  38 +--
 drivers/net/qede/base/ecore_dev_api.h     |   2 +-
 drivers/net/qede/base/ecore_l2.c          |   6 +-
 drivers/net/qede/base/ecore_mcp.c         |   4 +-
 drivers/net/qede/base/ecore_sp_commands.c |  12 +-
 drivers/net/qede/base/ecore_spq.c         |   2 +-
 drivers/net/qede/base/ecore_spq.h         |  10 +-
 drivers/net/qede/qede_main.c              |   4 +-
 lib/librte_eal/include/meson.build        |   1 +
 lib/librte_eal/include/rte_bitops.h       | 258 ++++++++++++++++++++
 34 files changed, 722 insertions(+), 398 deletions(-)
 create mode 100644 app/test/test_bitops.c
 create mode 100644 lib/librte_eal/include/rte_bitops.h
Signature · 1 line
2.17.1
author
#108 lore raw

PATCH v8 1/6 lib/eal: implement the family of common bit operation APIs

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family.

---
 MAINTAINERS                         |   4 +
 doc/api/doxy-api-index.md           |   5 +-
 lib/librte_eal/include/meson.build  |   1 +
 lib/librte_eal/include/rte_bitops.h | 258 ++++++++++++++++++++++++++++
 4 files changed, 266 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_eal/include/rte_bitops.h
MAINTAINERS +4 -0
index 4800f6884..1d5fad28b 100644
@@ -241,6 +241,10 @@ M: Cristian Dumitrescu <[email protected]>
 F: lib/librte_eal/include/rte_bitmap.h
 F: app/test/test_bitmap.c
 
+Bitops
+M: Joyce Kong <[email protected]>
+F: lib/librte_eal/include/rte_bitops.h
+
 MCSlock - EXPERIMENTAL
 M: Phil Yang <[email protected]>
 F: lib/librte_eal/include/generic/rte_mcslock.h
doc/api/doxy-api-index.md +3 -2
index dff496be0..b63e782ec 100644
@@ -9,6 +9,7 @@ API {#index}
 The public API headers are grouped by topics:
 
 - **device**:
+  [bitops]             (@ref rte_bitops.h),
   [dev]                (@ref rte_dev.h),
   [ethdev]             (@ref rte_ethdev.h),
   [ethctrl]            (@ref rte_eth_ctrl.h),
@@ -133,12 +134,12 @@ The public API headers are grouped by topics:
   [BPF]                (@ref rte_bpf.h)
 
 - **containers**:
+  [bitmap]             (@ref rte_bitmap.h),
   [mbuf]               (@ref rte_mbuf.h),
   [mbuf pool ops]      (@ref rte_mbuf_pool_ops.h),
   [ring]               (@ref rte_ring.h),
   [stack]              (@ref rte_stack.h),
-  [tailq]              (@ref rte_tailq.h),
-  [bitmap]             (@ref rte_bitmap.h)
+  [tailq]              (@ref rte_tailq.h)
 
 - **packet framework**:
   * [port]             (@ref rte_port.h):
lib/librte_eal/include/meson.build +1 -0
index 6fd427494..3afb50a5b 100644
@@ -6,6 +6,7 @@ includes += include_directories('.')
 headers += files(
 	'rte_alarm.h',
 	'rte_bitmap.h',
+	'rte_bitops.h',
 	'rte_branch_prediction.h',
 	'rte_bus.h',
 	'rte_class.h',
lib/librte_eal/include/rte_bitops.h new file +258 -0

258 lines not on this page · raw message

Signature · 1 line
2.17.1
#109 lore raw

Re: [dpdk-dev] [PATCH v8 1/6] lib/eal: implement the family of commonbit operation APIs

Quoted 7 lines

From: dev [mailto:[email protected]] On Behalf Of Joyce Kong
Sent: Thursday, April 16, 2020 7:39 AM

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family.

[...]

Quoted 15 lines

+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Return the original bit from a 32-bit value, then set it to 1 without
+ * memory ordering.
+ *
+ * @param nr
+ * The target bit to get and set.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The original bit.
+ */

lib/librte_eal/include/rte_bitops.h line 109

Quoted 9 lines
lib/librte_eal/include/rte_bitops.h new file +9 -0
+__rte_experimental
+static inline uint32_t
+rte_test_and_set_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+{
+	RTE_ASSERT(nr < 32);
+
+	uint32_t mask = UINT32_C(1) << nr;
+	uint32_t val = *addr;
+	*addr = (*addr) | mask;

Suggestion:
- *addr = (*addr) | mask;
+ *addr = val | mask;

Quoted 18 lines
lib/librte_eal/include/rte_bitops.h new file +6 -0
+	return val & mask;
+}
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior

notice
+ *
+ * Return the original bit from a 32-bit value, then clear it to 0 without
+ * memory ordering.
+ *
+ * @param nr
+ * The target bit to get and clear.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The original bit.
+ */

lib/librte_eal/include/rte_bitops.h line 135

Quoted 9 lines
lib/librte_eal/include/rte_bitops.h new file +9 -0
+__rte_experimental
+static inline uint32_t
+rte_test_and_clear_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+{
+	RTE_ASSERT(nr < 32);
+
+	uint32_t mask = UINT32_C(1) << nr;
+	uint32_t val = *addr;
+	*addr = (*addr) & (~mask);

Suggestion:
- *addr = (*addr) & (~mask);
+ *addr = val & (~mask);

Quoted 6 lines
lib/librte_eal/include/rte_bitops.h new file +5 -1
+	return val & mask;
+}
+
+/*---------------------------- 64 bit operations -------------------------
---*/
+

[...]

Quoted 15 lines

+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Return the original bit from a 64-bit value, then set it to 1 without
+ * memory ordering.
+ *
+ * @param nr
+ * The target bit to get and set.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The original bit.
+ */

lib/librte_eal/include/rte_bitops.h line 228

Quoted 9 lines
lib/librte_eal/include/rte_bitops.h new file +9 -0
+__rte_experimental
+static inline uint64_t
+rte_test_and_set_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)
+{
+	RTE_ASSERT(nr < 64);
+
+	uint64_t mask = UINT64_C(1) << nr;
+	uint64_t val = *addr;
+	*addr = (*addr) | mask;

Suggestion:
- *addr = (*addr) | mask;
+ *addr = val | mask;

Quoted 18 lines
lib/librte_eal/include/rte_bitops.h new file +6 -0
+	return val;
+}
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior

notice
+ *
+ * Return the original bit from a 64-bit value, then clear it to 0 without
+ * memory ordering.
+ *
+ * @param nr
+ * The target bit to get and clear.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The original bit.
+ */

lib/librte_eal/include/rte_bitops.h line 254

Quoted 9 lines
lib/librte_eal/include/rte_bitops.h new file +9 -0
+__rte_experimental
+static inline uint64_t
+rte_test_and_clear_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)
+{
+	RTE_ASSERT(nr < 64);
+
+	uint64_t mask = UINT64_C(1) << nr;
+	uint64_t val = *addr;
+	*addr = (*addr) & (~mask);

Suggestion:
- *addr = (*addr) & (~mask);
+ *addr = val & (~mask);

Quoted 7 lines
lib/librte_eal/include/rte_bitops.h new file +4 -1
+	return val & mask;
+}
+
+#endif /* _RTE_BITOPS_H_ */
--

2.17.1

author
#110 lore raw

Re: [dpdk-dev] [PATCH v8 1/6] lib/eal: implement the family of commonbit operation APIs

Quoted 52 lines

-----Original Message-----
From: Morten Brørup <[email protected]>
Sent: Friday, April 17, 2020 2:55 AM
To: Joyce Kong <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu <[email protected]>; Phil Yang <[email protected]>
Cc: nd <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v8 1/6] lib/eal: implement the family of commonbit operation APIs

Quoted 7 lines

From: dev [mailto:[email protected]] On Behalf Of Joyce Kong
Sent: Thursday, April 16, 2020 7:39 AM

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family.

[...]

Quoted 15 lines

+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Return the original bit from a 32-bit value, then set it to 1

lib/librte_eal/include/rte_bitops.h new file +9 -0
+without
+ * memory ordering.
+ *
+ * @param nr
+ *   The target bit to get and set.
+ * @param addr
+ *   The address holding the bit.
+ * @return
+ *   The original bit.

lib/librte_eal/include/rte_bitops.h line 109

Quoted 10 lines
lib/librte_eal/include/rte_bitops.h new file +10 -0
+ */
+__rte_experimental
+static inline uint32_t
+rte_test_and_set_bit32_relaxed(unsigned int nr, volatile uint32_t
+*addr) {
+	RTE_ASSERT(nr < 32);
+
+	uint32_t mask = UINT32_C(1) << nr;
+	uint32_t val = *addr;
+	*addr = (*addr) | mask;

Suggestion:

Review

Quoted 2 lines
(quoted diff) +1 -1
-	*addr = (*addr) | mask;
+	*addr = val | mask;

Shall take the advice in v9.
Thanks,
Joyce

Quoted 31 lines
Quoted 18 lines
lib/librte_eal/include/rte_bitops.h new file +6 -0
+	return val & mask;
+}
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior

notice
+ *
+ * Return the original bit from a 32-bit value, then clear it to 0

lib/librte_eal/include/rte_bitops.h new file +9 -0
+without
+ * memory ordering.
+ *
+ * @param nr
+ *   The target bit to get and clear.
+ * @param addr
+ *   The address holding the bit.
+ * @return
+ *   The original bit.

lib/librte_eal/include/rte_bitops.h line 135

Quoted 10 lines
lib/librte_eal/include/rte_bitops.h new file +10 -0
+ */
+__rte_experimental
+static inline uint32_t
+rte_test_and_clear_bit32_relaxed(unsigned int nr, volatile uint32_t
+*addr) {
+	RTE_ASSERT(nr < 32);
+
+	uint32_t mask = UINT32_C(1) << nr;
+	uint32_t val = *addr;
+	*addr = (*addr) & (~mask);

Suggestion:

Review

Quoted 2 lines
(quoted diff) +1 -1
-	*addr = (*addr) & (~mask);
+	*addr = val & (~mask);

Shall take the advice in v9.

Quoted 38 lines
Quoted 7 lines
lib/librte_eal/include/rte_bitops.h new file +6 -1
+	return val & mask;
+}
+
+/*---------------------------- 64 bit operations
+-------------------------
---*/
+

[...]

Quoted 15 lines

+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Return the original bit from a 64-bit value, then set it to 1

lib/librte_eal/include/rte_bitops.h new file +9 -0
+without
+ * memory ordering.
+ *
+ * @param nr
+ *   The target bit to get and set.
+ * @param addr
+ *   The address holding the bit.
+ * @return
+ *   The original bit.

lib/librte_eal/include/rte_bitops.h line 228

Quoted 10 lines
lib/librte_eal/include/rte_bitops.h new file +10 -0
+ */
+__rte_experimental
+static inline uint64_t
+rte_test_and_set_bit64_relaxed(unsigned int nr, volatile uint64_t
+*addr) {
+	RTE_ASSERT(nr < 64);
+
+	uint64_t mask = UINT64_C(1) << nr;
+	uint64_t val = *addr;
+	*addr = (*addr) | mask;

Suggestion:

Review

Quoted 2 lines
(quoted diff) +1 -1
-	*addr = (*addr) | mask;
+	*addr = val | mask;

Shall take the advice in v9.

Quoted 31 lines
Quoted 18 lines
lib/librte_eal/include/rte_bitops.h new file +6 -0
+	return val;
+}
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior

notice
+ *
+ * Return the original bit from a 64-bit value, then clear it to 0

lib/librte_eal/include/rte_bitops.h new file +9 -0
+without
+ * memory ordering.
+ *
+ * @param nr
+ *   The target bit to get and clear.
+ * @param addr
+ *   The address holding the bit.
+ * @return
+ *   The original bit.

lib/librte_eal/include/rte_bitops.h line 254

Quoted 10 lines
lib/librte_eal/include/rte_bitops.h new file +10 -0
+ */
+__rte_experimental
+static inline uint64_t
+rte_test_and_clear_bit64_relaxed(unsigned int nr, volatile uint64_t
+*addr) {
+	RTE_ASSERT(nr < 64);
+
+	uint64_t mask = UINT64_C(1) << nr;
+	uint64_t val = *addr;
+	*addr = (*addr) & (~mask);

Suggestion:

Review

Quoted 2 lines
(quoted diff) +1 -1
-	*addr = (*addr) & (~mask);
+	*addr = val & (~mask);

Shall take the advice in v9.

Quoted 7 lines
Quoted 7 lines
lib/librte_eal/include/rte_bitops.h new file +4 -1
+	return val & mask;
+}
+
+#endif /* _RTE_BITOPS_H_ */
--

2.17.1

#111 lore raw

Re: [dpdk-dev] [PATCH v8 1/6] lib/eal: implement the family of common bit operation APIs

In reply to Joyce Kong
Quoted 37 lines · Joyce Kong

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family.

---
 MAINTAINERS                         |   4 +
 doc/api/doxy-api-index.md           |   5 +-
 lib/librte_eal/include/meson.build  |   1 +
 lib/librte_eal/include/rte_bitops.h | 258 ++++++++++++++++++++++++++++
 4 files changed, 266 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_eal/include/rte_bitops.h
MAINTAINERS +4 -0
index 4800f6884..1d5fad28b 100644
@@ -241,6 +241,10 @@ M: Cristian Dumitrescu <[email protected]>
 F: lib/librte_eal/include/rte_bitmap.h
 F: app/test/test_bitmap.c
 
+Bitops
+M: Joyce Kong <[email protected]>
+F: lib/librte_eal/include/rte_bitops.h
+
 MCSlock - EXPERIMENTAL
 M: Phil Yang <[email protected]>
 F: lib/librte_eal/include/generic/rte_mcslock.h
doc/api/doxy-api-index.md +0 -0
index dff496be0..b63e782ec 100644

doc/api/doxy-api-index.md API {#index} · line 12

Quoted 4 lines
doc/api/doxy-api-index.md +1 -0
@@ -9,6 +9,7 @@ API {#index}
 The public API headers are grouped by topics:
 
 - **device**:
+  [bitops]             (@ref rte_bitops.h),

IMO, It may not come in "device" section, instead existing "**basic** section is more appropriate.

author
#112 lore raw

Re: [dpdk-dev] [PATCH v8 1/6] lib/eal: implement the family of common bit operation APIs

Quoted 60 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Friday, April 17, 2020 5:39 PM
To: Joyce Kong <[email protected]>
Cc: [email protected]; Stephen Hemminger <[email protected]>; David Marchand <[email protected]>; Morten Brørup <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; Ravi Kumar <[email protected]>; Rasesh Mody <[email protected]>; Shahed Shaikh <[email protected]>; Ziyang Xuan <[email protected]>; Xiaoyun Wang <[email protected]>; Guoyang Zhou <[email protected]>; Honnappa Nagarahalli <[email protected]>; Gavin Hu <[email protected]>; Phil Yang <[email protected]>; nd <[email protected]>; dpdk-dev <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v8 1/6] lib/eal: implement the family of common bit operation APIs

Quoted 41 lines · Joyce Kong

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family.

---
 MAINTAINERS                         |   4 +
 doc/api/doxy-api-index.md           |   5 +-
 lib/librte_eal/include/meson.build  |   1 +
 lib/librte_eal/include/rte_bitops.h | 258
++++++++++++++++++++++++++++
 4 files changed, 266 insertions(+), 2 deletions(-)  create mode

100644 lib/librte_eal/include/rte_bitops.h

MAINTAINERS index 4800f6884..1d5fad28b renamed from MAINTAINERS +0 -0

100644

MAINTAINERS +0 -0
@@ -241,6 +241,10 @@ M: Cristian Dumitrescu

<[email protected]>
F: lib/librte_eal/include/rte_bitmap.h
F: app/test/test_bitmap.c

MAINTAINERS +4 -0
+Bitops
+M: Joyce Kong <[email protected]>
+F: lib/librte_eal/include/rte_bitops.h
+
 MCSlock - EXPERIMENTAL
 M: Phil Yang <[email protected]>
 F: lib/librte_eal/include/generic/rte_mcslock.h
doc/api/doxy-api-index.md +0 -0
index dff496be0..b63e782ec 100644
@@ -9,6 +9,7 @@ API {#index}
 The public API headers are grouped by topics:
 
Quoted 5 lines

doc/api/doxy-api-index.md API {#index} · line 12

Quoted 2 lines
doc/api/doxy-api-index.md +1 -0
 - **device**:
+  [bitops]             (@ref rte_bitops.h),

IMO, It may not come in "device" section, instead existing "**basic** section is more appropriate.

Will change to '**basic** section' in v9.

author
#113 lore raw

PATCH v8 2/6 test/bitops: add bit operation test case

In reply to Joyce Kong

Add test cases for setting bit, clearing bit, testing and setting bit, testing and clearing bit operation.

---
 MAINTAINERS               |   1 +
 app/test/Makefile         |   1 +
 app/test/autotest_data.py |   6 ++
 app/test/meson.build      |   2 +
 app/test/test_bitops.c    | 137 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 147 insertions(+)
 create mode 100644 app/test/test_bitops.c
MAINTAINERS +1 -0
index 1d5fad28b..4b4b80fe6 100644
@@ -244,6 +244,7 @@ F: app/test/test_bitmap.c
 Bitops
 M: Joyce Kong <[email protected]>
 F: lib/librte_eal/include/rte_bitops.h
+F: app/test/test_bitops.c
 
 MCSlock - EXPERIMENTAL
 M: Phil Yang <[email protected]>
app/test/Makefile +1 -0
index 1f080d162..76014764e 100644
@@ -70,6 +70,7 @@ SRCS-y += test_ticketlock.c
 SRCS-y += test_memory.c
 SRCS-y += test_memzone.c
 SRCS-y += test_bitmap.c
+SRCS-y += test_bitops.c
 SRCS-y += test_reciprocal_division.c
 SRCS-y += test_reciprocal_division_perf.c
 SRCS-y += test_fbarray.c
app/test/autotest_data.py +6 -0
index 7b1d01389..fc3fcc159 100644
@@ -404,6 +404,12 @@
         "Func":    default_autotest,
         "Report":  None,
     },
+    {
+        "Name":    "Bitops test",
+        "Command": "bitops_test",
+        "Func":    default_autotest,
+        "Report":  None,
+    },
     {
         "Name":    "Hash multiwriter autotest",
         "Command": "hash_multiwriter_autotest",
app/test/meson.build +2 -0
index 351d29cb6..da3ca523e 100644
@@ -12,6 +12,7 @@ test_sources = files('commands.c',
 	'test_alarm.c',
 	'test_atomic.c',
 	'test_barrier.c',
+	'test_bitops.c',
 	'test_bpf.c',
 	'test_byteorder.c',
 	'test_cmdline.c',
@@ -160,6 +161,7 @@ fast_tests = [
         ['acl_autotest', true],
         ['alarm_autotest', false],
         ['atomic_autotest', false],
+        ['bitops_autotest', true],
         ['byteorder_autotest', true],
         ['cmdline_autotest', true],
         ['common_autotest', true],
app/test/test_bitops.c new file +137 -0

137 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#114 lore raw

PATCH v8 3/6 net/axgbe: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/axgbe/axgbe_common.h | 29 +----------------------------
 drivers/net/axgbe/axgbe_ethdev.c | 14 +++++++-------
 drivers/net/axgbe/axgbe_ethdev.h |  2 +-
 drivers/net/axgbe/axgbe_mdio.c   | 15 ++++++++-------
 4 files changed, 17 insertions(+), 43 deletions(-)
drivers/net/axgbe/axgbe_common.h +1 -28
index f48117180..d53b48ce6 100644
@@ -21,6 +21,7 @@
 #include <inttypes.h>
 #include <pthread.h>
 
+#include <rte_bitops.h>
 #include <rte_byteorder.h>
 #include <rte_memory.h>
 #include <rte_malloc.h>
@@ -1700,34 +1701,6 @@ do {									\
 #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);
drivers/net/axgbe/axgbe_ethdev.c +7 -7
index 867058845..b83c14144 100644
@@ -327,8 +327,8 @@ axgbe_dev_start(struct rte_eth_dev *dev)
 	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_clear_bit32_relaxed(AXGBE_STOPPED, &pdata->dev_state);
+	rte_clear_bit32_relaxed(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;
@@ -352,17 +352,17 @@ axgbe_dev_stop(struct rte_eth_dev *dev)
 
 	rte_intr_disable(&pdata->pci_dev->intr_handle);
 
-	if (axgbe_test_bit(AXGBE_STOPPED, &pdata->dev_state))
+	if (rte_get_bit32_relaxed(AXGBE_STOPPED, &pdata->dev_state))
 		return;
 
-	axgbe_set_bit(AXGBE_STOPPED, &pdata->dev_state);
+	rte_set_bit32_relaxed(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_set_bit32_relaxed(AXGBE_DOWN, &pdata->dev_state);
 }
 
 /* Clear all resources like TX/RX queues. */
@@ -1470,8 +1470,8 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
 
 	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_set_bit32_relaxed(AXGBE_DOWN, &pdata->dev_state);
+	rte_set_bit32_relaxed(AXGBE_STOPPED, &pdata->dev_state);
 	pdata->eth_dev = eth_dev;
 
 	pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
drivers/net/axgbe/axgbe_ethdev.h +1 -1
index f10ec4a40..1898e9eb9 100644
@@ -522,7 +522,7 @@ struct axgbe_port {
 	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;
drivers/net/axgbe/axgbe_mdio.c +8 -7
index 0f226c3f2..d1196d308 100644
@@ -916,7 +916,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata)
 {
 	int ret;
 
-	axgbe_set_bit(AXGBE_LINK_INIT, &pdata->dev_state);
+	rte_set_bit32_relaxed(AXGBE_LINK_INIT, &pdata->dev_state);
 	pdata->link_check = rte_get_timer_cycles();
 
 	ret = pdata->phy_if.phy_impl.an_config(pdata);
@@ -981,9 +981,9 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
 
 	ret = __axgbe_phy_config_aneg(pdata);
 	if (ret)
-		axgbe_set_bit(AXGBE_LINK_ERR, &pdata->dev_state);
+		rte_set_bit32_relaxed(AXGBE_LINK_ERR, &pdata->dev_state);
 	else
-		axgbe_clear_bit(AXGBE_LINK_ERR, &pdata->dev_state);
+		rte_clear_bit32_relaxed(AXGBE_LINK_ERR, &pdata->dev_state);
 
 	pthread_mutex_unlock(&pdata->an_mutex);
 
@@ -1072,7 +1072,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)
 	unsigned int reg = 0;
 	unsigned long autoneg_start_time;
 
-	if (axgbe_test_bit(AXGBE_LINK_ERR, &pdata->dev_state)) {
+	if (rte_get_bit32_relaxed(AXGBE_LINK_ERR, &pdata->dev_state)) {
 		pdata->phy.link = 0;
 		goto adjust_link;
 	}
@@ -1116,10 +1116,11 @@ static void axgbe_phy_status(struct axgbe_port *pdata)
 			}
 		}
 		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_get_bit32_relaxed(AXGBE_LINK_INIT, &pdata->dev_state))
+			rte_clear_bit32_relaxed(AXGBE_LINK_INIT,
+						&pdata->dev_state);
 	} else {
-		if (axgbe_test_bit(AXGBE_LINK_INIT, &pdata->dev_state)) {
+		if (rte_get_bit32_relaxed(AXGBE_LINK_INIT, &pdata->dev_state)) {
 			axgbe_check_link_timeout(pdata);
 
 			if (link_aneg)
Signature · 1 line
2.17.1
author
#115 lore raw

PATCH v8 4/6 net/bnx2x: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/bnx2x/bnx2x.c    | 271 +++++++++++++++++------------------
 drivers/net/bnx2x/bnx2x.h    |  10 +-
 drivers/net/bnx2x/ecore_sp.c |  68 ++++-----
 drivers/net/bnx2x/ecore_sp.h | 106 +++++++-------
 4 files changed, 221 insertions(+), 234 deletions(-)
drivers/net/bnx2x/bnx2x.c +130 -141
index 0b4030e2b..eaed6274a 100644
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <zlib.h>
+#include <rte_bitops.h>
 #include <rte_string_fns.h>
 
 #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"
@@ -129,32 +130,6 @@ static void bnx2x_ack_sb(struct bnx2x_softc *sc, uint8_t igu_sb_id,
 			 uint8_t storm, uint16_t index, uint8_t op,
 			 uint8_t update);
 
-int bnx2x_test_bit(int nr, volatile unsigned long *addr)
-{
-	int res;
-
-	mb();
-	res = ((*addr) & (1UL << nr)) != 0;
-	mb();
-	return res;
-}
-
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-void bnx2x_clear_bit(int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-int bnx2x_test_and_clear_bit(int nr, volatile unsigned long *addr)
-{
-	unsigned long mask = (1UL << nr);
-	return __sync_fetch_and_and(addr, ~mask) & mask;
-}
-
 int bnx2x_cmpxchg(volatile int *addr, int old, int new)
 {
 	return __sync_val_compare_and_swap(addr, old, new);
@@ -1434,16 +1409,16 @@ static int
 bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 		 int mac_type, uint8_t wait_for_comp)
 {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
 	int rc;
 
 	/* wait for completion of requested */
 	if (wait_for_comp) {
-		bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+		rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 	}
 
 	/* Set the mac type of addresses we want to clear */
-	bnx2x_set_bit(mac_type, &vlan_mac_flags);
+	rte_set_bit32_relaxed(mac_type, &vlan_mac_flags);
 
 	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
 	if (rc < 0)
@@ -1454,8 +1429,7 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 
 static int
 bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
-			unsigned long *rx_accept_flags,
-			unsigned long *tx_accept_flags)
+			uint32_t *rx_accept_flags, uint32_t *tx_accept_flags)
 {
 	/* Clear the flags first */
 	*rx_accept_flags = 0;
@@ -1470,26 +1444,28 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 		break;
 
 	case BNX2X_RX_MODE_NORMAL:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		break;
 
 	case BNX2X_RX_MODE_ALLMULTI:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		break;
 
@@ -1500,19 +1476,23 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 		 * should receive matched and unmatched (in resolution of port)
 		 * unicast packets.
 		 */
-		bnx2x_set_bit(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		if (IS_MF_SI(sc)) {
-			bnx2x_set_bit(ECORE_ACCEPT_ALL_UNICAST, tx_accept_flags);
+			rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_UNICAST,
+					tx_accept_flags);
 		} else {
-			bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+			rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST,
+					      tx_accept_flags);
 		}
 
 		break;
@@ -1524,8 +1504,8 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 
 	/* Set ACCEPT_ANY_VLAN as we do not enable filtering by VLAN */
 	if (rx_mode != BNX2X_RX_MODE_NONE) {
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
 	}
 
 	return 0;
@@ -1554,7 +1534,7 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
 	ramrod_param.rdata = BNX2X_SP(sc, rx_mode_rdata);
 	ramrod_param.rdata_mapping =
 	    (rte_iova_t)BNX2X_SP_MAPPING(sc, rx_mode_rdata),
-	    bnx2x_set_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	    rte_set_bit32_relaxed(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
 	ramrod_param.ramrod_flags = ramrod_flags;
 	ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1573,8 +1553,8 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
 
 int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
 {
-	unsigned long rx_mode_flags = 0, ramrod_flags = 0;
-	unsigned long rx_accept_flags = 0, tx_accept_flags = 0;
+	uint32_t rx_mode_flags = 0, ramrod_flags = 0;
+	uint32_t rx_accept_flags = 0, tx_accept_flags = 0;
 	int rc;
 
 	rc = bnx2x_fill_accept_flags(sc, sc->rx_mode, &rx_accept_flags,
@@ -1583,9 +1563,9 @@ int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
 		return rc;
 	}
 
-	bnx2x_set_bit(RAMROD_RX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_TX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_RX, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_TX, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 
 	return bnx2x_set_q_rx_mode(sc, sc->fp[0].cl_id, rx_mode_flags,
 				 rx_accept_flags, tx_accept_flags,
@@ -1710,7 +1690,8 @@ static int bnx2x_func_wait_started(struct bnx2x_softc *sc)
 			    "Forcing STARTED-->TX_STOPPED-->STARTED");
 
 		func_params.f_obj = &sc->func_obj;
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
 
 		/* STARTED-->TX_STOPPED */
 		func_params.cmd = ECORE_F_CMD_TX_STOP;
@@ -1734,7 +1715,7 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
 
 	q_params.q_obj = &sc->sp_objs[fp->index].q_obj;
 	/* We want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
 	/* Stop the primary connection: */
 
@@ -1763,26 +1744,25 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
 }
 
 /* wait for the outstanding SP commands */
-static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, unsigned long mask)
+static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, uint32_t mask)
 {
-	unsigned long tmp;
+	uint32_t tmp;
 	int tout = 5000;	/* wait for 5 secs tops */
 
 	while (tout--) {
 		mb();
-		if (!(atomic_load_acq_long(&sc->sp_state) & mask)) {
+		if (!(atomic_load_acq_int(&sc->sp_state) & mask))
 			return TRUE;
-		}
 
 		DELAY(1000);
 	}
 
 	mb();
 
-	tmp = atomic_load_acq_long(&sc->sp_state);
+	tmp = atomic_load_acq_int(&sc->sp_state);
 	if (tmp & mask) {
 		PMD_DRV_LOG(INFO, sc, "Filtering completion timed out: "
-			    "sp_state 0x%lx, mask 0x%lx", tmp, mask);
+			    "sp_state 0x%x, mask 0x%x", tmp, mask);
 		return FALSE;
 	}
 
@@ -1795,7 +1775,7 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
 	int rc;
 
 	/* prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_STOP;
 
@@ -1809,7 +1789,8 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
 	if (rc) {
 		PMD_DRV_LOG(NOTICE, sc, "FUNC_STOP ramrod failed. "
 			    "Running a dry transaction");
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
 		return ecore_func_state_change(sc, &func_params);
 	}
 
@@ -1821,7 +1802,7 @@ static int bnx2x_reset_hw(struct bnx2x_softc *sc, uint32_t load_code)
 	struct ecore_func_state_params func_params = { NULL };
 
 	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_HW_RESET;
@@ -1878,11 +1859,11 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
 	 * a race between the completion code and this code.
 	 */
 
-	if (bnx2x_test_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state)) {
-		bnx2x_set_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state);
-	} else {
+	if (rte_get_bit32_relaxed(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state))
+		rte_set_bit32_relaxed(ECORE_FILTER_RX_MODE_SCHED,
+				      &sc->sp_state);
+	else
 		bnx2x_set_storm_rx_mode(sc);
-	}
 
 	/* Clean up multicast configuration */
 	rparam.mcast_obj = &sc->mcast_obj;
@@ -1922,9 +1903,8 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
 	 * If SP settings didn't get completed so far - something
 	 * very wrong has happen.
 	 */
-	if (!bnx2x_wait_sp_comp(sc, ~0x0UL)) {
+	if (!bnx2x_wait_sp_comp(sc, ~0x0U))
 		PMD_DRV_LOG(NOTICE, sc, "Common slow path ramrods got stuck!");
-	}
 
 unload_error:
 
@@ -1964,7 +1944,7 @@ static void bnx2x_disable_close_the_gate(struct bnx2x_softc *sc)
  */
 static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
 	struct ecore_mcast_ramrod_params rparam = { NULL };
 	struct ecore_vlan_mac_obj *mac_obj = &sc->sp_objs->mac_obj;
 	int rc;
@@ -1972,12 +1952,12 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 	/* Cleanup MACs' object first... */
 
 	/* Wait for completion of requested */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 	/* Perform a dry cleanup */
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
 
 	/* Clean ETH primary MAC */
-	bnx2x_set_bit(ECORE_ETH_MAC, &vlan_mac_flags);
+	rte_set_bit32_relaxed(ECORE_ETH_MAC, &vlan_mac_flags);
 	rc = mac_obj->delete_all(sc, &sc->sp_objs->mac_obj, &vlan_mac_flags,
 				 &ramrod_flags);
 	if (rc != 0) {
@@ -1986,7 +1966,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 
 	/* Cleanup UC list */
 	vlan_mac_flags = 0;
-	bnx2x_set_bit(ECORE_UC_LIST_MAC, &vlan_mac_flags);
+	rte_set_bit32_relaxed(ECORE_UC_LIST_MAC, &vlan_mac_flags);
 	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
 	if (rc != 0) {
 		PMD_DRV_LOG(NOTICE, sc,
@@ -1996,7 +1976,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 	/* Now clean mcast object... */
 
 	rparam.mcast_obj = &sc->mcast_obj;
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
 
 	/* Add a DEL command... */
 	rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_DEL);
@@ -4294,13 +4274,13 @@ static void bnx2x_handle_mcast_eqe(struct bnx2x_softc *sc)
 static void
 bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *elem)
 {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
 	int rc = 0;
 	uint32_t cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK;
 	struct ecore_vlan_mac_obj *vlan_mac_obj;
 
 	/* always push next commands out, don't wait here */
-	bnx2x_set_bit(RAMROD_CONT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_CONT, &ramrod_flags);
 
 	switch (le32toh(elem->message.data.eth_event.echo) >> BNX2X_SWCID_SHIFT) {
 	case ECORE_FILTER_MAC_PENDING:
@@ -4331,12 +4311,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *e
 
 static void bnx2x_handle_rx_mode_eqe(struct bnx2x_softc *sc)
 {
-	bnx2x_clear_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	rte_clear_bit32_relaxed(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
 	/* send rx_mode command again if was requested */
-	if (bnx2x_test_and_clear_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state)) {
+	if (rte_test_and_clear_bit32_relaxed(ECORE_FILTER_RX_MODE_SCHED,
+						&sc->sp_state))
 		bnx2x_set_storm_rx_mode(sc);
-	}
 }
 
 static void bnx2x_update_eq_prod(struct bnx2x_softc *sc, uint16_t prod)
@@ -4705,7 +4685,7 @@ static int bnx2x_init_hw(struct bnx2x_softc *sc, uint32_t load_code)
 	PMD_INIT_FUNC_TRACE(sc);
 
 	/* prepare the parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_HW_INIT;
@@ -4953,7 +4933,7 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
 {
 	struct bnx2x_fastpath *fp = &sc->fp[idx];
 	uint32_t cids[ECORE_MULTI_TX_COS] = { 0 };
-	unsigned long q_type = 0;
+	uint32_t q_type = 0;
 	int cos;
 
 	fp->sc = sc;
@@ -5000,8 +4980,8 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
 	bnx2x_update_fp_sb_idx(fp);
 
 	/* Configure Queue State object */
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_RX, &q_type);
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_TX, &q_type);
+	rte_set_bit32_relaxed(ECORE_Q_TYPE_HAS_RX, &q_type);
+	rte_set_bit32_relaxed(ECORE_Q_TYPE_HAS_TX, &q_type);
 
 	ecore_init_queue_obj(sc,
 			     &sc->sp_objs[idx].q_obj,
@@ -5815,7 +5795,7 @@ static int bnx2x_func_start(struct bnx2x_softc *sc)
 	    &func_params.params.start;
 
 	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_START;
@@ -6391,11 +6371,11 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
 	uint8_t cos;
 	int cxt_index, cxt_offset;
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->tx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC, &init_params->rx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC, &init_params->tx.flags);
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
 
 	/* HC rate */
 	init_params->rx.hc_rate =
@@ -6426,10 +6406,10 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
 static unsigned long
 bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
 	/* PF driver will always initialize the Queue to an ACTIVE state */
-	bnx2x_set_bit(ECORE_Q_FLG_ACTIVE, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_ACTIVE, &flags);
 
 	/*
 	 * tx only connections collect statistics (on the same index as the
@@ -6437,9 +6417,9 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 	 * connection is initialized.
 	 */
 
-	bnx2x_set_bit(ECORE_Q_FLG_STATS, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_STATS, &flags);
 	if (zero_stats) {
-		bnx2x_set_bit(ECORE_Q_FLG_ZERO_STATS, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_ZERO_STATS, &flags);
 	}
 
 	/*
@@ -6447,28 +6427,28 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 	 * CoS-ness doesn't survive the loopback
 	 */
 	if (sc->flags & BNX2X_TX_SWITCHING) {
-		bnx2x_set_bit(ECORE_Q_FLG_TX_SWITCH, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_TX_SWITCH, &flags);
 	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
 
 	return flags;
 }
 
 static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)
 {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
 	if (IS_MF_SD(sc)) {
-		bnx2x_set_bit(ECORE_Q_FLG_OV, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_OV, &flags);
 	}
 
 	if (leading) {
-		bnx2x_set_bit(ECORE_Q_FLG_LEADING_RSS, &flags);
-		bnx2x_set_bit(ECORE_Q_FLG_MCAST, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_LEADING_RSS, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_MCAST, &flags);
 	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_VLAN, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_VLAN, &flags);
 
 	/* merge with common flags */
 	return flags | bnx2x_get_common_flags(sc, TRUE);
@@ -6589,7 +6569,7 @@ bnx2x_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, uint8_t lea
 	q_params.q_obj = &BNX2X_SP_OBJ(sc, fp).q_obj;
 
 	/* we want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
 	/* prepare the INIT parameters */
 	bnx2x_pf_q_prep_init(sc, fp, &q_params.params.init);
@@ -6657,20 +6637,20 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
 
 	params.rss_obj = rss_obj;
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &params.ramrod_flags);
 
-	bnx2x_set_bit(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
 
 	/* RSS configuration */
-	bnx2x_set_bit(ECORE_RSS_IPV4, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV4_TCP, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6_TCP, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV4, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV4_TCP, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV6, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV6_TCP, &params.rss_flags);
 	if (rss_obj->udp_rss_v4) {
-		bnx2x_set_bit(ECORE_RSS_IPV4_UDP, &params.rss_flags);
+		rte_set_bit32_relaxed(ECORE_RSS_IPV4_UDP, &params.rss_flags);
 	}
 	if (rss_obj->udp_rss_v6) {
-		bnx2x_set_bit(ECORE_RSS_IPV6_UDP, &params.rss_flags);
+		rte_set_bit32_relaxed(ECORE_RSS_IPV6_UDP, &params.rss_flags);
 	}
 
 	/* Hash bits */
@@ -6685,7 +6665,7 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
 			params.rss_key[i] = (uint32_t) rte_rand();
 		}
 
-		bnx2x_set_bit(ECORE_RSS_SET_SRCH, &params.rss_flags);
+		rte_set_bit32_relaxed(ECORE_RSS_SET_SRCH, &params.rss_flags);
 	}
 
 	if (IS_PF(sc))
@@ -6730,7 +6710,7 @@ static int bnx2x_init_rss_pf(struct bnx2x_softc *sc)
 static int
 bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 		struct ecore_vlan_mac_obj *obj, uint8_t set, int mac_type,
-		unsigned long *ramrod_flags)
+		uint32_t *ramrod_flags)
 {
 	struct ecore_vlan_mac_ramrod_params ramrod_param;
 	int rc;
@@ -6742,11 +6722,12 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 	ramrod_param.ramrod_flags = *ramrod_flags;
 
 	/* fill a user request section if needed */
-	if (!bnx2x_test_bit(RAMROD_CONT, ramrod_flags)) {
+	if (!rte_get_bit32_relaxed(RAMROD_CONT, ramrod_flags)) {
 		rte_memcpy(ramrod_param.user_req.u.mac.mac, mac,
 				 ETH_ALEN);
 
-		bnx2x_set_bit(mac_type, &ramrod_param.user_req.vlan_mac_flags);
+		rte_set_bit32_relaxed(mac_type,
+				      &ramrod_param.user_req.vlan_mac_flags);
 
 /* Set the command: ADD or DEL */
 		ramrod_param.user_req.cmd = (set) ? ECORE_VLAN_MAC_ADD :
@@ -6769,11 +6750,11 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 
 static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)
 {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
 
 	PMD_DRV_LOG(DEBUG, sc, "Adding Ethernet MAC");
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 
 	/* Eth MAC is set on RSS leading client (fp[0]) */
 	return bnx2x_set_mac_one(sc, sc->link_params.mac_addr,
@@ -6905,24 +6886,26 @@ bnx2x_fill_report_data(struct bnx2x_softc *sc, struct bnx2x_link_report_data *da
 
 	/* Link is down */
 	if (!sc->link_vars.link_up || (sc->flags & BNX2X_MF_FUNC_DIS)) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			    &data->link_report_flags);
 	}
 
 	/* Full DUPLEX */
 	if (sc->link_vars.duplex == DUPLEX_FULL) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_FULL_DUPLEX,
 			    &data->link_report_flags);
 	}
 
 	/* Rx Flow Control is ON */
 	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_RX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_RX_FC_ON, &data->link_report_flags);
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_RX_FC_ON,
+				&data->link_report_flags);
 	}
 
 	/* Tx Flow Control is ON */
 	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_TX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_TX_FC_ON, &data->link_report_flags);
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_TX_FC_ON,
+				&data->link_report_flags);
 	}
 }
 
@@ -6941,14 +6924,14 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 
 	/* Don't report link down or exactly the same link status twice */
 	if (!memcmp(&cur_data, &sc->last_reported_link, sizeof(cur_data)) ||
-	    (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	    (rte_get_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			  &sc->last_reported_link.link_report_flags) &&
-	     bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	     rte_get_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			  &cur_data.link_report_flags))) {
 		return;
 	}
 
-	ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %lx, last_reported_link = %lx",
+	ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %x, last_reported_link = %x",
 		       cur_data.link_report_flags,
 		       sc->last_reported_link.link_report_flags);
 
@@ -6958,15 +6941,16 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 	/* report new link params and remember the state for the next time */
 	rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
 
-	if (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	if (rte_get_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			 &cur_data.link_report_flags)) {
 		ELINK_DEBUG_P0(sc, "NIC Link is Down");
 	} else {
 		__rte_unused const char *duplex;
 		__rte_unused const char *flow;
 
-		if (bnx2x_test_and_clear_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
-					   &cur_data.link_report_flags)) {
+		if (rte_test_and_clear_bit32_relaxed
+					(BNX2X_LINK_REPORT_FULL_DUPLEX,
+					 &cur_data.link_report_flags)) {
 			duplex = "full";
 				ELINK_DEBUG_P0(sc, "link set to full duplex");
 		} else {
@@ -6980,20 +6964,25 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
  * enabled.
  */
 		if (cur_data.link_report_flags) {
-			if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			if (rte_get_bit32_relaxed
+					(BNX2X_LINK_REPORT_RX_FC_ON,
 					 &cur_data.link_report_flags) &&
-			    bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			    rte_get_bit32_relaxed(BNX2X_LINK_REPORT_TX_FC_ON,
 					 &cur_data.link_report_flags)) {
 				flow = "ON - receive & transmit";
-			} else if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
-						&cur_data.link_report_flags) &&
-				   !bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			} else if (rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_RX_FC_ON,
+						 &cur_data.link_report_flags) &&
+				   !rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_TX_FC_ON,
 						 &cur_data.link_report_flags)) {
 				flow = "ON - receive";
-			} else if (!bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			} else if (!rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_RX_FC_ON,
 						 &cur_data.link_report_flags) &&
-				   bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
-						&cur_data.link_report_flags)) {
+				   rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_TX_FC_ON,
+						 &cur_data.link_report_flags)) {
 				flow = "ON - transmit";
 			} else {
 				flow = "none";	/* possible? */
@@ -7413,7 +7402,7 @@ int bnx2x_nic_load(struct bnx2x_softc *sc)
 	bnx2x_set_rx_mode(sc);
 
 	/* wait for all pending SP commands to complete */
-	if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0UL)) {
+	if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0U)) {
 		PMD_DRV_LOG(NOTICE, sc, "Timeout waiting for all SPs to complete!");
 		bnx2x_periodic_stop(sc);
 		bnx2x_nic_unload(sc, UNLOAD_CLOSE, FALSE);
drivers/net/bnx2x/bnx2x.h +3 -7
index 1dbc98197..63be72a5b 100644
@@ -1000,8 +1000,8 @@ struct bnx2x_sp_objs {
  * link parameters twice.
  */
 struct bnx2x_link_report_data {
-	uint16_t      line_speed;        /* Effective line speed */
-	unsigned long link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
+	uint16_t line_speed;        /* Effective line speed */
+	uint32_t link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
 };
 
 enum {
@@ -1232,7 +1232,7 @@ struct bnx2x_softc {
 	/* slow path */
 	struct bnx2x_dma      sp_dma;
 	struct bnx2x_slowpath *sp;
-	unsigned long       sp_state;
+	uint32_t	    sp_state;
 
 	/* slow path queue */
 	struct bnx2x_dma spq_dma;
@@ -1812,10 +1812,6 @@ static const uint32_t dmae_reg_go_c[] = {
 #define PCI_PM_D0    1
 #define PCI_PM_D3hot 2
 
-int  bnx2x_test_bit(int nr, volatile unsigned long * addr);
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long * addr);
-void bnx2x_clear_bit(int nr, volatile unsigned long * addr);
-int  bnx2x_test_and_clear_bit(int nr, volatile unsigned long * addr);
 int  bnx2x_cmpxchg(volatile int *addr, int old, int new);
 
 int bnx2x_dma_alloc(struct bnx2x_softc *sc, size_t size,
drivers/net/bnx2x/ecore_sp.c +34 -34

241 lines not on this page · raw message

drivers/net/bnx2x/ecore_sp.h +54 -52

310 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#116 lore raw

PATCH v8 5/6 net/qede: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/qede/base/bcm_osal.c          | 22 +------------
 drivers/net/qede/base/bcm_osal.h          | 14 ++++-----
 drivers/net/qede/base/ecore.h             |  6 ++--
 drivers/net/qede/base/ecore_cxt.c         |  6 ++--
 drivers/net/qede/base/ecore_dcbx.c        |  8 ++---
 drivers/net/qede/base/ecore_dev.c         | 38 +++++++++++------------
 drivers/net/qede/base/ecore_dev_api.h     |  2 +-
 drivers/net/qede/base/ecore_l2.c          |  6 ++--
 drivers/net/qede/base/ecore_mcp.c         |  4 +--
 drivers/net/qede/base/ecore_sp_commands.c | 12 +++----
 drivers/net/qede/base/ecore_spq.c         |  2 +-
 drivers/net/qede/base/ecore_spq.h         | 10 +++---
 drivers/net/qede/qede_main.c              |  4 +--
 13 files changed, 56 insertions(+), 78 deletions(-)
drivers/net/qede/base/bcm_osal.c +1 -21
index 48d016e24..54e5e4f98 100644
@@ -46,26 +46,6 @@ u32 qede_osal_log2(u32 val)
 	return log;
 }
 
-inline void qede_set_bit(u32 nr, unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-inline void qede_clr_bit(u32 nr, unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-inline bool qede_test_bit(u32 nr, unsigned long *addr)
-{
-	bool res;
-
-	rte_mb();
-	res = ((*addr) & (1UL << nr)) != 0;
-	rte_mb();
-	return res;
-}
-
 static inline u32 qede_ffb(unsigned long word)
 {
 	unsigned long first_bit;
@@ -95,7 +75,7 @@ static inline u32 qede_ffz(unsigned long word)
 	return first_zero ? (first_zero - 1) : OSAL_BITS_PER_UL;
 }
 
-inline u32 qede_find_first_zero_bit(unsigned long *addr, u32 limit)
+inline u32 qede_find_first_zero_bit(u32 *addr, u32 limit)
 {
 	u32 i;
 	u32 nwords = 0;
drivers/net/qede/base/bcm_osal.h +6 -8
index 513f6a8b4..e4d915773 100644
@@ -8,6 +8,7 @@
 #define __BCM_OSAL_H
 
 #include <stdbool.h>
+#include <rte_bitops.h>
 #include <rte_byteorder.h>
 #include <rte_spinlock.h>
 #include <rte_malloc.h>
@@ -308,23 +309,20 @@ typedef struct osal_list_t {
 #define OSAL_BITS_PER_UL_MASK		(OSAL_BITS_PER_UL - 1)
 
 /* Bitops */
-void qede_set_bit(u32, unsigned long *);
 #define OSAL_SET_BIT(bit, bitmap) \
-	qede_set_bit(bit, bitmap)
+	rte_set_bit32_relaxed(bit, bitmap)
 
-void qede_clr_bit(u32, unsigned long *);
 #define OSAL_CLEAR_BIT(bit, bitmap) \
-	qede_clr_bit(bit, bitmap)
+	rte_clear_bit32_relaxed(bit, bitmap)
 
-bool qede_test_bit(u32, unsigned long *);
-#define OSAL_TEST_BIT(bit, bitmap) \
-	qede_test_bit(bit, bitmap)
+#define OSAL_GET_BIT(bit, bitmap) \
+	rte_get_bit32_relaxed(bit, bitmap)
 
 u32 qede_find_first_bit(unsigned long *, u32);
 #define OSAL_FIND_FIRST_BIT(bitmap, length) \
 	qede_find_first_bit(bitmap, length)
 
-u32 qede_find_first_zero_bit(unsigned long *, u32);
+u32 qede_find_first_zero_bit(u32 *bitmap, u32 length);
 #define OSAL_FIND_FIRST_ZERO_BIT(bitmap, length) \
 	qede_find_first_zero_bit(bitmap, length)
 
drivers/net/qede/base/ecore.h +3 -3
index b2077bc46..498bb6f09 100644
@@ -422,8 +422,8 @@ struct ecore_hw_info {
 	u8 max_chains_per_vf;
 
 	u32 port_mode;
-	u32	hw_mode;
-	unsigned long device_capabilities;
+	u32 hw_mode;
+	u32 device_capabilities;
 
 	/* Default DCBX mode */
 	u8 dcbx_mode;
@@ -807,7 +807,7 @@ struct ecore_dev {
 
 	u8				path_id;
 
-	unsigned long			mf_bits;
+	u32				mf_bits;
 	enum ecore_mf_mode		mf_mode;
 #define IS_MF_DEFAULT(_p_hwfn)	\
 	(((_p_hwfn)->p_dev)->mf_mode == ECORE_MF_DEFAULT)
drivers/net/qede/base/ecore_cxt.c +3 -3
index 773b75ecd..dda47ea67 100644
@@ -154,7 +154,7 @@ struct ecore_ilt_client_cfg {
 struct ecore_cid_acquired_map {
 	u32 start_cid;
 	u32 max_count;
-	unsigned long *cid_map;
+	u32 *cid_map;
 };
 
 struct ecore_src_t2 {
@@ -1991,7 +1991,7 @@ static bool ecore_cxt_test_cid_acquired(struct ecore_hwfn *p_hwfn,
 	}
 
 	rel_cid = cid - (*pp_map)->start_cid;
-	if (!OSAL_TEST_BIT(rel_cid, (*pp_map)->cid_map)) {
+	if (!OSAL_GET_BIT(rel_cid, (*pp_map)->cid_map)) {
 		DP_NOTICE(p_hwfn, true,
 			  "CID %d [vifd %02x] not acquired", cid, vfid);
 		goto fail;
@@ -2102,7 +2102,7 @@ enum _ecore_status_t ecore_cxt_set_pf_params(struct ecore_hwfn *p_hwfn)
 
 		count = p_params->num_arfs_filters;
 
-		if (!OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS,
+		if (!OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS,
 				   &p_hwfn->p_dev->mf_bits))
 			p_hwfn->p_cxt_mngr->arfs_count = count;
 
drivers/net/qede/base/ecore_dcbx.c +4 -4
index ccd4383bb..31234f18c 100644
@@ -148,7 +148,7 @@ ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
 	p_data->arr[type].update = UPDATE_DCB_DSCP;
 
 	/* Do not add valn tag 0 when DCB is enabled and port is in UFP mode */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		p_data->arr[type].dont_add_vlan0 = true;
 
 	/* QM reconf data */
@@ -156,8 +156,8 @@ ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
 		p_hwfn->hw_info.offload_tc = tc;
 
 	/* Configure dcbx vlan priority in doorbell block for roce EDPM */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits) &&
-	    (type == DCBX_PROTOCOL_ROCE)) {
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits) &&
+	    type == DCBX_PROTOCOL_ROCE) {
 		ecore_wr(p_hwfn, p_ptt, DORQ_REG_TAG1_OVRD_MODE, 1);
 		ecore_wr(p_hwfn, p_ptt, DORQ_REG_PF_PCP, prio << 1);
 	}
@@ -293,7 +293,7 @@ ecore_dcbx_process_tlv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	}
 
 	/* If Eth TLV is not detected, use UFP TC as default TC */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC,
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC,
 			  &p_hwfn->p_dev->mf_bits) && !eth_tlv)
 		p_data->arr[DCBX_PROTOCOL_ETH].tc = p_hwfn->ufp_info.tc;
 
drivers/net/qede/base/ecore_dev.c +19 -19
index 86ecfb269..e18c2fa89 100644
@@ -805,7 +805,7 @@ static enum _ecore_status_t ecore_llh_hw_init_pf(struct ecore_hwfn *p_hwfn,
 		ecore_wr(p_hwfn, p_ptt, addr, p_hwfn->rel_pf_id);
 	}
 
-	if (OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
+	if (OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
 	    !ECORE_IS_FCOE_PERSONALITY(p_hwfn)) {
 		rc = ecore_llh_add_mac_filter(p_dev, 0,
 					      p_hwfn->hw_info.hw_mac_addr);
@@ -1044,7 +1044,7 @@ ecore_llh_add_filter(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	filter_details.enable = 1;
 	filter_details.value = ((u64)high << 32) | low;
 	filter_details.hdr_sel =
-		OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits) ?
+		OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits) ?
 		1 : /* inner/encapsulated header */
 		0;  /* outer/tunnel header */
 	filter_details.protocol_type = filter_prot_type;
@@ -1083,7 +1083,7 @@ enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return ECORE_AGAIN;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	OSAL_MEM_ZERO(&filter, sizeof(filter));
@@ -1220,7 +1220,7 @@ ecore_llh_add_protocol_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return ECORE_AGAIN;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_llh_protocol_filter_stringify(p_dev, type,
@@ -1287,7 +1287,7 @@ void ecore_llh_remove_mac_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	OSAL_MEM_ZERO(&filter, sizeof(filter));
@@ -1342,7 +1342,7 @@ void ecore_llh_remove_protocol_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_llh_protocol_filter_stringify(p_dev, type,
@@ -1396,8 +1396,8 @@ void ecore_llh_clear_ppfid_filters(struct ecore_dev *p_dev, u8 ppfid)
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
-	    !OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
+	    !OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_abs_ppfid(p_dev, ppfid, &abs_ppfid);
@@ -1423,8 +1423,8 @@ void ecore_llh_clear_all_filters(struct ecore_dev *p_dev)
 {
 	u8 ppfid;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
-	    !OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
+	    !OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		return;
 
 	for (ppfid = 0; ppfid < p_dev->p_llh_info->num_ppfid; ppfid++)
@@ -2674,7 +2674,7 @@ static enum _ecore_status_t ecore_calc_hw_mode(struct ecore_hwfn *p_hwfn)
 		return ECORE_INVAL;
 	}
 
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
 		hw_mode |= 1 << MODE_MF_SD;
 	else
 		hw_mode |= 1 << MODE_MF_SI;
@@ -3382,7 +3382,7 @@ static enum _ecore_status_t ecore_hw_init_port(struct ecore_hwfn *p_hwfn,
 		 * The ppfid should be set in the vector, except in BB which has
 		 * a bug in the LLH where the ppfid is actually engine based.
 		 */
-		if (OSAL_TEST_BIT(ECORE_MF_NEED_DEF_PF, &p_dev->mf_bits)) {
+		if (OSAL_GET_BIT(ECORE_MF_NEED_DEF_PF, &p_dev->mf_bits)) {
 			u8 pf_id = p_hwfn->rel_pf_id;
 
 			if (!ECORE_IS_BB(p_dev))
@@ -3715,11 +3715,11 @@ enum _ecore_status_t ecore_hw_init(struct ecore_dev *p_dev,
 		if (rc != ECORE_SUCCESS)
 			return rc;
 
-		if (IS_PF(p_dev) && (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING,
+		if (IS_PF(p_dev) && (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING,
 						   &p_dev->mf_bits) ||
-				     OSAL_TEST_BIT(ECORE_MF_8021AD_TAGGING,
+				     OSAL_GET_BIT(ECORE_MF_8021AD_TAGGING,
 						   &p_dev->mf_bits))) {
-			if (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING,
+			if (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING,
 					  &p_dev->mf_bits))
 				ether_type = ETHER_TYPE_VLAN;
 			else
@@ -4119,7 +4119,7 @@ enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev)
 		OSAL_MSLEEP(1);
 
 		if (IS_LEAD_HWFN(p_hwfn) &&
-		    OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
+		    OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
 		    !ECORE_IS_FCOE_PERSONALITY(p_hwfn))
 			ecore_llh_remove_mac_filter(p_dev, 0,
 						   p_hwfn->hw_info.hw_mac_addr);
@@ -5113,7 +5113,7 @@ ecore_hw_get_nvm_info(struct ecore_hwfn *p_hwfn,
 			p_hwfn->p_dev->mf_bits |= 1 << ECORE_MF_NEED_DEF_PF;
 		break;
 	}
-	DP_INFO(p_hwfn, "Multi function mode is 0x%lx\n",
+	DP_INFO(p_hwfn, "Multi function mode is 0x%x\n",
 		p_hwfn->p_dev->mf_bits);
 
 	if (ECORE_IS_CMT(p_hwfn->p_dev))
@@ -6218,7 +6218,7 @@ enum _ecore_status_t
 ecore_llh_set_function_as_default(struct ecore_hwfn *p_hwfn,
 				  struct ecore_ptt *p_ptt)
 {
-	if (OSAL_TEST_BIT(ECORE_MF_NEED_DEF_PF, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_NEED_DEF_PF, &p_hwfn->p_dev->mf_bits)) {
 		ecore_wr(p_hwfn, p_ptt,
 			 NIG_REG_LLH_TAGMAC_DEF_PF_VECTOR,
 			 1 << p_hwfn->abs_pf_id / 2);
@@ -6795,5 +6795,5 @@ void ecore_set_fw_mac_addr(__le16 *fw_msb,
 
 bool ecore_is_mf_fip_special(struct ecore_dev *p_dev)
 {
-	return !!OSAL_TEST_BIT(ECORE_MF_FIP_SPECIAL, &p_dev->mf_bits);
+	return !!OSAL_GET_BIT(ECORE_MF_FIP_SPECIAL, &p_dev->mf_bits);
 }
drivers/net/qede/base/ecore_dev_api.h +1 -1
index 5ea8427a0..9ddf502eb 100644
@@ -212,7 +212,7 @@ enum _ecore_status_t ecore_db_recovery_del(struct ecore_dev *p_dev,
 
 static OSAL_INLINE bool ecore_is_mf_ufp(struct ecore_hwfn *p_hwfn)
 {
-	return !!OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits);
+	return !!OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits);
 }
 
 #endif
drivers/net/qede/base/ecore_l2.c +3 -3
index b20d83762..af234dec8 100644
@@ -29,7 +29,7 @@
 
 struct ecore_l2_info {
 	u32 queues;
-	unsigned long **pp_qid_usage;
+	u32 **pp_qid_usage;
 
 	/* The lock is meant to synchronize access to the qid usage */
 	osal_mutex_t lock;
@@ -38,7 +38,7 @@ struct ecore_l2_info {
 enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn)
 {
 	struct ecore_l2_info *p_l2_info;
-	unsigned long **pp_qids;
+	u32 **pp_qids;
 	u32 i;
 
 	if (!ECORE_IS_L2_PERSONALITY(p_hwfn))
@@ -2116,7 +2116,7 @@ void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn,
 			       struct ecore_ptt *p_ptt,
 			       struct ecore_arfs_config_params *p_cfg_params)
 {
-	if (OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS, &p_hwfn->p_dev->mf_bits))
 		return;
 
 	if (p_cfg_params->mode != ECORE_FILTER_CONFIG_MODE_DISABLE) {
drivers/net/qede/base/ecore_mcp.c +2 -2
index 7518765a0..a7485967b 100644
@@ -1732,7 +1732,7 @@ static void ecore_mcp_update_stag(struct ecore_hwfn *p_hwfn,
 	p_hwfn->mcp_info->func_info.ovlan = (u16)shmem_info.ovlan_stag &
 						 FUNC_MF_CFG_OV_STAG_MASK;
 	p_hwfn->hw_info.ovlan = p_hwfn->mcp_info->func_info.ovlan;
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits)) {
 		if (p_hwfn->hw_info.ovlan != ECORE_MCP_VLAN_UNSET) {
 			ecore_wr(p_hwfn, p_ptt, NIG_REG_LLH_FUNC_TAG_VALUE,
 				 p_hwfn->hw_info.ovlan);
@@ -2026,7 +2026,7 @@ ecore_mcp_read_ufp_config(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
 	struct public_func shmem_info;
 	u32 port_cfg, val;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		return;
 
 	OSAL_MEMSET(&p_hwfn->ufp_info, 0, sizeof(p_hwfn->ufp_info));
drivers/net/qede/base/ecore_sp_commands.c +6 -6
index 9860a62b5..44ced135d 100644
@@ -335,16 +335,16 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	p_ramrod->dont_log_ramrods = 0;
 	p_ramrod->log_type_mask = OSAL_CPU_TO_LE16(0x8f);
 
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
 		p_ramrod->mf_mode = MF_OVLAN;
 	else
 		p_ramrod->mf_mode = MF_NPAR;
 
 	p_ramrod->outer_tag_config.outer_tag.tci =
 		OSAL_CPU_TO_LE16(p_hwfn->hw_info.ovlan);
-	if (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING, &p_hwfn->p_dev->mf_bits)) {
 		p_ramrod->outer_tag_config.outer_tag.tpid = ETH_P_8021Q;
-	} else if (OSAL_TEST_BIT(ECORE_MF_8021AD_TAGGING,
+	} else if (OSAL_GET_BIT(ECORE_MF_8021AD_TAGGING,
 		 &p_hwfn->p_dev->mf_bits)) {
 		p_ramrod->outer_tag_config.outer_tag.tpid = ETH_P_8021AD;
 		p_ramrod->outer_tag_config.enable_stag_pri_change = 1;
@@ -357,7 +357,7 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	/* enable_stag_pri_change should be set if port is in BD mode or,
 	 * UFP with Host Control mode.
 	 */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits)) {
 		if (p_hwfn->ufp_info.pri_type == ECORE_UFP_PRI_OS)
 			p_ramrod->outer_tag_config.enable_stag_pri_change = 1;
 		else
@@ -378,7 +378,7 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	ecore_tunn_set_pf_start_params(p_hwfn, p_tunn,
 				       &p_ramrod->tunnel_config);
 
-	if (OSAL_TEST_BIT(ECORE_MF_INTER_PF_SWITCH,
+	if (OSAL_GET_BIT(ECORE_MF_INTER_PF_SWITCH,
 			  &p_hwfn->p_dev->mf_bits))
 		p_ramrod->allow_npar_tx_switching = allow_npar_tx_switch;
 
@@ -638,7 +638,7 @@ enum _ecore_status_t ecore_sp_heartbeat_ramrod(struct ecore_hwfn *p_hwfn)
 	if (rc != ECORE_SUCCESS)
 		return rc;
 
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		p_ent->ramrod.pf_update.mf_vlan |=
 			OSAL_CPU_TO_LE16(((u16)p_hwfn->ufp_info.tc << 13));
 
drivers/net/qede/base/ecore_spq.c +1 -1
index 6c386821f..02f613688 100644
@@ -977,7 +977,7 @@ enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
 			 * for the first successive completed entries.
 			 */
 			SPQ_COMP_BMAP_SET_BIT(p_spq, echo);
-			while (SPQ_COMP_BMAP_TEST_BIT(p_spq,
+			while (SPQ_COMP_BMAP_GET_BIT(p_spq,
 						      p_spq->comp_bitmap_idx)) {
 				SPQ_COMP_BMAP_CLEAR_BIT(p_spq,
 							p_spq->comp_bitmap_idx);
drivers/net/qede/base/ecore_spq.h +5 -5
index 6142c399a..0958e5a0a 100644
@@ -121,17 +121,17 @@ struct ecore_spq {
 #define SPQ_RING_SIZE		\
 	(CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element))
 /* BITS_PER_LONG */
-#define SPQ_COMP_BMAP_SIZE	(SPQ_RING_SIZE / (sizeof(unsigned long) * 8))
-	unsigned long			p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
-	u8				comp_bitmap_idx;
+#define SPQ_COMP_BMAP_SIZE	(SPQ_RING_SIZE / (sizeof(u32) * 8))
+	u32			p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
+	u8			comp_bitmap_idx;
 #define SPQ_COMP_BMAP_SET_BIT(p_spq, idx)				\
 	(OSAL_SET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
 #define SPQ_COMP_BMAP_CLEAR_BIT(p_spq, idx)				\
 	(OSAL_CLEAR_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
-#define SPQ_COMP_BMAP_TEST_BIT(p_spq, idx)	\
-	(OSAL_TEST_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
+#define SPQ_COMP_BMAP_GET_BIT(p_spq, idx)	\
+	(OSAL_GET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
 	/* Statistics */
 	u32				unlimited_pending_count;
drivers/net/qede/qede_main.c +2 -2
index 8580cbcd7..bd63c0ac7 100644
@@ -382,8 +382,8 @@ qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info)
 
 	if (IS_PF(edev)) {
 		dev_info->b_inter_pf_switch =
-			OSAL_TEST_BIT(ECORE_MF_INTER_PF_SWITCH, &edev->mf_bits);
-		if (!OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS, &edev->mf_bits))
+			OSAL_GET_BIT(ECORE_MF_INTER_PF_SWITCH, &edev->mf_bits);
+		if (!OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS, &edev->mf_bits))
 			dev_info->b_arfs_capable = true;
 		dev_info->tx_switching = false;
 
Signature · 1 line
2.17.1
author
#117 lore raw

PATCH v8 6/6 net/hinic: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/hinic/Makefile            |  1 +
 drivers/net/hinic/base/hinic_compat.h | 33 +--------------------------
 drivers/net/hinic/hinic_pmd_ethdev.c  | 18 ++++++++-------
 drivers/net/hinic/hinic_pmd_ethdev.h  |  2 +-
 drivers/net/hinic/meson.build         |  2 ++
 5 files changed, 15 insertions(+), 41 deletions(-)
drivers/net/hinic/Makefile +1 -0
index 87fd843e4..f087baac5 100644
@@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 LIB = librte_pmd_hinic.a
 
 CFLAGS += -O3
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 ifeq ($(CONFIG_RTE_ARCH_ARM64),y)
drivers/net/hinic/base/hinic_compat.h +1 -32
index 921b83012..2d21b7b67 100644
@@ -10,6 +10,7 @@
 #include <unistd.h>
 #include <pthread.h>
 #include <rte_common.h>
+#include <rte_bitops.h>
 #include <rte_byteorder.h>
 #include <rte_memzone.h>
 #include <rte_memcpy.h>
@@ -116,38 +117,6 @@ extern int hinic_logtype;
 
 #define HINIC_PAGE_SIZE_DPDK	6
 
-static inline int hinic_test_bit(int nr, volatile unsigned long *addr)
-{
-	int res;
-
-	res = ((*addr) & (1UL << nr)) != 0;
-	return res;
-}
-
-static inline void hinic_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-static inline void hinic_clear_bit(int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-static inline int hinic_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 int hinic_test_and_set_bit(int nr, volatile unsigned long *addr)
-{
-	unsigned long mask = (1UL << nr);
-
-	return __sync_fetch_and_or(addr, mask) & mask;
-}
-
 void *dma_zalloc_coherent(void *dev, size_t size, dma_addr_t *dma_handle,
 			  unsigned int socket_id);
 
drivers/net/hinic/hinic_pmd_ethdev.c +10 -8
index 8493f6e42..e8c070759 100644
@@ -270,7 +270,7 @@ static void hinic_dev_interrupt_handler(void *param)
 	struct rte_eth_dev *dev = param;
 	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	if (!hinic_test_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status)) {
+	if (!rte_get_bit32_relaxed(HINIC_DEV_INTR_EN, &nic_dev->dev_status)) {
 		PMD_DRV_LOG(WARNING, "Device's interrupt is disabled, ignore interrupt event, dev_name: %s, port_id: %d",
 			    nic_dev->proc_dev_name, dev->data->port_id);
 		return;
@@ -1079,7 +1079,7 @@ static int hinic_dev_start(struct rte_eth_dev *dev)
 	if (dev->data->dev_conf.intr_conf.lsc != 0)
 		(void)hinic_link_update(dev, 0);
 
-	hinic_set_bit(HINIC_DEV_START, &nic_dev->dev_status);
+	rte_set_bit32_relaxed(HINIC_DEV_START, &nic_dev->dev_status);
 
 	return 0;
 
@@ -1204,7 +1204,8 @@ static void hinic_dev_stop(struct rte_eth_dev *dev)
 	name = dev->data->name;
 	port_id = dev->data->port_id;
 
-	if (!hinic_test_and_clear_bit(HINIC_DEV_START, &nic_dev->dev_status)) {
+	if (!rte_test_and_clear_bit32_relaxed(HINIC_DEV_START,
+					      &nic_dev->dev_status)) {
 		PMD_DRV_LOG(INFO, "Device %s already stopped", name);
 		return;
 	}
@@ -1249,7 +1250,7 @@ static void hinic_disable_interrupt(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	int ret, retries = 0;
 
-	hinic_clear_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
+	rte_clear_bit32_relaxed(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
 
 	/* disable msix interrupt in hardware */
 	hinic_set_msix_state(nic_dev->hwdev, 0, HINIC_MSIX_DISABLE);
@@ -2848,7 +2849,8 @@ static void hinic_dev_close(struct rte_eth_dev *dev)
 {
 	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	if (hinic_test_and_set_bit(HINIC_DEV_CLOSE, &nic_dev->dev_status)) {
+	if (rte_test_and_set_bit32_relaxed(HINIC_DEV_CLOSE,
+					   &nic_dev->dev_status)) {
 		PMD_DRV_LOG(WARNING, "Device %s already closed",
 			    dev->data->name);
 		return;
@@ -3045,7 +3047,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 			    eth_dev->data->name);
 		goto enable_intr_fail;
 	}
-	hinic_set_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
+	rte_set_bit32_relaxed(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
 
 	/* initialize filter info */
 	filter_info = &nic_dev->filter;
@@ -3057,7 +3059,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 	TAILQ_INIT(&nic_dev->filter_fdir_rule_list);
 	TAILQ_INIT(&nic_dev->hinic_flow_list);
 
-	hinic_set_bit(HINIC_DEV_INIT, &nic_dev->dev_status);
+	rte_set_bit32_relaxed(HINIC_DEV_INIT, &nic_dev->dev_status);
 	PMD_DRV_LOG(INFO, "Initialize %s in primary successfully",
 		    eth_dev->data->name);
 
@@ -3113,7 +3115,7 @@ static int hinic_dev_uninit(struct rte_eth_dev *dev)
 	struct hinic_nic_dev *nic_dev;
 
 	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
-	hinic_clear_bit(HINIC_DEV_INIT, &nic_dev->dev_status);
+	rte_clear_bit32_relaxed(HINIC_DEV_INIT, &nic_dev->dev_status);
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
drivers/net/hinic/hinic_pmd_ethdev.h +1 -1
index 3e3f3b360..114f1df92 100644
@@ -171,7 +171,7 @@ struct hinic_nic_dev {
 	unsigned int flags;
 	struct nic_service_cap nic_cap;
 	u32 rx_mode_status;	/* promisc or allmulticast */
-	unsigned long dev_status;
+	u32 dev_status;
 
 	char proc_dev_name[HINIC_DEV_NAME_LEN];
 	/* PF0->COS4, PF1->COS5, PF2->COS6, PF3->COS7,
drivers/net/hinic/meson.build +2 -0
index bc7e24639..8c7ee9dfc 100644
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Huawei Technologies Co., Ltd
 
+allow_experimental_apis = true
+
 subdir('base')
 objs = [base_objs]
 
Signature · 1 line
2.17.1
author
#118 lore raw

v9 cover implement common bit operation APIs

In reply to Joyce Kong

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family and use it for all the PMDs(we started with a few selectively).

v9:
1. Change '*addr = (*addr) | mask' to '*addr = val | mask' <Morten Brørup>.
2. Move 'rte_bitops.h' from 'device' section to 'basic' section in 'doxy-api-index.md'<Jerin Jacob>.
v8:
1. Change 'rte_pmd_bitops.h' to 'rte_bitops.h' allowing for future extension into other cases other than PMD only.
2. Replace 'unsigned long' with 'uint32_t' to fix compling errors, the reason is the fact that 32-bit and 64-bit systems have different sized 'unsigned long', which caused incompatibility.

v7:
1. Change the API's head file to 'rte_pmd_bitops.h' as a common- but-not-public file.
2. Replace C11 atomic operations with 'volatile'. As the use cases are limited to PMDs, a 'volatile' is sufficient.

v5,v6:
Trim 'unsigned long' in PMDs down to 'uint32_t', as on mainstream 64-bit OS, 'unsigned long' is 64-bit in size, but the 32-bit OS expects 32-bit 'unsigned long' argument.

v4:
Introduce uint32_t/uint64_t *addr when definiting bit operation APIs.

v3:
1. Change the API's head file back to rte_bitops.h, then implement both 32-bit and 64-bit operations with and without C11 atomic memory ordering.
2. Add multi-core test case for bit operations which implemented with memory ordering.
3. Modify the doc of both APIs and test cases.

v2:
1. Add doxygen comments for the rte bit operation API.
2. Add test cases for common rte bit operation API.
3. Change the header file to rte_io_bitops.h and the operation to rte_io_set_bit() etc., as the API uses barriers inside and the barriers are only needed for IO operations.
4. Use an well defined uint_NN_t type.

Joyce Kong (6):
lib/eal: implement the family of common bit operation APIs test/bitops: add bit operation test case net/axgbe: use common rte bit operation APIs instead net/bnx2x: use common rte bit operation APIs instead net/qede: use common rte bit operation APIs instead net/hinic: use common rte bit operation APIs instead

 MAINTAINERS                               |   5 +
 app/test/Makefile                         |   1 +
 app/test/autotest_data.py                 |   6 +
 app/test/meson.build                      |   2 +
 app/test/test_bitops.c                    | 137 +++++++++++
 doc/api/doxy-api-index.md                 |   7 +-
 drivers/net/axgbe/axgbe_common.h          |  29 +--
 drivers/net/axgbe/axgbe_ethdev.c          |  14 +-
 drivers/net/axgbe/axgbe_ethdev.h          |   2 +-
 drivers/net/axgbe/axgbe_mdio.c            |  15 +-
 drivers/net/bnx2x/bnx2x.c                 | 271 +++++++++++-----------
 drivers/net/bnx2x/bnx2x.h                 |  10 +-
 drivers/net/bnx2x/ecore_sp.c              |  68 +++---
 drivers/net/bnx2x/ecore_sp.h              | 106 ++++-----
 drivers/net/hinic/Makefile                |   1 +
 drivers/net/hinic/base/hinic_compat.h     |  33 +--
 drivers/net/hinic/hinic_pmd_ethdev.c      |  18 +-
 drivers/net/hinic/hinic_pmd_ethdev.h      |   2 +-
 drivers/net/hinic/meson.build             |   2 +
 drivers/net/qede/base/bcm_osal.c          |  22 +-
 drivers/net/qede/base/bcm_osal.h          |  14 +-
 drivers/net/qede/base/ecore.h             |   6 +-
 drivers/net/qede/base/ecore_cxt.c         |   6 +-
 drivers/net/qede/base/ecore_dcbx.c        |   8 +-
 drivers/net/qede/base/ecore_dev.c         |  38 +--
 drivers/net/qede/base/ecore_dev_api.h     |   2 +-
 drivers/net/qede/base/ecore_l2.c          |   6 +-
 drivers/net/qede/base/ecore_mcp.c         |   4 +-
 drivers/net/qede/base/ecore_sp_commands.c |  12 +-
 drivers/net/qede/base/ecore_spq.c         |   2 +-
 drivers/net/qede/base/ecore_spq.h         |  10 +-
 drivers/net/qede/qede_main.c              |   4 +-
 lib/librte_eal/include/meson.build        |   1 +
 lib/librte_eal/include/rte_bitops.h       | 258 ++++++++++++++++++++
 34 files changed, 723 insertions(+), 399 deletions(-)
 create mode 100644 app/test/test_bitops.c
 create mode 100644 lib/librte_eal/include/rte_bitops.h
Signature · 1 line
2.17.1
author
#119 lore raw

PATCH v9 1/6 lib/eal: implement the family of common bit operation APIs

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family.

---
 MAINTAINERS                         |   4 +
 doc/api/doxy-api-index.md           |   7 +-
 lib/librte_eal/include/meson.build  |   1 +
 lib/librte_eal/include/rte_bitops.h | 258 ++++++++++++++++++++++++++++
 4 files changed, 267 insertions(+), 3 deletions(-)
 create mode 100644 lib/librte_eal/include/rte_bitops.h
MAINTAINERS +4 -0
index 1bf00d7e5..c5c255994 100644
@@ -241,6 +241,10 @@ M: Cristian Dumitrescu <[email protected]>
 F: lib/librte_eal/include/rte_bitmap.h
 F: app/test/test_bitmap.c
 
+Bitops
+M: Joyce Kong <[email protected]>
+F: lib/librte_eal/include/rte_bitops.h
+
 MCSlock - EXPERIMENTAL
 M: Phil Yang <[email protected]>
 F: lib/librte_eal/include/generic/rte_mcslock.h
doc/api/doxy-api-index.md +4 -3
index dff496be0..52e2be31d 100644
@@ -133,12 +133,12 @@ The public API headers are grouped by topics:
   [BPF]                (@ref rte_bpf.h)
 
 - **containers**:
+  [bitmap]             (@ref rte_bitmap.h),
   [mbuf]               (@ref rte_mbuf.h),
   [mbuf pool ops]      (@ref rte_mbuf_pool_ops.h),
   [ring]               (@ref rte_ring.h),
   [stack]              (@ref rte_stack.h),
-  [tailq]              (@ref rte_tailq.h),
-  [bitmap]             (@ref rte_bitmap.h)
+  [tailq]              (@ref rte_tailq.h)
 
 - **packet framework**:
   * [port]             (@ref rte_port.h):
@@ -165,7 +165,8 @@ The public API headers are grouped by topics:
   [random]             (@ref rte_random.h),
   [config file]        (@ref rte_cfgfile.h),
   [key/value args]     (@ref rte_kvargs.h),
-  [string]             (@ref rte_string_fns.h)
+  [string]             (@ref rte_string_fns.h),
+  [bitops]             (@ref rte_bitops.h)
 
 - **debug**:
   [jobstats]           (@ref rte_jobstats.h),
lib/librte_eal/include/meson.build +1 -0
index 6fd427494..3afb50a5b 100644
@@ -6,6 +6,7 @@ includes += include_directories('.')
 headers += files(
 	'rte_alarm.h',
 	'rte_bitmap.h',
+	'rte_bitops.h',
 	'rte_branch_prediction.h',
 	'rte_bus.h',
 	'rte_class.h',
lib/librte_eal/include/rte_bitops.h new file +258 -0

258 lines not on this page · raw message

Signature · 1 line
2.17.1
#120 lore raw

Re: [dpdk-dev] [PATCH v9 1/6] lib/eal: implement the family of common bit operation APIs

24/04/2020 05:21, Joyce Kong:

doc/api/doxy-api-index.md The public API headers are grouped by topics: · line 141

Quoted 11 lines
doc/api/doxy-api-index.md +2 -2
 - **containers**:
+  [bitmap]             (@ref rte_bitmap.h),
   [mbuf]               (@ref rte_mbuf.h),
   [mbuf pool ops]      (@ref rte_mbuf_pool_ops.h),
   [ring]               (@ref rte_ring.h),
   [stack]              (@ref rte_stack.h),
-  [tailq]              (@ref rte_tailq.h),
-  [bitmap]             (@ref rte_bitmap.h)
+  [tailq]              (@ref rte_tailq.h)

Why do you move bitmap?
I like having mbuf as the one.

author
#121 lore raw

Re: [dpdk-dev] [PATCH v9 1/6] lib/eal: implement the family of common bit operation APIs

Quoted 16 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Friday, April 24, 2020 4:09 PM
To: Joyce Kong <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu <[email protected]>; Phil Yang <[email protected]>; nd <[email protected]>; [email protected]
Subject: Re: [PATCH v9 1/6] lib/eal: implement the family of common bit operation APIs

24/04/2020 05:21, Joyce Kong:

Quoted 15 lines

doc/api/doxy-api-index.md The public API headers are grouped by topics: · line 141

Quoted 11 lines
doc/api/doxy-api-index.md +2 -2
 - **containers**:
+  [bitmap]             (@ref rte_bitmap.h),
   [mbuf]               (@ref rte_mbuf.h),
   [mbuf pool ops]      (@ref rte_mbuf_pool_ops.h),
   [ring]               (@ref rte_ring.h),
   [stack]              (@ref rte_stack.h),
-  [tailq]              (@ref rte_tailq.h),
-  [bitmap]             (@ref rte_bitmap.h)
+  [tailq]              (@ref rte_tailq.h)

Why do you move bitmap?
I like having mbuf as the one.

Yeah, will move bitmap back in v10.

#122 lore raw

Re: [dpdk-dev] [PATCH v9 1/6] lib/eal: implement the family of common bit operation APIs

In reply to Joyce Kong

24/04/2020 05:21, Joyce Kong:

Quoted 3 lines

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family.

[...]

lib/librte_eal/include/rte_bitops.h line 248

Quoted 10 lines
lib/librte_eal/include/rte_bitops.h new file +10 -0
+rte_get_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_set_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_clear_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_test_and_set_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_test_and_clear_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_get_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)
+rte_set_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)
+rte_clear_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)
+rte_test_and_set_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)
+rte_test_and_clear_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)

Sorry, I have one more naming concern with this series. I prefer a common namespace for bit operations.
Would you be OK to prefix all function names with rte_bit_relaxed_?

author
#123 lore raw

Re: [dpdk-dev] [PATCH v9 1/6] lib/eal: implement the family of common bit operation APIs

Quoted 20 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Sunday, April 26, 2020 3:59 AM
To: Joyce Kong <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu <[email protected]>; Phil Yang <[email protected]>; [email protected]; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v9 1/6] lib/eal: implement the family of common bit operation APIs

24/04/2020 05:21, Joyce Kong:

Quoted 3 lines

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family.

[...]

Quoted 16 lines

Review

Quoted 11 lines
(quoted diff) +11 -0
+rte_get_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_set_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_clear_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_test_and_set_bit32_relaxed(unsigned int nr, volatile uint32_t
+*addr) rte_test_and_clear_bit32_relaxed(unsigned int nr, volatile
+uint32_t *addr) rte_get_bit64_relaxed(unsigned int nr, volatile
+uint64_t *addr) rte_set_bit64_relaxed(unsigned int nr, volatile
+uint64_t *addr) rte_clear_bit64_relaxed(unsigned int nr, volatile
+uint64_t *addr) rte_test_and_set_bit64_relaxed(unsigned int nr,
+volatile uint64_t *addr) rte_test_and_clear_bit64_relaxed(unsigned
+int nr, volatile uint64_t *addr)

Sorry, I have one more naming concern with this series. I prefer a common namespace for bit operations.
Would you be OK to prefix all function names with rte_bit_relaxed_?

Hi Thomas,
Do you mean to rename the functions as 'rte_bit_relaxed_get_bit32'? If the example is ok, I will modify as this in v10. Thanks, Joyce

#124 lore raw

Re: [dpdk-dev] [PATCH v9 1/6] lib/eal: implement the family of common bit operation APIs

26/04/2020 09:18, Joyce Kong:

Quoted 22 lines

From: Thomas Monjalon <[email protected]>

Quoted 5 lines

24/04/2020 05:21, Joyce Kong:

Quoted 3 lines

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family.

[...]

Quoted 16 lines

Review

Quoted 11 lines
(quoted diff) +11 -0
+rte_get_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_set_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_clear_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)
+rte_test_and_set_bit32_relaxed(unsigned int nr, volatile uint32_t
+*addr) rte_test_and_clear_bit32_relaxed(unsigned int nr, volatile
+uint32_t *addr) rte_get_bit64_relaxed(unsigned int nr, volatile
+uint64_t *addr) rte_set_bit64_relaxed(unsigned int nr, volatile
+uint64_t *addr) rte_clear_bit64_relaxed(unsigned int nr, volatile
+uint64_t *addr) rte_test_and_set_bit64_relaxed(unsigned int nr,
+volatile uint64_t *addr) rte_test_and_clear_bit64_relaxed(unsigned
+int nr, volatile uint64_t *addr)

Sorry, I have one more naming concern with this series. I prefer a common namespace for bit operations.
Would you be OK to prefix all function names with rte_bit_relaxed_?

Quoted 3 lines

Hi Thomas,
Do you mean to rename the functions as 'rte_bit_relaxed_get_bit32'? If the example is ok, I will modify as this in v10.

Yes, thank you.

author
#125 lore raw

PATCH v9 2/6 test/bitops: add bit operation test case

In reply to Joyce Kong

Add test cases for setting bit, clearing bit, testing and setting bit, testing and clearing bit operation.

---
 MAINTAINERS               |   1 +
 app/test/Makefile         |   1 +
 app/test/autotest_data.py |   6 ++
 app/test/meson.build      |   2 +
 app/test/test_bitops.c    | 137 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 147 insertions(+)
 create mode 100644 app/test/test_bitops.c
MAINTAINERS +1 -0
index c5c255994..361d27d17 100644
@@ -244,6 +244,7 @@ F: app/test/test_bitmap.c
 Bitops
 M: Joyce Kong <[email protected]>
 F: lib/librte_eal/include/rte_bitops.h
+F: app/test/test_bitops.c
 
 MCSlock - EXPERIMENTAL
 M: Phil Yang <[email protected]>
app/test/Makefile +1 -0
index be53d33c3..a51a8181f 100644
@@ -70,6 +70,7 @@ SRCS-y += test_ticketlock.c
 SRCS-y += test_memory.c
 SRCS-y += test_memzone.c
 SRCS-y += test_bitmap.c
+SRCS-y += test_bitops.c
 SRCS-y += test_reciprocal_division.c
 SRCS-y += test_reciprocal_division_perf.c
 SRCS-y += test_fbarray.c
app/test/autotest_data.py +6 -0
index 7b1d01389..fc3fcc159 100644
@@ -404,6 +404,12 @@
         "Func":    default_autotest,
         "Report":  None,
     },
+    {
+        "Name":    "Bitops test",
+        "Command": "bitops_test",
+        "Func":    default_autotest,
+        "Report":  None,
+    },
     {
         "Name":    "Hash multiwriter autotest",
         "Command": "hash_multiwriter_autotest",
app/test/meson.build +2 -0
index 04b59cffa..d1d5cc122 100644
@@ -12,6 +12,7 @@ test_sources = files('commands.c',
 	'test_alarm.c',
 	'test_atomic.c',
 	'test_barrier.c',
+	'test_bitops.c',
 	'test_bpf.c',
 	'test_byteorder.c',
 	'test_cmdline.c',
@@ -160,6 +161,7 @@ fast_tests = [
         ['acl_autotest', true],
         ['alarm_autotest', false],
         ['atomic_autotest', false],
+        ['bitops_autotest', true],
         ['byteorder_autotest', true],
         ['cmdline_autotest', true],
         ['common_autotest', true],
app/test/test_bitops.c new file +137 -0

137 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#126 lore raw

PATCH v9 3/6 net/axgbe: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/axgbe/axgbe_common.h | 29 +----------------------------
 drivers/net/axgbe/axgbe_ethdev.c | 14 +++++++-------
 drivers/net/axgbe/axgbe_ethdev.h |  2 +-
 drivers/net/axgbe/axgbe_mdio.c   | 15 ++++++++-------
 4 files changed, 17 insertions(+), 43 deletions(-)
drivers/net/axgbe/axgbe_common.h +1 -28
index f48117180..d53b48ce6 100644
@@ -21,6 +21,7 @@
 #include <inttypes.h>
 #include <pthread.h>
 
+#include <rte_bitops.h>
 #include <rte_byteorder.h>
 #include <rte_memory.h>
 #include <rte_malloc.h>
@@ -1700,34 +1701,6 @@ do {									\
 #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);
drivers/net/axgbe/axgbe_ethdev.c +7 -7
index 867058845..b83c14144 100644
@@ -327,8 +327,8 @@ axgbe_dev_start(struct rte_eth_dev *dev)
 	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_clear_bit32_relaxed(AXGBE_STOPPED, &pdata->dev_state);
+	rte_clear_bit32_relaxed(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;
@@ -352,17 +352,17 @@ axgbe_dev_stop(struct rte_eth_dev *dev)
 
 	rte_intr_disable(&pdata->pci_dev->intr_handle);
 
-	if (axgbe_test_bit(AXGBE_STOPPED, &pdata->dev_state))
+	if (rte_get_bit32_relaxed(AXGBE_STOPPED, &pdata->dev_state))
 		return;
 
-	axgbe_set_bit(AXGBE_STOPPED, &pdata->dev_state);
+	rte_set_bit32_relaxed(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_set_bit32_relaxed(AXGBE_DOWN, &pdata->dev_state);
 }
 
 /* Clear all resources like TX/RX queues. */
@@ -1470,8 +1470,8 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
 
 	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_set_bit32_relaxed(AXGBE_DOWN, &pdata->dev_state);
+	rte_set_bit32_relaxed(AXGBE_STOPPED, &pdata->dev_state);
 	pdata->eth_dev = eth_dev;
 
 	pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
drivers/net/axgbe/axgbe_ethdev.h +1 -1
index f10ec4a40..1898e9eb9 100644
@@ -522,7 +522,7 @@ struct axgbe_port {
 	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;
drivers/net/axgbe/axgbe_mdio.c +8 -7
index 0f226c3f2..d1196d308 100644
@@ -916,7 +916,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata)
 {
 	int ret;
 
-	axgbe_set_bit(AXGBE_LINK_INIT, &pdata->dev_state);
+	rte_set_bit32_relaxed(AXGBE_LINK_INIT, &pdata->dev_state);
 	pdata->link_check = rte_get_timer_cycles();
 
 	ret = pdata->phy_if.phy_impl.an_config(pdata);
@@ -981,9 +981,9 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata)
 
 	ret = __axgbe_phy_config_aneg(pdata);
 	if (ret)
-		axgbe_set_bit(AXGBE_LINK_ERR, &pdata->dev_state);
+		rte_set_bit32_relaxed(AXGBE_LINK_ERR, &pdata->dev_state);
 	else
-		axgbe_clear_bit(AXGBE_LINK_ERR, &pdata->dev_state);
+		rte_clear_bit32_relaxed(AXGBE_LINK_ERR, &pdata->dev_state);
 
 	pthread_mutex_unlock(&pdata->an_mutex);
 
@@ -1072,7 +1072,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)
 	unsigned int reg = 0;
 	unsigned long autoneg_start_time;
 
-	if (axgbe_test_bit(AXGBE_LINK_ERR, &pdata->dev_state)) {
+	if (rte_get_bit32_relaxed(AXGBE_LINK_ERR, &pdata->dev_state)) {
 		pdata->phy.link = 0;
 		goto adjust_link;
 	}
@@ -1116,10 +1116,11 @@ static void axgbe_phy_status(struct axgbe_port *pdata)
 			}
 		}
 		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_get_bit32_relaxed(AXGBE_LINK_INIT, &pdata->dev_state))
+			rte_clear_bit32_relaxed(AXGBE_LINK_INIT,
+						&pdata->dev_state);
 	} else {
-		if (axgbe_test_bit(AXGBE_LINK_INIT, &pdata->dev_state)) {
+		if (rte_get_bit32_relaxed(AXGBE_LINK_INIT, &pdata->dev_state)) {
 			axgbe_check_link_timeout(pdata);
 
 			if (link_aneg)
Signature · 1 line
2.17.1
author
#127 lore raw

PATCH v9 4/6 net/bnx2x: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/bnx2x/bnx2x.c    | 271 +++++++++++++++++------------------
 drivers/net/bnx2x/bnx2x.h    |  10 +-
 drivers/net/bnx2x/ecore_sp.c |  68 ++++-----
 drivers/net/bnx2x/ecore_sp.h | 106 +++++++-------
 4 files changed, 221 insertions(+), 234 deletions(-)
drivers/net/bnx2x/bnx2x.c +130 -141
index 0b4030e2b..eaed6274a 100644
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <zlib.h>
+#include <rte_bitops.h>
 #include <rte_string_fns.h>
 
 #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"
@@ -129,32 +130,6 @@ static void bnx2x_ack_sb(struct bnx2x_softc *sc, uint8_t igu_sb_id,
 			 uint8_t storm, uint16_t index, uint8_t op,
 			 uint8_t update);
 
-int bnx2x_test_bit(int nr, volatile unsigned long *addr)
-{
-	int res;
-
-	mb();
-	res = ((*addr) & (1UL << nr)) != 0;
-	mb();
-	return res;
-}
-
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-void bnx2x_clear_bit(int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-int bnx2x_test_and_clear_bit(int nr, volatile unsigned long *addr)
-{
-	unsigned long mask = (1UL << nr);
-	return __sync_fetch_and_and(addr, ~mask) & mask;
-}
-
 int bnx2x_cmpxchg(volatile int *addr, int old, int new)
 {
 	return __sync_val_compare_and_swap(addr, old, new);
@@ -1434,16 +1409,16 @@ static int
 bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 		 int mac_type, uint8_t wait_for_comp)
 {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
 	int rc;
 
 	/* wait for completion of requested */
 	if (wait_for_comp) {
-		bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+		rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 	}
 
 	/* Set the mac type of addresses we want to clear */
-	bnx2x_set_bit(mac_type, &vlan_mac_flags);
+	rte_set_bit32_relaxed(mac_type, &vlan_mac_flags);
 
 	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
 	if (rc < 0)
@@ -1454,8 +1429,7 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 
 static int
 bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
-			unsigned long *rx_accept_flags,
-			unsigned long *tx_accept_flags)
+			uint32_t *rx_accept_flags, uint32_t *tx_accept_flags)
 {
 	/* Clear the flags first */
 	*rx_accept_flags = 0;
@@ -1470,26 +1444,28 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 		break;
 
 	case BNX2X_RX_MODE_NORMAL:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		break;
 
 	case BNX2X_RX_MODE_ALLMULTI:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		break;
 
@@ -1500,19 +1476,23 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 		 * should receive matched and unmatched (in resolution of port)
 		 * unicast packets.
 		 */
-		bnx2x_set_bit(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		if (IS_MF_SI(sc)) {
-			bnx2x_set_bit(ECORE_ACCEPT_ALL_UNICAST, tx_accept_flags);
+			rte_set_bit32_relaxed(ECORE_ACCEPT_ALL_UNICAST,
+					tx_accept_flags);
 		} else {
-			bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+			rte_set_bit32_relaxed(ECORE_ACCEPT_UNICAST,
+					      tx_accept_flags);
 		}
 
 		break;
@@ -1524,8 +1504,8 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 
 	/* Set ACCEPT_ANY_VLAN as we do not enable filtering by VLAN */
 	if (rx_mode != BNX2X_RX_MODE_NONE) {
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
+		rte_set_bit32_relaxed(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
 	}
 
 	return 0;
@@ -1554,7 +1534,7 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
 	ramrod_param.rdata = BNX2X_SP(sc, rx_mode_rdata);
 	ramrod_param.rdata_mapping =
 	    (rte_iova_t)BNX2X_SP_MAPPING(sc, rx_mode_rdata),
-	    bnx2x_set_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	    rte_set_bit32_relaxed(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
 	ramrod_param.ramrod_flags = ramrod_flags;
 	ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1573,8 +1553,8 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
 
 int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
 {
-	unsigned long rx_mode_flags = 0, ramrod_flags = 0;
-	unsigned long rx_accept_flags = 0, tx_accept_flags = 0;
+	uint32_t rx_mode_flags = 0, ramrod_flags = 0;
+	uint32_t rx_accept_flags = 0, tx_accept_flags = 0;
 	int rc;
 
 	rc = bnx2x_fill_accept_flags(sc, sc->rx_mode, &rx_accept_flags,
@@ -1583,9 +1563,9 @@ int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
 		return rc;
 	}
 
-	bnx2x_set_bit(RAMROD_RX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_TX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_RX, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_TX, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 
 	return bnx2x_set_q_rx_mode(sc, sc->fp[0].cl_id, rx_mode_flags,
 				 rx_accept_flags, tx_accept_flags,
@@ -1710,7 +1690,8 @@ static int bnx2x_func_wait_started(struct bnx2x_softc *sc)
 			    "Forcing STARTED-->TX_STOPPED-->STARTED");
 
 		func_params.f_obj = &sc->func_obj;
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
 
 		/* STARTED-->TX_STOPPED */
 		func_params.cmd = ECORE_F_CMD_TX_STOP;
@@ -1734,7 +1715,7 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
 
 	q_params.q_obj = &sc->sp_objs[fp->index].q_obj;
 	/* We want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
 	/* Stop the primary connection: */
 
@@ -1763,26 +1744,25 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
 }
 
 /* wait for the outstanding SP commands */
-static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, unsigned long mask)
+static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, uint32_t mask)
 {
-	unsigned long tmp;
+	uint32_t tmp;
 	int tout = 5000;	/* wait for 5 secs tops */
 
 	while (tout--) {
 		mb();
-		if (!(atomic_load_acq_long(&sc->sp_state) & mask)) {
+		if (!(atomic_load_acq_int(&sc->sp_state) & mask))
 			return TRUE;
-		}
 
 		DELAY(1000);
 	}
 
 	mb();
 
-	tmp = atomic_load_acq_long(&sc->sp_state);
+	tmp = atomic_load_acq_int(&sc->sp_state);
 	if (tmp & mask) {
 		PMD_DRV_LOG(INFO, sc, "Filtering completion timed out: "
-			    "sp_state 0x%lx, mask 0x%lx", tmp, mask);
+			    "sp_state 0x%x, mask 0x%x", tmp, mask);
 		return FALSE;
 	}
 
@@ -1795,7 +1775,7 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
 	int rc;
 
 	/* prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_STOP;
 
@@ -1809,7 +1789,8 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
 	if (rc) {
 		PMD_DRV_LOG(NOTICE, sc, "FUNC_STOP ramrod failed. "
 			    "Running a dry transaction");
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
 		return ecore_func_state_change(sc, &func_params);
 	}
 
@@ -1821,7 +1802,7 @@ static int bnx2x_reset_hw(struct bnx2x_softc *sc, uint32_t load_code)
 	struct ecore_func_state_params func_params = { NULL };
 
 	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_HW_RESET;
@@ -1878,11 +1859,11 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
 	 * a race between the completion code and this code.
 	 */
 
-	if (bnx2x_test_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state)) {
-		bnx2x_set_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state);
-	} else {
+	if (rte_get_bit32_relaxed(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state))
+		rte_set_bit32_relaxed(ECORE_FILTER_RX_MODE_SCHED,
+				      &sc->sp_state);
+	else
 		bnx2x_set_storm_rx_mode(sc);
-	}
 
 	/* Clean up multicast configuration */
 	rparam.mcast_obj = &sc->mcast_obj;
@@ -1922,9 +1903,8 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
 	 * If SP settings didn't get completed so far - something
 	 * very wrong has happen.
 	 */
-	if (!bnx2x_wait_sp_comp(sc, ~0x0UL)) {
+	if (!bnx2x_wait_sp_comp(sc, ~0x0U))
 		PMD_DRV_LOG(NOTICE, sc, "Common slow path ramrods got stuck!");
-	}
 
 unload_error:
 
@@ -1964,7 +1944,7 @@ static void bnx2x_disable_close_the_gate(struct bnx2x_softc *sc)
  */
 static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
 	struct ecore_mcast_ramrod_params rparam = { NULL };
 	struct ecore_vlan_mac_obj *mac_obj = &sc->sp_objs->mac_obj;
 	int rc;
@@ -1972,12 +1952,12 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 	/* Cleanup MACs' object first... */
 
 	/* Wait for completion of requested */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 	/* Perform a dry cleanup */
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
 
 	/* Clean ETH primary MAC */
-	bnx2x_set_bit(ECORE_ETH_MAC, &vlan_mac_flags);
+	rte_set_bit32_relaxed(ECORE_ETH_MAC, &vlan_mac_flags);
 	rc = mac_obj->delete_all(sc, &sc->sp_objs->mac_obj, &vlan_mac_flags,
 				 &ramrod_flags);
 	if (rc != 0) {
@@ -1986,7 +1966,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 
 	/* Cleanup UC list */
 	vlan_mac_flags = 0;
-	bnx2x_set_bit(ECORE_UC_LIST_MAC, &vlan_mac_flags);
+	rte_set_bit32_relaxed(ECORE_UC_LIST_MAC, &vlan_mac_flags);
 	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
 	if (rc != 0) {
 		PMD_DRV_LOG(NOTICE, sc,
@@ -1996,7 +1976,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 	/* Now clean mcast object... */
 
 	rparam.mcast_obj = &sc->mcast_obj;
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
 
 	/* Add a DEL command... */
 	rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_DEL);
@@ -4294,13 +4274,13 @@ static void bnx2x_handle_mcast_eqe(struct bnx2x_softc *sc)
 static void
 bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *elem)
 {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
 	int rc = 0;
 	uint32_t cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK;
 	struct ecore_vlan_mac_obj *vlan_mac_obj;
 
 	/* always push next commands out, don't wait here */
-	bnx2x_set_bit(RAMROD_CONT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_CONT, &ramrod_flags);
 
 	switch (le32toh(elem->message.data.eth_event.echo) >> BNX2X_SWCID_SHIFT) {
 	case ECORE_FILTER_MAC_PENDING:
@@ -4331,12 +4311,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *e
 
 static void bnx2x_handle_rx_mode_eqe(struct bnx2x_softc *sc)
 {
-	bnx2x_clear_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	rte_clear_bit32_relaxed(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
 	/* send rx_mode command again if was requested */
-	if (bnx2x_test_and_clear_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state)) {
+	if (rte_test_and_clear_bit32_relaxed(ECORE_FILTER_RX_MODE_SCHED,
+						&sc->sp_state))
 		bnx2x_set_storm_rx_mode(sc);
-	}
 }
 
 static void bnx2x_update_eq_prod(struct bnx2x_softc *sc, uint16_t prod)
@@ -4705,7 +4685,7 @@ static int bnx2x_init_hw(struct bnx2x_softc *sc, uint32_t load_code)
 	PMD_INIT_FUNC_TRACE(sc);
 
 	/* prepare the parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_HW_INIT;
@@ -4953,7 +4933,7 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
 {
 	struct bnx2x_fastpath *fp = &sc->fp[idx];
 	uint32_t cids[ECORE_MULTI_TX_COS] = { 0 };
-	unsigned long q_type = 0;
+	uint32_t q_type = 0;
 	int cos;
 
 	fp->sc = sc;
@@ -5000,8 +4980,8 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
 	bnx2x_update_fp_sb_idx(fp);
 
 	/* Configure Queue State object */
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_RX, &q_type);
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_TX, &q_type);
+	rte_set_bit32_relaxed(ECORE_Q_TYPE_HAS_RX, &q_type);
+	rte_set_bit32_relaxed(ECORE_Q_TYPE_HAS_TX, &q_type);
 
 	ecore_init_queue_obj(sc,
 			     &sc->sp_objs[idx].q_obj,
@@ -5815,7 +5795,7 @@ static int bnx2x_func_start(struct bnx2x_softc *sc)
 	    &func_params.params.start;
 
 	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_START;
@@ -6391,11 +6371,11 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
 	uint8_t cos;
 	int cxt_index, cxt_offset;
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->tx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC, &init_params->rx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC, &init_params->tx.flags);
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
 
 	/* HC rate */
 	init_params->rx.hc_rate =
@@ -6426,10 +6406,10 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
 static unsigned long
 bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
 	/* PF driver will always initialize the Queue to an ACTIVE state */
-	bnx2x_set_bit(ECORE_Q_FLG_ACTIVE, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_ACTIVE, &flags);
 
 	/*
 	 * tx only connections collect statistics (on the same index as the
@@ -6437,9 +6417,9 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 	 * connection is initialized.
 	 */
 
-	bnx2x_set_bit(ECORE_Q_FLG_STATS, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_STATS, &flags);
 	if (zero_stats) {
-		bnx2x_set_bit(ECORE_Q_FLG_ZERO_STATS, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_ZERO_STATS, &flags);
 	}
 
 	/*
@@ -6447,28 +6427,28 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 	 * CoS-ness doesn't survive the loopback
 	 */
 	if (sc->flags & BNX2X_TX_SWITCHING) {
-		bnx2x_set_bit(ECORE_Q_FLG_TX_SWITCH, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_TX_SWITCH, &flags);
 	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
 
 	return flags;
 }
 
 static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)
 {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
 	if (IS_MF_SD(sc)) {
-		bnx2x_set_bit(ECORE_Q_FLG_OV, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_OV, &flags);
 	}
 
 	if (leading) {
-		bnx2x_set_bit(ECORE_Q_FLG_LEADING_RSS, &flags);
-		bnx2x_set_bit(ECORE_Q_FLG_MCAST, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_LEADING_RSS, &flags);
+		rte_set_bit32_relaxed(ECORE_Q_FLG_MCAST, &flags);
 	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_VLAN, &flags);
+	rte_set_bit32_relaxed(ECORE_Q_FLG_VLAN, &flags);
 
 	/* merge with common flags */
 	return flags | bnx2x_get_common_flags(sc, TRUE);
@@ -6589,7 +6569,7 @@ bnx2x_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, uint8_t lea
 	q_params.q_obj = &BNX2X_SP_OBJ(sc, fp).q_obj;
 
 	/* we want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
 	/* prepare the INIT parameters */
 	bnx2x_pf_q_prep_init(sc, fp, &q_params.params.init);
@@ -6657,20 +6637,20 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
 
 	params.rss_obj = rss_obj;
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &params.ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &params.ramrod_flags);
 
-	bnx2x_set_bit(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
 
 	/* RSS configuration */
-	bnx2x_set_bit(ECORE_RSS_IPV4, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV4_TCP, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6_TCP, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV4, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV4_TCP, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV6, &params.rss_flags);
+	rte_set_bit32_relaxed(ECORE_RSS_IPV6_TCP, &params.rss_flags);
 	if (rss_obj->udp_rss_v4) {
-		bnx2x_set_bit(ECORE_RSS_IPV4_UDP, &params.rss_flags);
+		rte_set_bit32_relaxed(ECORE_RSS_IPV4_UDP, &params.rss_flags);
 	}
 	if (rss_obj->udp_rss_v6) {
-		bnx2x_set_bit(ECORE_RSS_IPV6_UDP, &params.rss_flags);
+		rte_set_bit32_relaxed(ECORE_RSS_IPV6_UDP, &params.rss_flags);
 	}
 
 	/* Hash bits */
@@ -6685,7 +6665,7 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
 			params.rss_key[i] = (uint32_t) rte_rand();
 		}
 
-		bnx2x_set_bit(ECORE_RSS_SET_SRCH, &params.rss_flags);
+		rte_set_bit32_relaxed(ECORE_RSS_SET_SRCH, &params.rss_flags);
 	}
 
 	if (IS_PF(sc))
@@ -6730,7 +6710,7 @@ static int bnx2x_init_rss_pf(struct bnx2x_softc *sc)
 static int
 bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 		struct ecore_vlan_mac_obj *obj, uint8_t set, int mac_type,
-		unsigned long *ramrod_flags)
+		uint32_t *ramrod_flags)
 {
 	struct ecore_vlan_mac_ramrod_params ramrod_param;
 	int rc;
@@ -6742,11 +6722,12 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 	ramrod_param.ramrod_flags = *ramrod_flags;
 
 	/* fill a user request section if needed */
-	if (!bnx2x_test_bit(RAMROD_CONT, ramrod_flags)) {
+	if (!rte_get_bit32_relaxed(RAMROD_CONT, ramrod_flags)) {
 		rte_memcpy(ramrod_param.user_req.u.mac.mac, mac,
 				 ETH_ALEN);
 
-		bnx2x_set_bit(mac_type, &ramrod_param.user_req.vlan_mac_flags);
+		rte_set_bit32_relaxed(mac_type,
+				      &ramrod_param.user_req.vlan_mac_flags);
 
 /* Set the command: ADD or DEL */
 		ramrod_param.user_req.cmd = (set) ? ECORE_VLAN_MAC_ADD :
@@ -6769,11 +6750,11 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 
 static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)
 {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
 
 	PMD_DRV_LOG(DEBUG, sc, "Adding Ethernet MAC");
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_set_bit32_relaxed(RAMROD_COMP_WAIT, &ramrod_flags);
 
 	/* Eth MAC is set on RSS leading client (fp[0]) */
 	return bnx2x_set_mac_one(sc, sc->link_params.mac_addr,
@@ -6905,24 +6886,26 @@ bnx2x_fill_report_data(struct bnx2x_softc *sc, struct bnx2x_link_report_data *da
 
 	/* Link is down */
 	if (!sc->link_vars.link_up || (sc->flags & BNX2X_MF_FUNC_DIS)) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			    &data->link_report_flags);
 	}
 
 	/* Full DUPLEX */
 	if (sc->link_vars.duplex == DUPLEX_FULL) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_FULL_DUPLEX,
 			    &data->link_report_flags);
 	}
 
 	/* Rx Flow Control is ON */
 	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_RX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_RX_FC_ON, &data->link_report_flags);
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_RX_FC_ON,
+				&data->link_report_flags);
 	}
 
 	/* Tx Flow Control is ON */
 	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_TX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_TX_FC_ON, &data->link_report_flags);
+		rte_set_bit32_relaxed(BNX2X_LINK_REPORT_TX_FC_ON,
+				&data->link_report_flags);
 	}
 }
 
@@ -6941,14 +6924,14 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 
 	/* Don't report link down or exactly the same link status twice */
 	if (!memcmp(&cur_data, &sc->last_reported_link, sizeof(cur_data)) ||
-	    (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	    (rte_get_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			  &sc->last_reported_link.link_report_flags) &&
-	     bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	     rte_get_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			  &cur_data.link_report_flags))) {
 		return;
 	}
 
-	ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %lx, last_reported_link = %lx",
+	ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %x, last_reported_link = %x",
 		       cur_data.link_report_flags,
 		       sc->last_reported_link.link_report_flags);
 
@@ -6958,15 +6941,16 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 	/* report new link params and remember the state for the next time */
 	rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
 
-	if (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	if (rte_get_bit32_relaxed(BNX2X_LINK_REPORT_LINK_DOWN,
 			 &cur_data.link_report_flags)) {
 		ELINK_DEBUG_P0(sc, "NIC Link is Down");
 	} else {
 		__rte_unused const char *duplex;
 		__rte_unused const char *flow;
 
-		if (bnx2x_test_and_clear_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
-					   &cur_data.link_report_flags)) {
+		if (rte_test_and_clear_bit32_relaxed
+					(BNX2X_LINK_REPORT_FULL_DUPLEX,
+					 &cur_data.link_report_flags)) {
 			duplex = "full";
 				ELINK_DEBUG_P0(sc, "link set to full duplex");
 		} else {
@@ -6980,20 +6964,25 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
  * enabled.
  */
 		if (cur_data.link_report_flags) {
-			if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			if (rte_get_bit32_relaxed
+					(BNX2X_LINK_REPORT_RX_FC_ON,
 					 &cur_data.link_report_flags) &&
-			    bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			    rte_get_bit32_relaxed(BNX2X_LINK_REPORT_TX_FC_ON,
 					 &cur_data.link_report_flags)) {
 				flow = "ON - receive & transmit";
-			} else if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
-						&cur_data.link_report_flags) &&
-				   !bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			} else if (rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_RX_FC_ON,
+						 &cur_data.link_report_flags) &&
+				   !rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_TX_FC_ON,
 						 &cur_data.link_report_flags)) {
 				flow = "ON - receive";
-			} else if (!bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			} else if (!rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_RX_FC_ON,
 						 &cur_data.link_report_flags) &&
-				   bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
-						&cur_data.link_report_flags)) {
+				   rte_get_bit32_relaxed
+						(BNX2X_LINK_REPORT_TX_FC_ON,
+						 &cur_data.link_report_flags)) {
 				flow = "ON - transmit";
 			} else {
 				flow = "none";	/* possible? */
@@ -7413,7 +7402,7 @@ int bnx2x_nic_load(struct bnx2x_softc *sc)
 	bnx2x_set_rx_mode(sc);
 
 	/* wait for all pending SP commands to complete */
-	if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0UL)) {
+	if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0U)) {
 		PMD_DRV_LOG(NOTICE, sc, "Timeout waiting for all SPs to complete!");
 		bnx2x_periodic_stop(sc);
 		bnx2x_nic_unload(sc, UNLOAD_CLOSE, FALSE);
drivers/net/bnx2x/bnx2x.h +3 -7
index 1dbc98197..63be72a5b 100644
@@ -1000,8 +1000,8 @@ struct bnx2x_sp_objs {
  * link parameters twice.
  */
 struct bnx2x_link_report_data {
-	uint16_t      line_speed;        /* Effective line speed */
-	unsigned long link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
+	uint16_t line_speed;        /* Effective line speed */
+	uint32_t link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
 };
 
 enum {
@@ -1232,7 +1232,7 @@ struct bnx2x_softc {
 	/* slow path */
 	struct bnx2x_dma      sp_dma;
 	struct bnx2x_slowpath *sp;
-	unsigned long       sp_state;
+	uint32_t	    sp_state;
 
 	/* slow path queue */
 	struct bnx2x_dma spq_dma;
@@ -1812,10 +1812,6 @@ static const uint32_t dmae_reg_go_c[] = {
 #define PCI_PM_D0    1
 #define PCI_PM_D3hot 2
 
-int  bnx2x_test_bit(int nr, volatile unsigned long * addr);
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long * addr);
-void bnx2x_clear_bit(int nr, volatile unsigned long * addr);
-int  bnx2x_test_and_clear_bit(int nr, volatile unsigned long * addr);
 int  bnx2x_cmpxchg(volatile int *addr, int old, int new);
 
 int bnx2x_dma_alloc(struct bnx2x_softc *sc, size_t size,
drivers/net/bnx2x/ecore_sp.c +34 -34

241 lines not on this page · raw message

drivers/net/bnx2x/ecore_sp.h +54 -52

310 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#128 lore raw

PATCH v9 5/6 net/qede: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/qede/base/bcm_osal.c          | 22 +------------
 drivers/net/qede/base/bcm_osal.h          | 14 ++++-----
 drivers/net/qede/base/ecore.h             |  6 ++--
 drivers/net/qede/base/ecore_cxt.c         |  6 ++--
 drivers/net/qede/base/ecore_dcbx.c        |  8 ++---
 drivers/net/qede/base/ecore_dev.c         | 38 +++++++++++------------
 drivers/net/qede/base/ecore_dev_api.h     |  2 +-
 drivers/net/qede/base/ecore_l2.c          |  6 ++--
 drivers/net/qede/base/ecore_mcp.c         |  4 +--
 drivers/net/qede/base/ecore_sp_commands.c | 12 +++----
 drivers/net/qede/base/ecore_spq.c         |  2 +-
 drivers/net/qede/base/ecore_spq.h         | 10 +++---
 drivers/net/qede/qede_main.c              |  4 +--
 13 files changed, 56 insertions(+), 78 deletions(-)
drivers/net/qede/base/bcm_osal.c +1 -21
index 48d016e24..54e5e4f98 100644
@@ -46,26 +46,6 @@ u32 qede_osal_log2(u32 val)
 	return log;
 }
 
-inline void qede_set_bit(u32 nr, unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-inline void qede_clr_bit(u32 nr, unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-inline bool qede_test_bit(u32 nr, unsigned long *addr)
-{
-	bool res;
-
-	rte_mb();
-	res = ((*addr) & (1UL << nr)) != 0;
-	rte_mb();
-	return res;
-}
-
 static inline u32 qede_ffb(unsigned long word)
 {
 	unsigned long first_bit;
@@ -95,7 +75,7 @@ static inline u32 qede_ffz(unsigned long word)
 	return first_zero ? (first_zero - 1) : OSAL_BITS_PER_UL;
 }
 
-inline u32 qede_find_first_zero_bit(unsigned long *addr, u32 limit)
+inline u32 qede_find_first_zero_bit(u32 *addr, u32 limit)
 {
 	u32 i;
 	u32 nwords = 0;
drivers/net/qede/base/bcm_osal.h +6 -8
index 8b2faec5b..643884aca 100644
@@ -8,6 +8,7 @@
 #define __BCM_OSAL_H
 
 #include <stdbool.h>
+#include <rte_bitops.h>
 #include <rte_byteorder.h>
 #include <rte_spinlock.h>
 #include <rte_malloc.h>
@@ -308,23 +309,20 @@ typedef struct osal_list_t {
 #define OSAL_BITS_PER_UL_MASK		(OSAL_BITS_PER_UL - 1)
 
 /* Bitops */
-void qede_set_bit(u32, unsigned long *);
 #define OSAL_SET_BIT(bit, bitmap) \
-	qede_set_bit(bit, bitmap)
+	rte_set_bit32_relaxed(bit, bitmap)
 
-void qede_clr_bit(u32, unsigned long *);
 #define OSAL_CLEAR_BIT(bit, bitmap) \
-	qede_clr_bit(bit, bitmap)
+	rte_clear_bit32_relaxed(bit, bitmap)
 
-bool qede_test_bit(u32, unsigned long *);
-#define OSAL_TEST_BIT(bit, bitmap) \
-	qede_test_bit(bit, bitmap)
+#define OSAL_GET_BIT(bit, bitmap) \
+	rte_get_bit32_relaxed(bit, bitmap)
 
 u32 qede_find_first_bit(unsigned long *, u32);
 #define OSAL_FIND_FIRST_BIT(bitmap, length) \
 	qede_find_first_bit(bitmap, length)
 
-u32 qede_find_first_zero_bit(unsigned long *, u32);
+u32 qede_find_first_zero_bit(u32 *bitmap, u32 length);
 #define OSAL_FIND_FIRST_ZERO_BIT(bitmap, length) \
 	qede_find_first_zero_bit(bitmap, length)
 
drivers/net/qede/base/ecore.h +3 -3
index b2077bc46..498bb6f09 100644
@@ -422,8 +422,8 @@ struct ecore_hw_info {
 	u8 max_chains_per_vf;
 
 	u32 port_mode;
-	u32	hw_mode;
-	unsigned long device_capabilities;
+	u32 hw_mode;
+	u32 device_capabilities;
 
 	/* Default DCBX mode */
 	u8 dcbx_mode;
@@ -807,7 +807,7 @@ struct ecore_dev {
 
 	u8				path_id;
 
-	unsigned long			mf_bits;
+	u32				mf_bits;
 	enum ecore_mf_mode		mf_mode;
 #define IS_MF_DEFAULT(_p_hwfn)	\
 	(((_p_hwfn)->p_dev)->mf_mode == ECORE_MF_DEFAULT)
drivers/net/qede/base/ecore_cxt.c +3 -3
index 773b75ecd..dda47ea67 100644
@@ -154,7 +154,7 @@ struct ecore_ilt_client_cfg {
 struct ecore_cid_acquired_map {
 	u32 start_cid;
 	u32 max_count;
-	unsigned long *cid_map;
+	u32 *cid_map;
 };
 
 struct ecore_src_t2 {
@@ -1991,7 +1991,7 @@ static bool ecore_cxt_test_cid_acquired(struct ecore_hwfn *p_hwfn,
 	}
 
 	rel_cid = cid - (*pp_map)->start_cid;
-	if (!OSAL_TEST_BIT(rel_cid, (*pp_map)->cid_map)) {
+	if (!OSAL_GET_BIT(rel_cid, (*pp_map)->cid_map)) {
 		DP_NOTICE(p_hwfn, true,
 			  "CID %d [vifd %02x] not acquired", cid, vfid);
 		goto fail;
@@ -2102,7 +2102,7 @@ enum _ecore_status_t ecore_cxt_set_pf_params(struct ecore_hwfn *p_hwfn)
 
 		count = p_params->num_arfs_filters;
 
-		if (!OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS,
+		if (!OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS,
 				   &p_hwfn->p_dev->mf_bits))
 			p_hwfn->p_cxt_mngr->arfs_count = count;
 
drivers/net/qede/base/ecore_dcbx.c +4 -4
index ccd4383bb..31234f18c 100644
@@ -148,7 +148,7 @@ ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
 	p_data->arr[type].update = UPDATE_DCB_DSCP;
 
 	/* Do not add valn tag 0 when DCB is enabled and port is in UFP mode */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		p_data->arr[type].dont_add_vlan0 = true;
 
 	/* QM reconf data */
@@ -156,8 +156,8 @@ ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
 		p_hwfn->hw_info.offload_tc = tc;
 
 	/* Configure dcbx vlan priority in doorbell block for roce EDPM */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits) &&
-	    (type == DCBX_PROTOCOL_ROCE)) {
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits) &&
+	    type == DCBX_PROTOCOL_ROCE) {
 		ecore_wr(p_hwfn, p_ptt, DORQ_REG_TAG1_OVRD_MODE, 1);
 		ecore_wr(p_hwfn, p_ptt, DORQ_REG_PF_PCP, prio << 1);
 	}
@@ -293,7 +293,7 @@ ecore_dcbx_process_tlv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	}
 
 	/* If Eth TLV is not detected, use UFP TC as default TC */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC,
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC,
 			  &p_hwfn->p_dev->mf_bits) && !eth_tlv)
 		p_data->arr[DCBX_PROTOCOL_ETH].tc = p_hwfn->ufp_info.tc;
 
drivers/net/qede/base/ecore_dev.c +19 -19
index 86ecfb269..e18c2fa89 100644
@@ -805,7 +805,7 @@ static enum _ecore_status_t ecore_llh_hw_init_pf(struct ecore_hwfn *p_hwfn,
 		ecore_wr(p_hwfn, p_ptt, addr, p_hwfn->rel_pf_id);
 	}
 
-	if (OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
+	if (OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
 	    !ECORE_IS_FCOE_PERSONALITY(p_hwfn)) {
 		rc = ecore_llh_add_mac_filter(p_dev, 0,
 					      p_hwfn->hw_info.hw_mac_addr);
@@ -1044,7 +1044,7 @@ ecore_llh_add_filter(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	filter_details.enable = 1;
 	filter_details.value = ((u64)high << 32) | low;
 	filter_details.hdr_sel =
-		OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits) ?
+		OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits) ?
 		1 : /* inner/encapsulated header */
 		0;  /* outer/tunnel header */
 	filter_details.protocol_type = filter_prot_type;
@@ -1083,7 +1083,7 @@ enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return ECORE_AGAIN;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	OSAL_MEM_ZERO(&filter, sizeof(filter));
@@ -1220,7 +1220,7 @@ ecore_llh_add_protocol_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return ECORE_AGAIN;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_llh_protocol_filter_stringify(p_dev, type,
@@ -1287,7 +1287,7 @@ void ecore_llh_remove_mac_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	OSAL_MEM_ZERO(&filter, sizeof(filter));
@@ -1342,7 +1342,7 @@ void ecore_llh_remove_protocol_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_llh_protocol_filter_stringify(p_dev, type,
@@ -1396,8 +1396,8 @@ void ecore_llh_clear_ppfid_filters(struct ecore_dev *p_dev, u8 ppfid)
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
-	    !OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
+	    !OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_abs_ppfid(p_dev, ppfid, &abs_ppfid);
@@ -1423,8 +1423,8 @@ void ecore_llh_clear_all_filters(struct ecore_dev *p_dev)
 {
 	u8 ppfid;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
-	    !OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
+	    !OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		return;
 
 	for (ppfid = 0; ppfid < p_dev->p_llh_info->num_ppfid; ppfid++)
@@ -2674,7 +2674,7 @@ static enum _ecore_status_t ecore_calc_hw_mode(struct ecore_hwfn *p_hwfn)
 		return ECORE_INVAL;
 	}
 
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
 		hw_mode |= 1 << MODE_MF_SD;
 	else
 		hw_mode |= 1 << MODE_MF_SI;
@@ -3382,7 +3382,7 @@ static enum _ecore_status_t ecore_hw_init_port(struct ecore_hwfn *p_hwfn,
 		 * The ppfid should be set in the vector, except in BB which has
 		 * a bug in the LLH where the ppfid is actually engine based.
 		 */
-		if (OSAL_TEST_BIT(ECORE_MF_NEED_DEF_PF, &p_dev->mf_bits)) {
+		if (OSAL_GET_BIT(ECORE_MF_NEED_DEF_PF, &p_dev->mf_bits)) {
 			u8 pf_id = p_hwfn->rel_pf_id;
 
 			if (!ECORE_IS_BB(p_dev))
@@ -3715,11 +3715,11 @@ enum _ecore_status_t ecore_hw_init(struct ecore_dev *p_dev,
 		if (rc != ECORE_SUCCESS)
 			return rc;
 
-		if (IS_PF(p_dev) && (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING,
+		if (IS_PF(p_dev) && (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING,
 						   &p_dev->mf_bits) ||
-				     OSAL_TEST_BIT(ECORE_MF_8021AD_TAGGING,
+				     OSAL_GET_BIT(ECORE_MF_8021AD_TAGGING,
 						   &p_dev->mf_bits))) {
-			if (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING,
+			if (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING,
 					  &p_dev->mf_bits))
 				ether_type = ETHER_TYPE_VLAN;
 			else
@@ -4119,7 +4119,7 @@ enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev)
 		OSAL_MSLEEP(1);
 
 		if (IS_LEAD_HWFN(p_hwfn) &&
-		    OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
+		    OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
 		    !ECORE_IS_FCOE_PERSONALITY(p_hwfn))
 			ecore_llh_remove_mac_filter(p_dev, 0,
 						   p_hwfn->hw_info.hw_mac_addr);
@@ -5113,7 +5113,7 @@ ecore_hw_get_nvm_info(struct ecore_hwfn *p_hwfn,
 			p_hwfn->p_dev->mf_bits |= 1 << ECORE_MF_NEED_DEF_PF;
 		break;
 	}
-	DP_INFO(p_hwfn, "Multi function mode is 0x%lx\n",
+	DP_INFO(p_hwfn, "Multi function mode is 0x%x\n",
 		p_hwfn->p_dev->mf_bits);
 
 	if (ECORE_IS_CMT(p_hwfn->p_dev))
@@ -6218,7 +6218,7 @@ enum _ecore_status_t
 ecore_llh_set_function_as_default(struct ecore_hwfn *p_hwfn,
 				  struct ecore_ptt *p_ptt)
 {
-	if (OSAL_TEST_BIT(ECORE_MF_NEED_DEF_PF, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_NEED_DEF_PF, &p_hwfn->p_dev->mf_bits)) {
 		ecore_wr(p_hwfn, p_ptt,
 			 NIG_REG_LLH_TAGMAC_DEF_PF_VECTOR,
 			 1 << p_hwfn->abs_pf_id / 2);
@@ -6795,5 +6795,5 @@ void ecore_set_fw_mac_addr(__le16 *fw_msb,
 
 bool ecore_is_mf_fip_special(struct ecore_dev *p_dev)
 {
-	return !!OSAL_TEST_BIT(ECORE_MF_FIP_SPECIAL, &p_dev->mf_bits);
+	return !!OSAL_GET_BIT(ECORE_MF_FIP_SPECIAL, &p_dev->mf_bits);
 }
drivers/net/qede/base/ecore_dev_api.h +1 -1
index 5ea8427a0..9ddf502eb 100644
@@ -212,7 +212,7 @@ enum _ecore_status_t ecore_db_recovery_del(struct ecore_dev *p_dev,
 
 static OSAL_INLINE bool ecore_is_mf_ufp(struct ecore_hwfn *p_hwfn)
 {
-	return !!OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits);
+	return !!OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits);
 }
 
 #endif
drivers/net/qede/base/ecore_l2.c +3 -3
index b20d83762..af234dec8 100644
@@ -29,7 +29,7 @@
 
 struct ecore_l2_info {
 	u32 queues;
-	unsigned long **pp_qid_usage;
+	u32 **pp_qid_usage;
 
 	/* The lock is meant to synchronize access to the qid usage */
 	osal_mutex_t lock;
@@ -38,7 +38,7 @@ struct ecore_l2_info {
 enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn)
 {
 	struct ecore_l2_info *p_l2_info;
-	unsigned long **pp_qids;
+	u32 **pp_qids;
 	u32 i;
 
 	if (!ECORE_IS_L2_PERSONALITY(p_hwfn))
@@ -2116,7 +2116,7 @@ void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn,
 			       struct ecore_ptt *p_ptt,
 			       struct ecore_arfs_config_params *p_cfg_params)
 {
-	if (OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS, &p_hwfn->p_dev->mf_bits))
 		return;
 
 	if (p_cfg_params->mode != ECORE_FILTER_CONFIG_MODE_DISABLE) {
drivers/net/qede/base/ecore_mcp.c +2 -2
index 7518765a0..a7485967b 100644
@@ -1732,7 +1732,7 @@ static void ecore_mcp_update_stag(struct ecore_hwfn *p_hwfn,
 	p_hwfn->mcp_info->func_info.ovlan = (u16)shmem_info.ovlan_stag &
 						 FUNC_MF_CFG_OV_STAG_MASK;
 	p_hwfn->hw_info.ovlan = p_hwfn->mcp_info->func_info.ovlan;
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits)) {
 		if (p_hwfn->hw_info.ovlan != ECORE_MCP_VLAN_UNSET) {
 			ecore_wr(p_hwfn, p_ptt, NIG_REG_LLH_FUNC_TAG_VALUE,
 				 p_hwfn->hw_info.ovlan);
@@ -2026,7 +2026,7 @@ ecore_mcp_read_ufp_config(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
 	struct public_func shmem_info;
 	u32 port_cfg, val;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		return;
 
 	OSAL_MEMSET(&p_hwfn->ufp_info, 0, sizeof(p_hwfn->ufp_info));
drivers/net/qede/base/ecore_sp_commands.c +6 -6
index 9860a62b5..44ced135d 100644
@@ -335,16 +335,16 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	p_ramrod->dont_log_ramrods = 0;
 	p_ramrod->log_type_mask = OSAL_CPU_TO_LE16(0x8f);
 
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
 		p_ramrod->mf_mode = MF_OVLAN;
 	else
 		p_ramrod->mf_mode = MF_NPAR;
 
 	p_ramrod->outer_tag_config.outer_tag.tci =
 		OSAL_CPU_TO_LE16(p_hwfn->hw_info.ovlan);
-	if (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING, &p_hwfn->p_dev->mf_bits)) {
 		p_ramrod->outer_tag_config.outer_tag.tpid = ETH_P_8021Q;
-	} else if (OSAL_TEST_BIT(ECORE_MF_8021AD_TAGGING,
+	} else if (OSAL_GET_BIT(ECORE_MF_8021AD_TAGGING,
 		 &p_hwfn->p_dev->mf_bits)) {
 		p_ramrod->outer_tag_config.outer_tag.tpid = ETH_P_8021AD;
 		p_ramrod->outer_tag_config.enable_stag_pri_change = 1;
@@ -357,7 +357,7 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	/* enable_stag_pri_change should be set if port is in BD mode or,
 	 * UFP with Host Control mode.
 	 */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits)) {
 		if (p_hwfn->ufp_info.pri_type == ECORE_UFP_PRI_OS)
 			p_ramrod->outer_tag_config.enable_stag_pri_change = 1;
 		else
@@ -378,7 +378,7 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	ecore_tunn_set_pf_start_params(p_hwfn, p_tunn,
 				       &p_ramrod->tunnel_config);
 
-	if (OSAL_TEST_BIT(ECORE_MF_INTER_PF_SWITCH,
+	if (OSAL_GET_BIT(ECORE_MF_INTER_PF_SWITCH,
 			  &p_hwfn->p_dev->mf_bits))
 		p_ramrod->allow_npar_tx_switching = allow_npar_tx_switch;
 
@@ -638,7 +638,7 @@ enum _ecore_status_t ecore_sp_heartbeat_ramrod(struct ecore_hwfn *p_hwfn)
 	if (rc != ECORE_SUCCESS)
 		return rc;
 
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		p_ent->ramrod.pf_update.mf_vlan |=
 			OSAL_CPU_TO_LE16(((u16)p_hwfn->ufp_info.tc << 13));
 
drivers/net/qede/base/ecore_spq.c +1 -1
index 6c386821f..02f613688 100644
@@ -977,7 +977,7 @@ enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
 			 * for the first successive completed entries.
 			 */
 			SPQ_COMP_BMAP_SET_BIT(p_spq, echo);
-			while (SPQ_COMP_BMAP_TEST_BIT(p_spq,
+			while (SPQ_COMP_BMAP_GET_BIT(p_spq,
 						      p_spq->comp_bitmap_idx)) {
 				SPQ_COMP_BMAP_CLEAR_BIT(p_spq,
 							p_spq->comp_bitmap_idx);
drivers/net/qede/base/ecore_spq.h +5 -5
index 6142c399a..0958e5a0a 100644
@@ -121,17 +121,17 @@ struct ecore_spq {
 #define SPQ_RING_SIZE		\
 	(CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element))
 /* BITS_PER_LONG */
-#define SPQ_COMP_BMAP_SIZE	(SPQ_RING_SIZE / (sizeof(unsigned long) * 8))
-	unsigned long			p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
-	u8				comp_bitmap_idx;
+#define SPQ_COMP_BMAP_SIZE	(SPQ_RING_SIZE / (sizeof(u32) * 8))
+	u32			p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
+	u8			comp_bitmap_idx;
 #define SPQ_COMP_BMAP_SET_BIT(p_spq, idx)				\
 	(OSAL_SET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
 #define SPQ_COMP_BMAP_CLEAR_BIT(p_spq, idx)				\
 	(OSAL_CLEAR_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
-#define SPQ_COMP_BMAP_TEST_BIT(p_spq, idx)	\
-	(OSAL_TEST_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
+#define SPQ_COMP_BMAP_GET_BIT(p_spq, idx)	\
+	(OSAL_GET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
 	/* Statistics */
 	u32				unlimited_pending_count;
drivers/net/qede/qede_main.c +2 -2
index 8580cbcd7..bd63c0ac7 100644
@@ -382,8 +382,8 @@ qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info)
 
 	if (IS_PF(edev)) {
 		dev_info->b_inter_pf_switch =
-			OSAL_TEST_BIT(ECORE_MF_INTER_PF_SWITCH, &edev->mf_bits);
-		if (!OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS, &edev->mf_bits))
+			OSAL_GET_BIT(ECORE_MF_INTER_PF_SWITCH, &edev->mf_bits);
+		if (!OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS, &edev->mf_bits))
 			dev_info->b_arfs_capable = true;
 		dev_info->tx_switching = false;
 
Signature · 1 line
2.17.1
author
#129 lore raw

PATCH v9 6/6 net/hinic: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/hinic/Makefile            |  1 +
 drivers/net/hinic/base/hinic_compat.h | 33 +--------------------------
 drivers/net/hinic/hinic_pmd_ethdev.c  | 18 ++++++++-------
 drivers/net/hinic/hinic_pmd_ethdev.h  |  2 +-
 drivers/net/hinic/meson.build         |  2 ++
 5 files changed, 15 insertions(+), 41 deletions(-)
drivers/net/hinic/Makefile +1 -0
index 87fd843e4..f087baac5 100644
@@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 LIB = librte_pmd_hinic.a
 
 CFLAGS += -O3
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 ifeq ($(CONFIG_RTE_ARCH_ARM64),y)
drivers/net/hinic/base/hinic_compat.h +1 -32
index 921b83012..2d21b7b67 100644
@@ -10,6 +10,7 @@
 #include <unistd.h>
 #include <pthread.h>
 #include <rte_common.h>
+#include <rte_bitops.h>
 #include <rte_byteorder.h>
 #include <rte_memzone.h>
 #include <rte_memcpy.h>
@@ -116,38 +117,6 @@ extern int hinic_logtype;
 
 #define HINIC_PAGE_SIZE_DPDK	6
 
-static inline int hinic_test_bit(int nr, volatile unsigned long *addr)
-{
-	int res;
-
-	res = ((*addr) & (1UL << nr)) != 0;
-	return res;
-}
-
-static inline void hinic_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-static inline void hinic_clear_bit(int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-static inline int hinic_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 int hinic_test_and_set_bit(int nr, volatile unsigned long *addr)
-{
-	unsigned long mask = (1UL << nr);
-
-	return __sync_fetch_and_or(addr, mask) & mask;
-}
-
 void *dma_zalloc_coherent(void *dev, size_t size, dma_addr_t *dma_handle,
 			  unsigned int socket_id);
 
drivers/net/hinic/hinic_pmd_ethdev.c +10 -8
index 8493f6e42..e8c070759 100644
@@ -270,7 +270,7 @@ static void hinic_dev_interrupt_handler(void *param)
 	struct rte_eth_dev *dev = param;
 	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	if (!hinic_test_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status)) {
+	if (!rte_get_bit32_relaxed(HINIC_DEV_INTR_EN, &nic_dev->dev_status)) {
 		PMD_DRV_LOG(WARNING, "Device's interrupt is disabled, ignore interrupt event, dev_name: %s, port_id: %d",
 			    nic_dev->proc_dev_name, dev->data->port_id);
 		return;
@@ -1079,7 +1079,7 @@ static int hinic_dev_start(struct rte_eth_dev *dev)
 	if (dev->data->dev_conf.intr_conf.lsc != 0)
 		(void)hinic_link_update(dev, 0);
 
-	hinic_set_bit(HINIC_DEV_START, &nic_dev->dev_status);
+	rte_set_bit32_relaxed(HINIC_DEV_START, &nic_dev->dev_status);
 
 	return 0;
 
@@ -1204,7 +1204,8 @@ static void hinic_dev_stop(struct rte_eth_dev *dev)
 	name = dev->data->name;
 	port_id = dev->data->port_id;
 
-	if (!hinic_test_and_clear_bit(HINIC_DEV_START, &nic_dev->dev_status)) {
+	if (!rte_test_and_clear_bit32_relaxed(HINIC_DEV_START,
+					      &nic_dev->dev_status)) {
 		PMD_DRV_LOG(INFO, "Device %s already stopped", name);
 		return;
 	}
@@ -1249,7 +1250,7 @@ static void hinic_disable_interrupt(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	int ret, retries = 0;
 
-	hinic_clear_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
+	rte_clear_bit32_relaxed(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
 
 	/* disable msix interrupt in hardware */
 	hinic_set_msix_state(nic_dev->hwdev, 0, HINIC_MSIX_DISABLE);
@@ -2848,7 +2849,8 @@ static void hinic_dev_close(struct rte_eth_dev *dev)
 {
 	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	if (hinic_test_and_set_bit(HINIC_DEV_CLOSE, &nic_dev->dev_status)) {
+	if (rte_test_and_set_bit32_relaxed(HINIC_DEV_CLOSE,
+					   &nic_dev->dev_status)) {
 		PMD_DRV_LOG(WARNING, "Device %s already closed",
 			    dev->data->name);
 		return;
@@ -3045,7 +3047,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 			    eth_dev->data->name);
 		goto enable_intr_fail;
 	}
-	hinic_set_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
+	rte_set_bit32_relaxed(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
 
 	/* initialize filter info */
 	filter_info = &nic_dev->filter;
@@ -3057,7 +3059,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 	TAILQ_INIT(&nic_dev->filter_fdir_rule_list);
 	TAILQ_INIT(&nic_dev->hinic_flow_list);
 
-	hinic_set_bit(HINIC_DEV_INIT, &nic_dev->dev_status);
+	rte_set_bit32_relaxed(HINIC_DEV_INIT, &nic_dev->dev_status);
 	PMD_DRV_LOG(INFO, "Initialize %s in primary successfully",
 		    eth_dev->data->name);
 
@@ -3113,7 +3115,7 @@ static int hinic_dev_uninit(struct rte_eth_dev *dev)
 	struct hinic_nic_dev *nic_dev;
 
 	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
-	hinic_clear_bit(HINIC_DEV_INIT, &nic_dev->dev_status);
+	rte_clear_bit32_relaxed(HINIC_DEV_INIT, &nic_dev->dev_status);
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
drivers/net/hinic/hinic_pmd_ethdev.h +1 -1
index 3e3f3b360..114f1df92 100644
@@ -171,7 +171,7 @@ struct hinic_nic_dev {
 	unsigned int flags;
 	struct nic_service_cap nic_cap;
 	u32 rx_mode_status;	/* promisc or allmulticast */
-	unsigned long dev_status;
+	u32 dev_status;
 
 	char proc_dev_name[HINIC_DEV_NAME_LEN];
 	/* PF0->COS4, PF1->COS5, PF2->COS6, PF3->COS7,
drivers/net/hinic/meson.build +2 -0
index bc7e24639..8c7ee9dfc 100644
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Huawei Technologies Co., Ltd
 
+allow_experimental_apis = true
+
 subdir('base')
 objs = [base_objs]
 
Signature · 1 line
2.17.1
author
#130 lore raw

v10 cover implement common bit operation APIs

In reply to Joyce Kong

v10:
Rename the APIs of '_relaxed' suffix to 'rte_bit_relaxed_xx'. <Tomas Monjalon>

v9:
1. Change '*addr = (*addr) | mask' to '*addr = val | mask'. <Morten Brørup>
2. Move 'rte_bitops.h' from 'device' section to 'basic' section in 'doxy-api-index.md'. <Jerin Jacob>

v8:
1. Change 'rte_pmd_bitops.h' to 'rte_bitops.h' allowing for future extension into other cases other than PMD only.
2. Replace omissive 'unsigned long' with 'uint32_t' to fix compling errors, the reason is the fact that 32-bit and 64-bit systems have different sized 'unsigned long', which caused incompatibility.

v7:
1. Change the API's head file to 'rte_pmd_bitops.h' as a common- but-not-public file.
2. Replace C11 atomic operations with 'volatile'. As the use cases are limited to PMDs, a 'volatile' is sufficient.

v5,v6:
Trim 'unsigned long' in PMDs down to 'uint32_t', as on mainstream 64-bit OS, 'unsigned long' is 64-bit in size, but the 32-bit OS expects 32-bit 'unsigned long' argument.

v4:
Introduce uint32_t/uint64_t *addr when definiting bit operation APIs.

v3:
1. Change the API's head file back to rte_bitops.h, then implement both 32-bit and 64-bit operations with and without C11 atomic memory ordering.
2. Add multi-core test case for bit operations which implemented with memory ordering.
3. Modify the doc of both APIs and test cases.

v2:
1. Add doxygen comments for the rte bit operation API.
2. Add test cases for common rte bit operation API.
3. Change the header file to rte_io_bitops.h and the operation to rte_io_set_bit() etc., as the API uses barriers inside and the barriers are only needed for IO operations.
4. Use an well defined uint_NN_t type.

Joyce Kong (6):
lib/eal: implement the family of common bit operation APIs test/bitops: add bit operation test case net/axgbe: use common rte bit operation APIs instead net/bnx2x: use common rte bit operation APIs instead net/qede: use common rte bit operation APIs instead net/hinic: use common rte bit operation APIs instead

 MAINTAINERS                               |   5 +
 app/test/Makefile                         |   1 +
 app/test/autotest_data.py                 |   6 +
 app/test/meson.build                      |   2 +
 app/test/test_bitops.c                    | 137 +++++++++++
 doc/api/doxy-api-index.md                 |   3 +-
 drivers/net/axgbe/axgbe_common.h          |  29 +--
 drivers/net/axgbe/axgbe_ethdev.c          |  14 +-
 drivers/net/axgbe/axgbe_ethdev.h          |   2 +-
 drivers/net/axgbe/axgbe_mdio.c            |  15 +-
 drivers/net/bnx2x/bnx2x.c                 | 271 +++++++++++-----------
 drivers/net/bnx2x/bnx2x.h                 |  10 +-
 drivers/net/bnx2x/ecore_sp.c              |  68 +++---
 drivers/net/bnx2x/ecore_sp.h              | 106 ++++-----
 drivers/net/hinic/Makefile                |   1 +
 drivers/net/hinic/base/hinic_compat.h     |  33 +--
 drivers/net/hinic/hinic_pmd_ethdev.c      |  18 +-
 drivers/net/hinic/hinic_pmd_ethdev.h      |   2 +-
 drivers/net/hinic/meson.build             |   2 +
 drivers/net/qede/base/bcm_osal.c          |  22 +-
 drivers/net/qede/base/bcm_osal.h          |  14 +-
 drivers/net/qede/base/ecore.h             |   6 +-
 drivers/net/qede/base/ecore_cxt.c         |   6 +-
 drivers/net/qede/base/ecore_dcbx.c        |   8 +-
 drivers/net/qede/base/ecore_dev.c         |  38 +--
 drivers/net/qede/base/ecore_dev_api.h     |   2 +-
 drivers/net/qede/base/ecore_l2.c          |   6 +-
 drivers/net/qede/base/ecore_mcp.c         |   4 +-
 drivers/net/qede/base/ecore_sp_commands.c |  12 +-
 drivers/net/qede/base/ecore_spq.c         |   2 +-
 drivers/net/qede/base/ecore_spq.h         |  10 +-
 drivers/net/qede/qede_main.c              |   4 +-
 lib/librte_eal/include/meson.build        |   1 +
 lib/librte_eal/include/rte_bitops.h       | 258 ++++++++++++++++++++
 34 files changed, 721 insertions(+), 397 deletions(-)
 create mode 100644 app/test/test_bitops.c
 create mode 100644 lib/librte_eal/include/rte_bitops.h
Signature · 1 line
2.17.1
author
#131 lore raw

PATCH v10 1/6 lib/eal: implement the family of common bit operation APIs

Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication. To reduce duplication, this patch consolidates them into a common API family.

---
 MAINTAINERS                         |   4 +
 doc/api/doxy-api-index.md           |   3 +-
 lib/librte_eal/include/meson.build  |   1 +
 lib/librte_eal/include/rte_bitops.h | 258 ++++++++++++++++++++++++++++
 4 files changed, 265 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_eal/include/rte_bitops.h
MAINTAINERS +4 -0
index d31a80929..c8d4b99a7 100644
@@ -250,6 +250,10 @@ M: Cristian Dumitrescu <[email protected]>
 F: lib/librte_eal/include/rte_bitmap.h
 F: app/test/test_bitmap.c
 
+Bitops
+M: Joyce Kong <[email protected]>
+F: lib/librte_eal/include/rte_bitops.h
+
 MCSlock - EXPERIMENTAL
 M: Phil Yang <[email protected]>
 F: lib/librte_eal/include/generic/rte_mcslock.h
doc/api/doxy-api-index.md +2 -1
index 845a53491..edc5d166c 100644
@@ -165,7 +165,8 @@ The public API headers are grouped by topics:
   [random]             (@ref rte_random.h),
   [config file]        (@ref rte_cfgfile.h),
   [key/value args]     (@ref rte_kvargs.h),
-  [string]             (@ref rte_string_fns.h)
+  [string]             (@ref rte_string_fns.h),
+  [bitops]             (@ref rte_bitops.h)
 
 - **debug**:
   [jobstats]           (@ref rte_jobstats.h),
lib/librte_eal/include/meson.build +1 -0
index e9537c91f..89a6485a4 100644
@@ -6,6 +6,7 @@ includes += include_directories('.')
 headers += files(
 	'rte_alarm.h',
 	'rte_bitmap.h',
+	'rte_bitops.h',
 	'rte_branch_prediction.h',
 	'rte_bus.h',
 	'rte_class.h',
lib/librte_eal/include/rte_bitops.h new file +258 -0

258 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#132 lore raw

PATCH v10 2/6 test/bitops: add bit operation test case

In reply to Joyce Kong

Add test cases for setting bit, clearing bit, testing and setting bit, testing and clearing bit operation.

---
 MAINTAINERS               |   1 +
 app/test/Makefile         |   1 +
 app/test/autotest_data.py |   6 ++
 app/test/meson.build      |   2 +
 app/test/test_bitops.c    | 137 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 147 insertions(+)
 create mode 100644 app/test/test_bitops.c
MAINTAINERS +1 -0
index c8d4b99a7..cff9f590d 100644
@@ -253,6 +253,7 @@ F: app/test/test_bitmap.c
 Bitops
 M: Joyce Kong <[email protected]>
 F: lib/librte_eal/include/rte_bitops.h
+F: app/test/test_bitops.c
 
 MCSlock - EXPERIMENTAL
 M: Phil Yang <[email protected]>
app/test/Makefile +1 -0
index 4582eca6c..eaad3b71d 100644
@@ -70,6 +70,7 @@ SRCS-y += test_ticketlock.c
 SRCS-y += test_memory.c
 SRCS-y += test_memzone.c
 SRCS-y += test_bitmap.c
+SRCS-y += test_bitops.c
 SRCS-y += test_reciprocal_division.c
 SRCS-y += test_reciprocal_division_perf.c
 SRCS-y += test_fbarray.c
app/test/autotest_data.py +6 -0
index 7b1d01389..fc3fcc159 100644
@@ -404,6 +404,12 @@
         "Func":    default_autotest,
         "Report":  None,
     },
+    {
+        "Name":    "Bitops test",
+        "Command": "bitops_test",
+        "Func":    default_autotest,
+        "Report":  None,
+    },
     {
         "Name":    "Hash multiwriter autotest",
         "Command": "hash_multiwriter_autotest",
app/test/meson.build +2 -0
index fc60acbe7..fed6dd51b 100644
@@ -12,6 +12,7 @@ test_sources = files('commands.c',
 	'test_alarm.c',
 	'test_atomic.c',
 	'test_barrier.c',
+	'test_bitops.c',
 	'test_bpf.c',
 	'test_byteorder.c',
 	'test_cmdline.c',
@@ -171,6 +172,7 @@ fast_tests = [
         ['acl_autotest', true],
         ['alarm_autotest', false],
         ['atomic_autotest', false],
+        ['bitops_autotest', true],
         ['byteorder_autotest', true],
         ['cmdline_autotest', true],
         ['common_autotest', true],
app/test/test_bitops.c new file +137 -0

137 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#133 lore raw

PATCH v10 3/6 net/axgbe: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/axgbe/axgbe_common.h | 29 +----------------------------
 drivers/net/axgbe/axgbe_ethdev.c | 14 +++++++-------
 drivers/net/axgbe/axgbe_ethdev.h |  2 +-
 drivers/net/axgbe/axgbe_mdio.c   | 15 ++++++++-------
 4 files changed, 17 insertions(+), 43 deletions(-)
drivers/net/axgbe/axgbe_common.h +1 -28
index f48117180..d53b48ce6 100644
@@ -21,6 +21,7 @@
 #include <inttypes.h>
 #include <pthread.h>
 
+#include <rte_bitops.h>
 #include <rte_byteorder.h>
 #include <rte_memory.h>
 #include <rte_malloc.h>
@@ -1700,34 +1701,6 @@ do {									\
 #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);
drivers/net/axgbe/axgbe_ethdev.c +7 -7
index 867058845..5ea37f140 100644
@@ -327,8 +327,8 @@ axgbe_dev_start(struct rte_eth_dev *dev)
 	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;
@@ -352,17 +352,17 @@ axgbe_dev_stop(struct rte_eth_dev *dev)
 
 	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. */
@@ -1470,8 +1470,8 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
 
 	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);
drivers/net/axgbe/axgbe_ethdev.h +1 -1
index f10ec4a40..1898e9eb9 100644
@@ -522,7 +522,7 @@ struct axgbe_port {
 	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;
drivers/net/axgbe/axgbe_mdio.c +8 -7
index 0f226c3f2..4f98e695a 100644
@@ -916,7 +916,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata)
 {
 	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);
@@ -981,9 +981,9 @@ static int axgbe_phy_config_aneg(struct axgbe_port *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);
 
@@ -1072,7 +1072,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)
 	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;
 	}
@@ -1116,10 +1116,11 @@ static void axgbe_phy_status(struct axgbe_port *pdata)
 			}
 		}
 		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)
Signature · 1 line
2.17.1
author
#134 lore raw

PATCH v10 4/6 net/bnx2x: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/bnx2x/bnx2x.c    | 271 +++++++++++++++++------------------
 drivers/net/bnx2x/bnx2x.h    |  10 +-
 drivers/net/bnx2x/ecore_sp.c |  68 ++++-----
 drivers/net/bnx2x/ecore_sp.h | 106 +++++++-------
 4 files changed, 221 insertions(+), 234 deletions(-)
drivers/net/bnx2x/bnx2x.c +130 -141
index ff7646b25..8eb6d609b 100644
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <zlib.h>
+#include <rte_bitops.h>
 #include <rte_string_fns.h>
 
 #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"
@@ -129,32 +130,6 @@ static void bnx2x_ack_sb(struct bnx2x_softc *sc, uint8_t igu_sb_id,
 			 uint8_t storm, uint16_t index, uint8_t op,
 			 uint8_t update);
 
-int bnx2x_test_bit(int nr, volatile unsigned long *addr)
-{
-	int res;
-
-	mb();
-	res = ((*addr) & (1UL << nr)) != 0;
-	mb();
-	return res;
-}
-
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-void bnx2x_clear_bit(int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-int bnx2x_test_and_clear_bit(int nr, volatile unsigned long *addr)
-{
-	unsigned long mask = (1UL << nr);
-	return __sync_fetch_and_and(addr, ~mask) & mask;
-}
-
 int bnx2x_cmpxchg(volatile int *addr, int old, int new)
 {
 	return __sync_val_compare_and_swap(addr, old, new);
@@ -1434,16 +1409,16 @@ static int
 bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 		 int mac_type, uint8_t wait_for_comp)
 {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
 	int rc;
 
 	/* wait for completion of requested */
 	if (wait_for_comp) {
-		bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+		rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
 	}
 
 	/* Set the mac type of addresses we want to clear */
-	bnx2x_set_bit(mac_type, &vlan_mac_flags);
+	rte_bit_relaxed_set32(mac_type, &vlan_mac_flags);
 
 	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
 	if (rc < 0)
@@ -1454,8 +1429,7 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 
 static int
 bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
-			unsigned long *rx_accept_flags,
-			unsigned long *tx_accept_flags)
+			uint32_t *rx_accept_flags, uint32_t *tx_accept_flags)
 {
 	/* Clear the flags first */
 	*rx_accept_flags = 0;
@@ -1470,26 +1444,28 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 		break;
 
 	case BNX2X_RX_MODE_NORMAL:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		break;
 
 	case BNX2X_RX_MODE_ALLMULTI:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		break;
 
@@ -1500,19 +1476,23 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 		 * should receive matched and unmatched (in resolution of port)
 		 * unicast packets.
 		 */
-		bnx2x_set_bit(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
 		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
 		if (IS_MF_SI(sc)) {
-			bnx2x_set_bit(ECORE_ACCEPT_ALL_UNICAST, tx_accept_flags);
+			rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_UNICAST,
+					tx_accept_flags);
 		} else {
-			bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+			rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST,
+					      tx_accept_flags);
 		}
 
 		break;
@@ -1524,8 +1504,8 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 
 	/* Set ACCEPT_ANY_VLAN as we do not enable filtering by VLAN */
 	if (rx_mode != BNX2X_RX_MODE_NONE) {
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
 	}
 
 	return 0;
@@ -1554,7 +1534,7 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
 	ramrod_param.rdata = BNX2X_SP(sc, rx_mode_rdata);
 	ramrod_param.rdata_mapping =
 	    (rte_iova_t)BNX2X_SP_MAPPING(sc, rx_mode_rdata),
-	    bnx2x_set_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	    rte_bit_relaxed_set32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
 	ramrod_param.ramrod_flags = ramrod_flags;
 	ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1573,8 +1553,8 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
 
 int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
 {
-	unsigned long rx_mode_flags = 0, ramrod_flags = 0;
-	unsigned long rx_accept_flags = 0, tx_accept_flags = 0;
+	uint32_t rx_mode_flags = 0, ramrod_flags = 0;
+	uint32_t rx_accept_flags = 0, tx_accept_flags = 0;
 	int rc;
 
 	rc = bnx2x_fill_accept_flags(sc, sc->rx_mode, &rx_accept_flags,
@@ -1583,9 +1563,9 @@ int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
 		return rc;
 	}
 
-	bnx2x_set_bit(RAMROD_RX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_TX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_RX, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_TX, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
 
 	return bnx2x_set_q_rx_mode(sc, sc->fp[0].cl_id, rx_mode_flags,
 				 rx_accept_flags, tx_accept_flags,
@@ -1710,7 +1690,8 @@ static int bnx2x_func_wait_started(struct bnx2x_softc *sc)
 			    "Forcing STARTED-->TX_STOPPED-->STARTED");
 
 		func_params.f_obj = &sc->func_obj;
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
 
 		/* STARTED-->TX_STOPPED */
 		func_params.cmd = ECORE_F_CMD_TX_STOP;
@@ -1734,7 +1715,7 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
 
 	q_params.q_obj = &sc->sp_objs[fp->index].q_obj;
 	/* We want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
 	/* Stop the primary connection: */
 
@@ -1763,26 +1744,25 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
 }
 
 /* wait for the outstanding SP commands */
-static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, unsigned long mask)
+static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, uint32_t mask)
 {
-	unsigned long tmp;
+	uint32_t tmp;
 	int tout = 5000;	/* wait for 5 secs tops */
 
 	while (tout--) {
 		mb();
-		if (!(atomic_load_acq_long(&sc->sp_state) & mask)) {
+		if (!(atomic_load_acq_int(&sc->sp_state) & mask))
 			return TRUE;
-		}
 
 		DELAY(1000);
 	}
 
 	mb();
 
-	tmp = atomic_load_acq_long(&sc->sp_state);
+	tmp = atomic_load_acq_int(&sc->sp_state);
 	if (tmp & mask) {
 		PMD_DRV_LOG(INFO, sc, "Filtering completion timed out: "
-			    "sp_state 0x%lx, mask 0x%lx", tmp, mask);
+			    "sp_state 0x%x, mask 0x%x", tmp, mask);
 		return FALSE;
 	}
 
@@ -1795,7 +1775,7 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
 	int rc;
 
 	/* prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_STOP;
 
@@ -1809,7 +1789,8 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
 	if (rc) {
 		PMD_DRV_LOG(NOTICE, sc, "FUNC_STOP ramrod failed. "
 			    "Running a dry transaction");
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
 		return ecore_func_state_change(sc, &func_params);
 	}
 
@@ -1821,7 +1802,7 @@ static int bnx2x_reset_hw(struct bnx2x_softc *sc, uint32_t load_code)
 	struct ecore_func_state_params func_params = { NULL };
 
 	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_HW_RESET;
@@ -1878,11 +1859,11 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
 	 * a race between the completion code and this code.
 	 */
 
-	if (bnx2x_test_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state)) {
-		bnx2x_set_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state);
-	} else {
+	if (rte_bit_relaxed_get32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state))
+		rte_bit_relaxed_set32(ECORE_FILTER_RX_MODE_SCHED,
+				      &sc->sp_state);
+	else
 		bnx2x_set_storm_rx_mode(sc);
-	}
 
 	/* Clean up multicast configuration */
 	rparam.mcast_obj = &sc->mcast_obj;
@@ -1922,9 +1903,8 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
 	 * If SP settings didn't get completed so far - something
 	 * very wrong has happen.
 	 */
-	if (!bnx2x_wait_sp_comp(sc, ~0x0UL)) {
+	if (!bnx2x_wait_sp_comp(sc, ~0x0U))
 		PMD_DRV_LOG(NOTICE, sc, "Common slow path ramrods got stuck!");
-	}
 
 unload_error:
 
@@ -1964,7 +1944,7 @@ static void bnx2x_disable_close_the_gate(struct bnx2x_softc *sc)
  */
 static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
 	struct ecore_mcast_ramrod_params rparam = { NULL };
 	struct ecore_vlan_mac_obj *mac_obj = &sc->sp_objs->mac_obj;
 	int rc;
@@ -1972,12 +1952,12 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 	/* Cleanup MACs' object first... */
 
 	/* Wait for completion of requested */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
 	/* Perform a dry cleanup */
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
 
 	/* Clean ETH primary MAC */
-	bnx2x_set_bit(ECORE_ETH_MAC, &vlan_mac_flags);
+	rte_bit_relaxed_set32(ECORE_ETH_MAC, &vlan_mac_flags);
 	rc = mac_obj->delete_all(sc, &sc->sp_objs->mac_obj, &vlan_mac_flags,
 				 &ramrod_flags);
 	if (rc != 0) {
@@ -1986,7 +1966,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 
 	/* Cleanup UC list */
 	vlan_mac_flags = 0;
-	bnx2x_set_bit(ECORE_UC_LIST_MAC, &vlan_mac_flags);
+	rte_bit_relaxed_set32(ECORE_UC_LIST_MAC, &vlan_mac_flags);
 	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
 	if (rc != 0) {
 		PMD_DRV_LOG(NOTICE, sc,
@@ -1996,7 +1976,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 	/* Now clean mcast object... */
 
 	rparam.mcast_obj = &sc->mcast_obj;
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
 
 	/* Add a DEL command... */
 	rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_DEL);
@@ -4310,13 +4290,13 @@ static void bnx2x_handle_mcast_eqe(struct bnx2x_softc *sc)
 static void
 bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *elem)
 {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
 	int rc = 0;
 	uint32_t cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK;
 	struct ecore_vlan_mac_obj *vlan_mac_obj;
 
 	/* always push next commands out, don't wait here */
-	bnx2x_set_bit(RAMROD_CONT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_CONT, &ramrod_flags);
 
 	switch (le32toh(elem->message.data.eth_event.echo) >> BNX2X_SWCID_SHIFT) {
 	case ECORE_FILTER_MAC_PENDING:
@@ -4347,12 +4327,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *e
 
 static void bnx2x_handle_rx_mode_eqe(struct bnx2x_softc *sc)
 {
-	bnx2x_clear_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	rte_bit_relaxed_clear32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
 	/* send rx_mode command again if was requested */
-	if (bnx2x_test_and_clear_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state)) {
+	if (rte_bit_relaxed_test_and_clear32(ECORE_FILTER_RX_MODE_SCHED,
+						&sc->sp_state))
 		bnx2x_set_storm_rx_mode(sc);
-	}
 }
 
 static void bnx2x_update_eq_prod(struct bnx2x_softc *sc, uint16_t prod)
@@ -4721,7 +4701,7 @@ static int bnx2x_init_hw(struct bnx2x_softc *sc, uint32_t load_code)
 	PMD_INIT_FUNC_TRACE(sc);
 
 	/* prepare the parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_HW_INIT;
@@ -4969,7 +4949,7 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
 {
 	struct bnx2x_fastpath *fp = &sc->fp[idx];
 	uint32_t cids[ECORE_MULTI_TX_COS] = { 0 };
-	unsigned long q_type = 0;
+	uint32_t q_type = 0;
 	int cos;
 
 	fp->sc = sc;
@@ -5016,8 +4996,8 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
 	bnx2x_update_fp_sb_idx(fp);
 
 	/* Configure Queue State object */
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_RX, &q_type);
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_TX, &q_type);
+	rte_bit_relaxed_set32(ECORE_Q_TYPE_HAS_RX, &q_type);
+	rte_bit_relaxed_set32(ECORE_Q_TYPE_HAS_TX, &q_type);
 
 	ecore_init_queue_obj(sc,
 			     &sc->sp_objs[idx].q_obj,
@@ -5831,7 +5811,7 @@ static int bnx2x_func_start(struct bnx2x_softc *sc)
 	    &func_params.params.start;
 
 	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
 	func_params.f_obj = &sc->func_obj;
 	func_params.cmd = ECORE_F_CMD_START;
@@ -6407,11 +6387,11 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
 	uint8_t cos;
 	int cxt_index, cxt_offset;
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->tx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC, &init_params->rx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC, &init_params->tx.flags);
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
 
 	/* HC rate */
 	init_params->rx.hc_rate =
@@ -6442,10 +6422,10 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
 static unsigned long
 bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
 	/* PF driver will always initialize the Queue to an ACTIVE state */
-	bnx2x_set_bit(ECORE_Q_FLG_ACTIVE, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_ACTIVE, &flags);
 
 	/*
 	 * tx only connections collect statistics (on the same index as the
@@ -6453,9 +6433,9 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 	 * connection is initialized.
 	 */
 
-	bnx2x_set_bit(ECORE_Q_FLG_STATS, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_STATS, &flags);
 	if (zero_stats) {
-		bnx2x_set_bit(ECORE_Q_FLG_ZERO_STATS, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_ZERO_STATS, &flags);
 	}
 
 	/*
@@ -6463,28 +6443,28 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
 	 * CoS-ness doesn't survive the loopback
 	 */
 	if (sc->flags & BNX2X_TX_SWITCHING) {
-		bnx2x_set_bit(ECORE_Q_FLG_TX_SWITCH, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_TX_SWITCH, &flags);
 	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
 
 	return flags;
 }
 
 static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)
 {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
 	if (IS_MF_SD(sc)) {
-		bnx2x_set_bit(ECORE_Q_FLG_OV, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_OV, &flags);
 	}
 
 	if (leading) {
-		bnx2x_set_bit(ECORE_Q_FLG_LEADING_RSS, &flags);
-		bnx2x_set_bit(ECORE_Q_FLG_MCAST, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_LEADING_RSS, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_MCAST, &flags);
 	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_VLAN, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_VLAN, &flags);
 
 	/* merge with common flags */
 	return flags | bnx2x_get_common_flags(sc, TRUE);
@@ -6605,7 +6585,7 @@ bnx2x_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, uint8_t lea
 	q_params.q_obj = &BNX2X_SP_OBJ(sc, fp).q_obj;
 
 	/* we want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
 	/* prepare the INIT parameters */
 	bnx2x_pf_q_prep_init(sc, fp, &q_params.params.init);
@@ -6673,20 +6653,20 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
 
 	params.rss_obj = rss_obj;
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &params.ramrod_flags);
 
-	bnx2x_set_bit(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
 
 	/* RSS configuration */
-	bnx2x_set_bit(ECORE_RSS_IPV4, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV4_TCP, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6_TCP, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV4, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV4_TCP, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV6, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV6_TCP, &params.rss_flags);
 	if (rss_obj->udp_rss_v4) {
-		bnx2x_set_bit(ECORE_RSS_IPV4_UDP, &params.rss_flags);
+		rte_bit_relaxed_set32(ECORE_RSS_IPV4_UDP, &params.rss_flags);
 	}
 	if (rss_obj->udp_rss_v6) {
-		bnx2x_set_bit(ECORE_RSS_IPV6_UDP, &params.rss_flags);
+		rte_bit_relaxed_set32(ECORE_RSS_IPV6_UDP, &params.rss_flags);
 	}
 
 	/* Hash bits */
@@ -6701,7 +6681,7 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
 			params.rss_key[i] = (uint32_t) rte_rand();
 		}
 
-		bnx2x_set_bit(ECORE_RSS_SET_SRCH, &params.rss_flags);
+		rte_bit_relaxed_set32(ECORE_RSS_SET_SRCH, &params.rss_flags);
 	}
 
 	if (IS_PF(sc))
@@ -6746,7 +6726,7 @@ static int bnx2x_init_rss_pf(struct bnx2x_softc *sc)
 static int
 bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 		struct ecore_vlan_mac_obj *obj, uint8_t set, int mac_type,
-		unsigned long *ramrod_flags)
+		uint32_t *ramrod_flags)
 {
 	struct ecore_vlan_mac_ramrod_params ramrod_param;
 	int rc;
@@ -6758,11 +6738,12 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 	ramrod_param.ramrod_flags = *ramrod_flags;
 
 	/* fill a user request section if needed */
-	if (!bnx2x_test_bit(RAMROD_CONT, ramrod_flags)) {
+	if (!rte_bit_relaxed_get32(RAMROD_CONT, ramrod_flags)) {
 		rte_memcpy(ramrod_param.user_req.u.mac.mac, mac,
 				 ETH_ALEN);
 
-		bnx2x_set_bit(mac_type, &ramrod_param.user_req.vlan_mac_flags);
+		rte_bit_relaxed_set32(mac_type,
+				      &ramrod_param.user_req.vlan_mac_flags);
 
 /* Set the command: ADD or DEL */
 		ramrod_param.user_req.cmd = (set) ? ECORE_VLAN_MAC_ADD :
@@ -6785,11 +6766,11 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 
 static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)
 {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
 
 	PMD_DRV_LOG(DEBUG, sc, "Adding Ethernet MAC");
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
 
 	/* Eth MAC is set on RSS leading client (fp[0]) */
 	return bnx2x_set_mac_one(sc, sc->link_params.mac_addr,
@@ -6921,24 +6902,26 @@ bnx2x_fill_report_data(struct bnx2x_softc *sc, struct bnx2x_link_report_data *da
 
 	/* Link is down */
 	if (!sc->link_vars.link_up || (sc->flags & BNX2X_MF_FUNC_DIS)) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_LINK_DOWN,
 			    &data->link_report_flags);
 	}
 
 	/* Full DUPLEX */
 	if (sc->link_vars.duplex == DUPLEX_FULL) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_FULL_DUPLEX,
 			    &data->link_report_flags);
 	}
 
 	/* Rx Flow Control is ON */
 	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_RX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_RX_FC_ON, &data->link_report_flags);
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_RX_FC_ON,
+				&data->link_report_flags);
 	}
 
 	/* Tx Flow Control is ON */
 	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_TX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_TX_FC_ON, &data->link_report_flags);
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_TX_FC_ON,
+				&data->link_report_flags);
 	}
 }
 
@@ -6957,14 +6940,14 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 
 	/* Don't report link down or exactly the same link status twice */
 	if (!memcmp(&cur_data, &sc->last_reported_link, sizeof(cur_data)) ||
-	    (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	    (rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
 			  &sc->last_reported_link.link_report_flags) &&
-	     bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	     rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
 			  &cur_data.link_report_flags))) {
 		return;
 	}
 
-	ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %lx, last_reported_link = %lx",
+	ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %x, last_reported_link = %x",
 		       cur_data.link_report_flags,
 		       sc->last_reported_link.link_report_flags);
 
@@ -6974,15 +6957,16 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 	/* report new link params and remember the state for the next time */
 	rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
 
-	if (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	if (rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
 			 &cur_data.link_report_flags)) {
 		ELINK_DEBUG_P0(sc, "NIC Link is Down");
 	} else {
 		__rte_unused const char *duplex;
 		__rte_unused const char *flow;
 
-		if (bnx2x_test_and_clear_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
-					   &cur_data.link_report_flags)) {
+		if (rte_bit_relaxed_test_and_clear32
+					(BNX2X_LINK_REPORT_FULL_DUPLEX,
+					 &cur_data.link_report_flags)) {
 			duplex = "full";
 				ELINK_DEBUG_P0(sc, "link set to full duplex");
 		} else {
@@ -6996,20 +6980,25 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
  * enabled.
  */
 		if (cur_data.link_report_flags) {
-			if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			if (rte_bit_relaxed_get32
+					(BNX2X_LINK_REPORT_RX_FC_ON,
 					 &cur_data.link_report_flags) &&
-			    bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			    rte_bit_relaxed_get32(BNX2X_LINK_REPORT_TX_FC_ON,
 					 &cur_data.link_report_flags)) {
 				flow = "ON - receive & transmit";
-			} else if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
-						&cur_data.link_report_flags) &&
-				   !bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			} else if (rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_RX_FC_ON,
+						 &cur_data.link_report_flags) &&
+				   !rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_TX_FC_ON,
 						 &cur_data.link_report_flags)) {
 				flow = "ON - receive";
-			} else if (!bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			} else if (!rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_RX_FC_ON,
 						 &cur_data.link_report_flags) &&
-				   bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
-						&cur_data.link_report_flags)) {
+				   rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_TX_FC_ON,
+						 &cur_data.link_report_flags)) {
 				flow = "ON - transmit";
 			} else {
 				flow = "none";	/* possible? */
@@ -7429,7 +7418,7 @@ int bnx2x_nic_load(struct bnx2x_softc *sc)
 	bnx2x_set_rx_mode(sc);
 
 	/* wait for all pending SP commands to complete */
-	if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0UL)) {
+	if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0U)) {
 		PMD_DRV_LOG(NOTICE, sc, "Timeout waiting for all SPs to complete!");
 		bnx2x_periodic_stop(sc);
 		bnx2x_nic_unload(sc, UNLOAD_CLOSE, FALSE);
drivers/net/bnx2x/bnx2x.h +3 -7
index 3cadb5d82..69cc1430a 100644
@@ -1000,8 +1000,8 @@ struct bnx2x_sp_objs {
  * link parameters twice.
  */
 struct bnx2x_link_report_data {
-	uint16_t      line_speed;        /* Effective line speed */
-	unsigned long link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
+	uint16_t line_speed;        /* Effective line speed */
+	uint32_t link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
 };
 
 enum {
@@ -1232,7 +1232,7 @@ struct bnx2x_softc {
 	/* slow path */
 	struct bnx2x_dma      sp_dma;
 	struct bnx2x_slowpath *sp;
-	unsigned long       sp_state;
+	uint32_t	    sp_state;
 
 	/* slow path queue */
 	struct bnx2x_dma spq_dma;
@@ -1816,10 +1816,6 @@ static const uint32_t dmae_reg_go_c[] = {
 #define PCI_PM_D0    1
 #define PCI_PM_D3hot 2
 
-int  bnx2x_test_bit(int nr, volatile unsigned long * addr);
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long * addr);
-void bnx2x_clear_bit(int nr, volatile unsigned long * addr);
-int  bnx2x_test_and_clear_bit(int nr, volatile unsigned long * addr);
 int  bnx2x_cmpxchg(volatile int *addr, int old, int new);
 
 int bnx2x_dma_alloc(struct bnx2x_softc *sc, size_t size,
drivers/net/bnx2x/ecore_sp.c +34 -34

241 lines not on this page · raw message

drivers/net/bnx2x/ecore_sp.h +54 -52

310 lines not on this page · raw message

Signature · 1 line
2.17.1
#135 lore raw

Re: [dpdk-dev] [PATCH v10 4/6] net/bnx2x: use common rte bit operation APIs instead

Quoted 3 lines · Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

In an attempt to backtrack what the semantics of <rte_bitops.h> should/need actually be (because the API documentation doesn't say anything regarding atomicity), I found this commmit.

Joyce, you are replacing a set of atomic bit operations in this PMD, all of which are also full barriers, with a set of functions (from rte_bitops.h), all of which are *neither* guarateeed to be atomic *nor* has any memory ordering implications.

Either the Broadcom authors of this PMD put way too much restrictions on its bit operations, or this commit broke this driver.

I had a quick look in the Linux kernel bnx2x driver, and there was a mixture of __set_bit() (non-ordering, non-atomic) and set_bit() (full barrier, atomic).

Quoted 1,344 lines
---
  drivers/net/bnx2x/bnx2x.c    | 271 +++++++++++++++++------------------
  drivers/net/bnx2x/bnx2x.h    |  10 +-
  drivers/net/bnx2x/ecore_sp.c |  68 ++++-----
  drivers/net/bnx2x/ecore_sp.h | 106 +++++++-------
  4 files changed, 221 insertions(+), 234 deletions(-)
drivers/net/bnx2x/bnx2x.c +130 -141
index ff7646b25..8eb6d609b 100644
@@ -25,6 +25,7 @@
  #include <sys/stat.h>
  #include <fcntl.h>
  #include <zlib.h>
+#include <rte_bitops.h>
  #include <rte_string_fns.h>
 
  #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"
@@ -129,32 +130,6 @@ static void bnx2x_ack_sb(struct bnx2x_softc *sc, uint8_t igu_sb_id,
  			 uint8_t storm, uint16_t index, uint8_t op,
  			 uint8_t update);
 
-int bnx2x_test_bit(int nr, volatile unsigned long *addr)
-{
-	int res;
-
-	mb();
-	res = ((*addr) & (1UL << nr)) != 0;
-	mb();
-	return res;
-}
-
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-void bnx2x_clear_bit(int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-int bnx2x_test_and_clear_bit(int nr, volatile unsigned long *addr)
-{
-	unsigned long mask = (1UL << nr);
-	return __sync_fetch_and_and(addr, ~mask) & mask;
-}
-
  int bnx2x_cmpxchg(volatile int *addr, int old, int new)
  {
  	return __sync_val_compare_and_swap(addr, old, new);
@@ -1434,16 +1409,16 @@ static int
  bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
  		 int mac_type, uint8_t wait_for_comp)
  {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
  	int rc;
 
  	/* wait for completion of requested */
  	if (wait_for_comp) {
-		bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+		rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
  	}
 
  	/* Set the mac type of addresses we want to clear */
-	bnx2x_set_bit(mac_type, &vlan_mac_flags);
+	rte_bit_relaxed_set32(mac_type, &vlan_mac_flags);
 
  	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
  	if (rc < 0)
@@ -1454,8 +1429,7 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 
  static int
  bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
-			unsigned long *rx_accept_flags,
-			unsigned long *tx_accept_flags)
+			uint32_t *rx_accept_flags, uint32_t *tx_accept_flags)
  {
  	/* Clear the flags first */
  	*rx_accept_flags = 0;
@@ -1470,26 +1444,28 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
  		break;
 
  	case BNX2X_RX_MODE_NORMAL:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
  		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
  		break;
 
  	case BNX2X_RX_MODE_ALLMULTI:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
  		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
  		break;
 
@@ -1500,19 +1476,23 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
  		 * should receive matched and unmatched (in resolution of port)
  		 * unicast packets.
  		 */
-		bnx2x_set_bit(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
  		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
  		if (IS_MF_SI(sc)) {
-			bnx2x_set_bit(ECORE_ACCEPT_ALL_UNICAST, tx_accept_flags);
+			rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_UNICAST,
+					tx_accept_flags);
  		} else {
-			bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+			rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST,
+					      tx_accept_flags);
  		}
 
  		break;
@@ -1524,8 +1504,8 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 
  	/* Set ACCEPT_ANY_VLAN as we do not enable filtering by VLAN */
  	if (rx_mode != BNX2X_RX_MODE_NONE) {
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
  	}
 
  	return 0;
@@ -1554,7 +1534,7 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
  	ramrod_param.rdata = BNX2X_SP(sc, rx_mode_rdata);
  	ramrod_param.rdata_mapping =
  	    (rte_iova_t)BNX2X_SP_MAPPING(sc, rx_mode_rdata),
-	    bnx2x_set_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	    rte_bit_relaxed_set32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
  	ramrod_param.ramrod_flags = ramrod_flags;
  	ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1573,8 +1553,8 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
 
  int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
  {
-	unsigned long rx_mode_flags = 0, ramrod_flags = 0;
-	unsigned long rx_accept_flags = 0, tx_accept_flags = 0;
+	uint32_t rx_mode_flags = 0, ramrod_flags = 0;
+	uint32_t rx_accept_flags = 0, tx_accept_flags = 0;
  	int rc;
 
  	rc = bnx2x_fill_accept_flags(sc, sc->rx_mode, &rx_accept_flags,
@@ -1583,9 +1563,9 @@ int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
  		return rc;
  	}
 
-	bnx2x_set_bit(RAMROD_RX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_TX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_RX, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_TX, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
 
  	return bnx2x_set_q_rx_mode(sc, sc->fp[0].cl_id, rx_mode_flags,
  				 rx_accept_flags, tx_accept_flags,
@@ -1710,7 +1690,8 @@ static int bnx2x_func_wait_started(struct bnx2x_softc *sc)
  			    "Forcing STARTED-->TX_STOPPED-->STARTED");
 
  		func_params.f_obj = &sc->func_obj;
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
 
  		/* STARTED-->TX_STOPPED */
  		func_params.cmd = ECORE_F_CMD_TX_STOP;
@@ -1734,7 +1715,7 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
 
  	q_params.q_obj = &sc->sp_objs[fp->index].q_obj;
  	/* We want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
  	/* Stop the primary connection: */
 
@@ -1763,26 +1744,25 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
  }
 
  /* wait for the outstanding SP commands */
-static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, unsigned long mask)
+static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, uint32_t mask)
  {
-	unsigned long tmp;
+	uint32_t tmp;
  	int tout = 5000;	/* wait for 5 secs tops */
 
  	while (tout--) {
  		mb();
-		if (!(atomic_load_acq_long(&sc->sp_state) & mask)) {
+		if (!(atomic_load_acq_int(&sc->sp_state) & mask))
  			return TRUE;
-		}
 
  		DELAY(1000);
  	}
 
  	mb();
 
-	tmp = atomic_load_acq_long(&sc->sp_state);
+	tmp = atomic_load_acq_int(&sc->sp_state);
  	if (tmp & mask) {
  		PMD_DRV_LOG(INFO, sc, "Filtering completion timed out: "
-			    "sp_state 0x%lx, mask 0x%lx", tmp, mask);
+			    "sp_state 0x%x, mask 0x%x", tmp, mask);
  		return FALSE;
  	}
 
@@ -1795,7 +1775,7 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
  	int rc;
 
  	/* prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
  	func_params.f_obj = &sc->func_obj;
  	func_params.cmd = ECORE_F_CMD_STOP;
 
@@ -1809,7 +1789,8 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
  	if (rc) {
  		PMD_DRV_LOG(NOTICE, sc, "FUNC_STOP ramrod failed. "
  			    "Running a dry transaction");
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
  		return ecore_func_state_change(sc, &func_params);
  	}
 
@@ -1821,7 +1802,7 @@ static int bnx2x_reset_hw(struct bnx2x_softc *sc, uint32_t load_code)
  	struct ecore_func_state_params func_params = { NULL };
 
  	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
  	func_params.f_obj = &sc->func_obj;
  	func_params.cmd = ECORE_F_CMD_HW_RESET;
@@ -1878,11 +1859,11 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
  	 * a race between the completion code and this code.
  	 */
 
-	if (bnx2x_test_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state)) {
-		bnx2x_set_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state);
-	} else {
+	if (rte_bit_relaxed_get32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state))
+		rte_bit_relaxed_set32(ECORE_FILTER_RX_MODE_SCHED,
+				      &sc->sp_state);
+	else
  		bnx2x_set_storm_rx_mode(sc);
-	}
 
  	/* Clean up multicast configuration */
  	rparam.mcast_obj = &sc->mcast_obj;
@@ -1922,9 +1903,8 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
  	 * If SP settings didn't get completed so far - something
  	 * very wrong has happen.
  	 */
-	if (!bnx2x_wait_sp_comp(sc, ~0x0UL)) {
+	if (!bnx2x_wait_sp_comp(sc, ~0x0U))
  		PMD_DRV_LOG(NOTICE, sc, "Common slow path ramrods got stuck!");
-	}
 
  unload_error:
 
@@ -1964,7 +1944,7 @@ static void bnx2x_disable_close_the_gate(struct bnx2x_softc *sc)
   */
  static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
  {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
  	struct ecore_mcast_ramrod_params rparam = { NULL };
  	struct ecore_vlan_mac_obj *mac_obj = &sc->sp_objs->mac_obj;
  	int rc;
@@ -1972,12 +1952,12 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
  	/* Cleanup MACs' object first... */
 
  	/* Wait for completion of requested */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
  	/* Perform a dry cleanup */
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
 
  	/* Clean ETH primary MAC */
-	bnx2x_set_bit(ECORE_ETH_MAC, &vlan_mac_flags);
+	rte_bit_relaxed_set32(ECORE_ETH_MAC, &vlan_mac_flags);
  	rc = mac_obj->delete_all(sc, &sc->sp_objs->mac_obj, &vlan_mac_flags,
  				 &ramrod_flags);
  	if (rc != 0) {
@@ -1986,7 +1966,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 
  	/* Cleanup UC list */
  	vlan_mac_flags = 0;
-	bnx2x_set_bit(ECORE_UC_LIST_MAC, &vlan_mac_flags);
+	rte_bit_relaxed_set32(ECORE_UC_LIST_MAC, &vlan_mac_flags);
  	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
  	if (rc != 0) {
  		PMD_DRV_LOG(NOTICE, sc,
@@ -1996,7 +1976,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
  	/* Now clean mcast object... */
 
  	rparam.mcast_obj = &sc->mcast_obj;
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
 
  	/* Add a DEL command... */
  	rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_DEL);
@@ -4310,13 +4290,13 @@ static void bnx2x_handle_mcast_eqe(struct bnx2x_softc *sc)
  static void
  bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *elem)
  {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
  	int rc = 0;
  	uint32_t cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK;
  	struct ecore_vlan_mac_obj *vlan_mac_obj;
 
  	/* always push next commands out, don't wait here */
-	bnx2x_set_bit(RAMROD_CONT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_CONT, &ramrod_flags);
 
  	switch (le32toh(elem->message.data.eth_event.echo) >> BNX2X_SWCID_SHIFT) {
  	case ECORE_FILTER_MAC_PENDING:
@@ -4347,12 +4327,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *e
 
  static void bnx2x_handle_rx_mode_eqe(struct bnx2x_softc *sc)
  {
-	bnx2x_clear_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	rte_bit_relaxed_clear32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
  	/* send rx_mode command again if was requested */
-	if (bnx2x_test_and_clear_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state)) {
+	if (rte_bit_relaxed_test_and_clear32(ECORE_FILTER_RX_MODE_SCHED,
+						&sc->sp_state))
  		bnx2x_set_storm_rx_mode(sc);
-	}
  }
 
  static void bnx2x_update_eq_prod(struct bnx2x_softc *sc, uint16_t prod)
@@ -4721,7 +4701,7 @@ static int bnx2x_init_hw(struct bnx2x_softc *sc, uint32_t load_code)
  	PMD_INIT_FUNC_TRACE(sc);
 
  	/* prepare the parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
  	func_params.f_obj = &sc->func_obj;
  	func_params.cmd = ECORE_F_CMD_HW_INIT;
@@ -4969,7 +4949,7 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
  {
  	struct bnx2x_fastpath *fp = &sc->fp[idx];
  	uint32_t cids[ECORE_MULTI_TX_COS] = { 0 };
-	unsigned long q_type = 0;
+	uint32_t q_type = 0;
  	int cos;
 
  	fp->sc = sc;
@@ -5016,8 +4996,8 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
  	bnx2x_update_fp_sb_idx(fp);
 
  	/* Configure Queue State object */
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_RX, &q_type);
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_TX, &q_type);
+	rte_bit_relaxed_set32(ECORE_Q_TYPE_HAS_RX, &q_type);
+	rte_bit_relaxed_set32(ECORE_Q_TYPE_HAS_TX, &q_type);
 
  	ecore_init_queue_obj(sc,
  			     &sc->sp_objs[idx].q_obj,
@@ -5831,7 +5811,7 @@ static int bnx2x_func_start(struct bnx2x_softc *sc)
  	    &func_params.params.start;
 
  	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
  	func_params.f_obj = &sc->func_obj;
  	func_params.cmd = ECORE_F_CMD_START;
@@ -6407,11 +6387,11 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
  	uint8_t cos;
  	int cxt_index, cxt_offset;
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->tx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC, &init_params->rx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC, &init_params->tx.flags);
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
 
  	/* HC rate */
  	init_params->rx.hc_rate =
@@ -6442,10 +6422,10 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
  static unsigned long
  bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
  {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
  	/* PF driver will always initialize the Queue to an ACTIVE state */
-	bnx2x_set_bit(ECORE_Q_FLG_ACTIVE, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_ACTIVE, &flags);
 
  	/*
  	 * tx only connections collect statistics (on the same index as the
@@ -6453,9 +6433,9 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
  	 * connection is initialized.
  	 */
 
-	bnx2x_set_bit(ECORE_Q_FLG_STATS, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_STATS, &flags);
  	if (zero_stats) {
-		bnx2x_set_bit(ECORE_Q_FLG_ZERO_STATS, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_ZERO_STATS, &flags);
  	}
 
  	/*
@@ -6463,28 +6443,28 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
  	 * CoS-ness doesn't survive the loopback
  	 */
  	if (sc->flags & BNX2X_TX_SWITCHING) {
-		bnx2x_set_bit(ECORE_Q_FLG_TX_SWITCH, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_TX_SWITCH, &flags);
  	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
 
  	return flags;
  }
 
  static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)
  {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
  	if (IS_MF_SD(sc)) {
-		bnx2x_set_bit(ECORE_Q_FLG_OV, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_OV, &flags);
  	}
 
  	if (leading) {
-		bnx2x_set_bit(ECORE_Q_FLG_LEADING_RSS, &flags);
-		bnx2x_set_bit(ECORE_Q_FLG_MCAST, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_LEADING_RSS, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_MCAST, &flags);
  	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_VLAN, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_VLAN, &flags);
 
  	/* merge with common flags */
  	return flags | bnx2x_get_common_flags(sc, TRUE);
@@ -6605,7 +6585,7 @@ bnx2x_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, uint8_t lea
  	q_params.q_obj = &BNX2X_SP_OBJ(sc, fp).q_obj;
 
  	/* we want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
  	/* prepare the INIT parameters */
  	bnx2x_pf_q_prep_init(sc, fp, &q_params.params.init);
@@ -6673,20 +6653,20 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
 
  	params.rss_obj = rss_obj;
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &params.ramrod_flags);
 
-	bnx2x_set_bit(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
 
  	/* RSS configuration */
-	bnx2x_set_bit(ECORE_RSS_IPV4, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV4_TCP, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6_TCP, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV4, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV4_TCP, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV6, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV6_TCP, &params.rss_flags);
  	if (rss_obj->udp_rss_v4) {
-		bnx2x_set_bit(ECORE_RSS_IPV4_UDP, &params.rss_flags);
+		rte_bit_relaxed_set32(ECORE_RSS_IPV4_UDP, &params.rss_flags);
  	}
  	if (rss_obj->udp_rss_v6) {
-		bnx2x_set_bit(ECORE_RSS_IPV6_UDP, &params.rss_flags);
+		rte_bit_relaxed_set32(ECORE_RSS_IPV6_UDP, &params.rss_flags);
  	}
 
  	/* Hash bits */
@@ -6701,7 +6681,7 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
  			params.rss_key[i] = (uint32_t) rte_rand();
  		}
 
-		bnx2x_set_bit(ECORE_RSS_SET_SRCH, &params.rss_flags);
+		rte_bit_relaxed_set32(ECORE_RSS_SET_SRCH, &params.rss_flags);
  	}
 
  	if (IS_PF(sc))
@@ -6746,7 +6726,7 @@ static int bnx2x_init_rss_pf(struct bnx2x_softc *sc)
  static int
  bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
  		struct ecore_vlan_mac_obj *obj, uint8_t set, int mac_type,
-		unsigned long *ramrod_flags)
+		uint32_t *ramrod_flags)
  {
  	struct ecore_vlan_mac_ramrod_params ramrod_param;
  	int rc;
@@ -6758,11 +6738,12 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
  	ramrod_param.ramrod_flags = *ramrod_flags;
 
  	/* fill a user request section if needed */
-	if (!bnx2x_test_bit(RAMROD_CONT, ramrod_flags)) {
+	if (!rte_bit_relaxed_get32(RAMROD_CONT, ramrod_flags)) {
  		rte_memcpy(ramrod_param.user_req.u.mac.mac, mac,
  				 ETH_ALEN);
 
-		bnx2x_set_bit(mac_type, &ramrod_param.user_req.vlan_mac_flags);
+		rte_bit_relaxed_set32(mac_type,
+				      &ramrod_param.user_req.vlan_mac_flags);
 
  /* Set the command: ADD or DEL */
  		ramrod_param.user_req.cmd = (set) ? ECORE_VLAN_MAC_ADD :
@@ -6785,11 +6766,11 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 
  static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)
  {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
 
  	PMD_DRV_LOG(DEBUG, sc, "Adding Ethernet MAC");
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
 
  	/* Eth MAC is set on RSS leading client (fp[0]) */
  	return bnx2x_set_mac_one(sc, sc->link_params.mac_addr,
@@ -6921,24 +6902,26 @@ bnx2x_fill_report_data(struct bnx2x_softc *sc, struct bnx2x_link_report_data *da
 
  	/* Link is down */
  	if (!sc->link_vars.link_up || (sc->flags & BNX2X_MF_FUNC_DIS)) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_LINK_DOWN,
  			    &data->link_report_flags);
  	}
 
  	/* Full DUPLEX */
  	if (sc->link_vars.duplex == DUPLEX_FULL) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_FULL_DUPLEX,
  			    &data->link_report_flags);
  	}
 
  	/* Rx Flow Control is ON */
  	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_RX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_RX_FC_ON, &data->link_report_flags);
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_RX_FC_ON,
+				&data->link_report_flags);
  	}
 
  	/* Tx Flow Control is ON */
  	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_TX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_TX_FC_ON, &data->link_report_flags);
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_TX_FC_ON,
+				&data->link_report_flags);
  	}
  }
 
@@ -6957,14 +6940,14 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 
  	/* Don't report link down or exactly the same link status twice */
  	if (!memcmp(&cur_data, &sc->last_reported_link, sizeof(cur_data)) ||
-	    (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	    (rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
  			  &sc->last_reported_link.link_report_flags) &&
-	     bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	     rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
  			  &cur_data.link_report_flags))) {
  		return;
  	}
 
-	ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %lx, last_reported_link = %lx",
+	ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %x, last_reported_link = %x",
  		       cur_data.link_report_flags,
  		       sc->last_reported_link.link_report_flags);
 
@@ -6974,15 +6957,16 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
  	/* report new link params and remember the state for the next time */
  	rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
 
-	if (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	if (rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
  			 &cur_data.link_report_flags)) {
  		ELINK_DEBUG_P0(sc, "NIC Link is Down");
  	} else {
  		__rte_unused const char *duplex;
  		__rte_unused const char *flow;
 
-		if (bnx2x_test_and_clear_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
-					   &cur_data.link_report_flags)) {
+		if (rte_bit_relaxed_test_and_clear32
+					(BNX2X_LINK_REPORT_FULL_DUPLEX,
+					 &cur_data.link_report_flags)) {
  			duplex = "full";
  				ELINK_DEBUG_P0(sc, "link set to full duplex");
  		} else {
@@ -6996,20 +6980,25 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
   * enabled.
   */
  		if (cur_data.link_report_flags) {
-			if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			if (rte_bit_relaxed_get32
+					(BNX2X_LINK_REPORT_RX_FC_ON,
  					 &cur_data.link_report_flags) &&
-			    bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			    rte_bit_relaxed_get32(BNX2X_LINK_REPORT_TX_FC_ON,
  					 &cur_data.link_report_flags)) {
  				flow = "ON - receive & transmit";
-			} else if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
-						&cur_data.link_report_flags) &&
-				   !bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			} else if (rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_RX_FC_ON,
+						 &cur_data.link_report_flags) &&
+				   !rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_TX_FC_ON,
  						 &cur_data.link_report_flags)) {
  				flow = "ON - receive";
-			} else if (!bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			} else if (!rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_RX_FC_ON,
  						 &cur_data.link_report_flags) &&
-				   bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
-						&cur_data.link_report_flags)) {
+				   rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_TX_FC_ON,
+						 &cur_data.link_report_flags)) {
  				flow = "ON - transmit";
  			} else {
  				flow = "none";	/* possible? */
@@ -7429,7 +7418,7 @@ int bnx2x_nic_load(struct bnx2x_softc *sc)
  	bnx2x_set_rx_mode(sc);
 
  	/* wait for all pending SP commands to complete */
-	if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0UL)) {
+	if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0U)) {
  		PMD_DRV_LOG(NOTICE, sc, "Timeout waiting for all SPs to complete!");
  		bnx2x_periodic_stop(sc);
  		bnx2x_nic_unload(sc, UNLOAD_CLOSE, FALSE);
drivers/net/bnx2x/bnx2x.h +3 -7
index 3cadb5d82..69cc1430a 100644
@@ -1000,8 +1000,8 @@ struct bnx2x_sp_objs {
   * link parameters twice.
   */
  struct bnx2x_link_report_data {
-	uint16_t      line_speed;        /* Effective line speed */
-	unsigned long link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
+	uint16_t line_speed;        /* Effective line speed */
+	uint32_t link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
  };
 
  enum {
@@ -1232,7 +1232,7 @@ struct bnx2x_softc {
  	/* slow path */
  	struct bnx2x_dma      sp_dma;
  	struct bnx2x_slowpath *sp;
-	unsigned long       sp_state;
+	uint32_t	    sp_state;
 
  	/* slow path queue */
  	struct bnx2x_dma spq_dma;
@@ -1816,10 +1816,6 @@ static const uint32_t dmae_reg_go_c[] = {
  #define PCI_PM_D0    1
  #define PCI_PM_D3hot 2
 
-int  bnx2x_test_bit(int nr, volatile unsigned long * addr);
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long * addr);
-void bnx2x_clear_bit(int nr, volatile unsigned long * addr);
-int  bnx2x_test_and_clear_bit(int nr, volatile unsigned long * addr);
  int  bnx2x_cmpxchg(volatile int *addr, int old, int new);
 
  int bnx2x_dma_alloc(struct bnx2x_softc *sc, size_t size,
drivers/net/bnx2x/ecore_sp.c +34 -34
index 00c33a317..61f99c640 100644
@@ -161,7 +161,7 @@ static inline void ecore_exe_queue_reset_pending(struct bnx2x_softc *sc,
   */
  static int ecore_exe_queue_step(struct bnx2x_softc *sc,
  				struct ecore_exe_queue_obj *o,
-				unsigned long *ramrod_flags)
+				uint32_t *ramrod_flags)
  {
  	struct ecore_exeq_elem *elem, spacer;
  	int cur_len = 0, rc;
@@ -282,7 +282,7 @@ static void ecore_raw_set_pending(struct ecore_raw_obj *o)
   *
   */
  static int ecore_state_wait(struct bnx2x_softc *sc, int state,
-			    unsigned long *pstate)
+			    uint32_t *pstate)
  {
  	/* can take a while if any port is running */
  	int cnt = 5000;
@@ -396,9 +396,9 @@ static void __ecore_vlan_mac_h_exec_pending(struct bnx2x_softc *sc,
  					    struct ecore_vlan_mac_obj *o)
  {
  	int rc;
-	unsigned long ramrod_flags = o->saved_ramrod_flags;
+	uint32_t ramrod_flags = o->saved_ramrod_flags;
 
-	ECORE_MSG(sc, "vlan_mac_lock execute pending command with ramrod flags %lu",
+	ECORE_MSG(sc, "vlan_mac_lock execute pending command with ramrod flags %u",
  		  ramrod_flags);
  	o->head_exe_request = FALSE;
  	o->saved_ramrod_flags = 0;
@@ -425,11 +425,11 @@ static void __ecore_vlan_mac_h_exec_pending(struct bnx2x_softc *sc,
   */
  static void __ecore_vlan_mac_h_pend(struct bnx2x_softc *sc __rte_unused,
  				    struct ecore_vlan_mac_obj *o,
-				    unsigned long ramrod_flags)
+				    uint32_t ramrod_flags)
  {
  	o->head_exe_request = TRUE;
  	o->saved_ramrod_flags = ramrod_flags;
-	ECORE_MSG(sc, "Placing pending execution with ramrod flags %lu",
+	ECORE_MSG(sc, "Placing pending execution with ramrod flags %u",
  		  ramrod_flags);
  }
 
@@ -804,7 +804,7 @@ static void ecore_set_one_mac_e2(struct bnx2x_softc *sc,
  	int rule_cnt = rule_idx + 1, cmd = elem->cmd_data.vlan_mac.cmd;
  	union eth_classify_rule_cmd *rule_entry = &data->rules[rule_idx];
  	bool add = (cmd == ECORE_VLAN_MAC_ADD) ? TRUE : FALSE;
-	unsigned long *vlan_mac_flags = &elem->cmd_data.vlan_mac.vlan_mac_flags;
+	uint32_t *vlan_mac_flags = &elem->cmd_data.vlan_mac.vlan_mac_flags;
  	uint8_t *mac = elem->cmd_data.vlan_mac.u.mac.mac;
 
  	/* Set LLH CAM entry: currently only iSCSI and ETH macs are
@@ -1326,7 +1326,7 @@ static int ecore_wait_vlan_mac(struct bnx2x_softc *sc,
 
  static int __ecore_vlan_mac_execute_step(struct bnx2x_softc *sc,
  					 struct ecore_vlan_mac_obj *o,
-					 unsigned long *ramrod_flags)
+					 uint32_t *ramrod_flags)
  {
  	int rc = ECORE_SUCCESS;
 
@@ -1362,7 +1362,7 @@ static int __ecore_vlan_mac_execute_step(struct bnx2x_softc *sc,
  static int ecore_complete_vlan_mac(struct bnx2x_softc *sc,
  				   struct ecore_vlan_mac_obj *o,
  				   union event_ring_elem *cqe,
-				   unsigned long *ramrod_flags)
+				   uint32_t *ramrod_flags)
  {
  	struct ecore_raw_obj *r = &o->raw;
  	int rc;
@@ -1518,7 +1518,7 @@ static int ecore_vlan_mac_get_registry_elem(struct bnx2x_softc *sc,
  static int ecore_execute_vlan_mac(struct bnx2x_softc *sc,
  				  union ecore_qable_obj *qo,
  				  ecore_list_t * exe_chunk,
-				  unsigned long *ramrod_flags)
+				  uint32_t *ramrod_flags)
  {
  	struct ecore_exeq_elem *elem;
  	struct ecore_vlan_mac_obj *o = &qo->vlan_mac, *cam_obj;
@@ -1678,7 +1678,7 @@ int ecore_config_vlan_mac(struct bnx2x_softc *sc,
  {
  	int rc = ECORE_SUCCESS;
  	struct ecore_vlan_mac_obj *o = p->vlan_mac_obj;
-	unsigned long *ramrod_flags = &p->ramrod_flags;
+	uint32_t *ramrod_flags = &p->ramrod_flags;
  	int cont = ECORE_TEST_BIT(RAMROD_CONT, ramrod_flags);
  	struct ecore_raw_obj *raw = &o->raw;
 
@@ -1758,8 +1758,8 @@ int ecore_config_vlan_mac(struct bnx2x_softc *sc,
   */
  static int ecore_vlan_mac_del_all(struct bnx2x_softc *sc,
  				  struct ecore_vlan_mac_obj *o,
-				  unsigned long *vlan_mac_flags,
-				  unsigned long *ramrod_flags)
+				  uint32_t *vlan_mac_flags,
+				  uint32_t *ramrod_flags)
  {
  	struct ecore_vlan_mac_registry_elem *pos = NULL;
  	int rc = 0, read_lock;
@@ -1836,7 +1836,7 @@ static void ecore_init_raw_obj(struct ecore_raw_obj *raw, uint8_t cl_id,
  			       uint32_t cid, uint8_t func_id,
  			       void *rdata,
  			       ecore_dma_addr_t rdata_mapping, int state,
-			       unsigned long *pstate, ecore_obj_type type)
+			       uint32_t *pstate, ecore_obj_type type)
  {
  	raw->func_id = func_id;
  	raw->cid = cid;
@@ -1856,7 +1856,7 @@ static void ecore_init_vlan_mac_common(struct ecore_vlan_mac_obj *o,
  				       uint8_t cl_id, uint32_t cid,
  				       uint8_t func_id, void *rdata,
  				       ecore_dma_addr_t rdata_mapping,
-				       int state, unsigned long *pstate,
+				       int state, uint32_t *pstate,
  				       ecore_obj_type type,
  				       struct ecore_credit_pool_obj
  				       *macs_pool, struct ecore_credit_pool_obj
@@ -1883,7 +1883,7 @@ void ecore_init_mac_obj(struct bnx2x_softc *sc,
  			struct ecore_vlan_mac_obj *mac_obj,
  			uint8_t cl_id, uint32_t cid, uint8_t func_id,
  			void *rdata, ecore_dma_addr_t rdata_mapping, int state,
-			unsigned long *pstate, ecore_obj_type type,
+			uint32_t *pstate, ecore_obj_type type,
  			struct ecore_credit_pool_obj *macs_pool)
  {
  	union ecore_qable_obj *qable_obj = (union ecore_qable_obj *)mac_obj;
@@ -2034,8 +2034,8 @@ static void ecore_rx_mode_set_rdata_hdr_e2(uint32_t cid, struct eth_classify_hea
  	hdr->rule_cnt = rule_cnt;
  }
 
-static void ecore_rx_mode_set_cmd_state_e2(unsigned long *accept_flags, struct eth_filter_rules_cmd
-					   *cmd, int clear_accept_all)
+static void ecore_rx_mode_set_cmd_state_e2(uint32_t *accept_flags,
+			struct eth_filter_rules_cmd *cmd, int clear_accept_all)
  {
  	uint16_t state;
 
@@ -2157,7 +2157,7 @@ static int ecore_set_rx_mode_e2(struct bnx2x_softc *sc,
  	ecore_rx_mode_set_rdata_hdr_e2(p->cid, &data->header, rule_idx);
 
  	    ECORE_MSG
-	    (sc, "About to configure %d rules, rx_accept_flags 0x%lx, tx_accept_flags 0x%lx",
+	    (sc, "About to configure %d rules, rx_accept_flags 0x%x, tx_accept_flags 0x%x",
  	     data->header.rule_cnt, p->rx_accept_flags, p->tx_accept_flags);
 
  	/* No need for an explicit memory barrier here as long we would
@@ -3132,7 +3132,7 @@ void ecore_init_mcast_obj(struct bnx2x_softc *sc,
  			  uint8_t mcast_cl_id, uint32_t mcast_cid,
  			  uint8_t func_id, uint8_t engine_id, void *rdata,
  			  ecore_dma_addr_t rdata_mapping, int state,
-			  unsigned long *pstate, ecore_obj_type type)
+			  uint32_t *pstate, ecore_obj_type type)
  {
  	ECORE_MEMSET(mcast_obj, 0, sizeof(*mcast_obj));
 
@@ -3598,7 +3598,7 @@ void ecore_init_rss_config_obj(struct bnx2x_softc *sc __rte_unused,
  			       uint8_t cl_id, uint32_t cid, uint8_t func_id,
  			       uint8_t engine_id,
  			       void *rdata, ecore_dma_addr_t rdata_mapping,
-			       int state, unsigned long *pstate,
+			       int state, uint32_t *pstate,
  			       ecore_obj_type type)
  {
  	ecore_init_raw_obj(&rss_obj->raw, cl_id, cid, func_id, rdata,
@@ -3627,7 +3627,7 @@ int ecore_queue_state_change(struct bnx2x_softc *sc,
  {
  	struct ecore_queue_sp_obj *o = params->q_obj;
  	int rc, pending_bit;
-	unsigned long *pending = &o->pending;
+	uint32_t *pending = &o->pending;
 
  	/* Check that the requested transition is legal */
  	rc = o->check_transition(sc, o, params);
@@ -3638,9 +3638,9 @@ int ecore_queue_state_change(struct bnx2x_softc *sc,
  	}
 
  	/* Set "pending" bit */
-	ECORE_MSG(sc, "pending bit was=%lx", o->pending);
+	ECORE_MSG(sc, "pending bit was=%x", o->pending);
  	pending_bit = o->set_pending(o, params);
-	ECORE_MSG(sc, "pending bit now=%lx", o->pending);
+	ECORE_MSG(sc, "pending bit now=%x", o->pending);
 
  	/* Don't send a command if only driver cleanup was requested */
  	if (ECORE_TEST_BIT(RAMROD_DRV_CLR_ONLY, &params->ramrod_flags))
@@ -3704,11 +3704,11 @@ static int ecore_queue_comp_cmd(struct bnx2x_softc *sc __rte_unused,
  				struct ecore_queue_sp_obj *o,
  				enum ecore_queue_cmd cmd)
  {
-	unsigned long cur_pending = o->pending;
+	uint32_t cur_pending = o->pending;
 
  	if (!ECORE_TEST_AND_CLEAR_BIT(cmd, &cur_pending)) {
  		PMD_DRV_LOG(ERR, sc,
-			    "Bad MC reply %d for queue %d in state %d pending 0x%lx, next_state %d",
+			    "Bad MC reply %d for queue %d in state %d pending 0x%x, next_state %d",
  			    cmd, o->cids[ECORE_PRIMARY_CID_INDEX], o->state,
  			    cur_pending, o->next_state);
  		return ECORE_INVAL;
@@ -3762,7 +3762,7 @@ static void ecore_q_fill_init_general_data(struct bnx2x_softc *sc __rte_unused,
  					   struct ecore_queue_sp_obj *o,
  					   struct ecore_general_setup_params
  					   *params, struct client_init_general_data
-					   *gen_data, unsigned long *flags)
+					   *gen_data, uint32_t *flags)
  {
  	gen_data->client_id = o->cl_id;
 
@@ -3794,7 +3794,7 @@ static void ecore_q_fill_init_general_data(struct bnx2x_softc *sc __rte_unused,
 
  static void ecore_q_fill_init_tx_data(struct ecore_txq_setup_params *params,
  				      struct client_init_tx_data *tx_data,
-				      unsigned long *flags)
+				      uint32_t *flags)
  {
  	tx_data->enforce_security_flg =
  	    ECORE_TEST_BIT(ECORE_Q_FLG_TX_SEC, flags);
@@ -3840,7 +3840,7 @@ static void ecore_q_fill_init_pause_data(struct rxq_pause_params *params,
 
  static void ecore_q_fill_init_rx_data(struct ecore_rxq_setup_params *params,
  				      struct client_init_rx_data *rx_data,
-				      unsigned long *flags)
+				      uint32_t *flags)
  {
  	rx_data->tpa_en = ECORE_TEST_BIT(ECORE_Q_FLG_TPA, flags) *
  	    CLIENT_INIT_RX_DATA_TPA_EN_IPV4;
@@ -4421,7 +4421,7 @@ static int ecore_queue_chk_transition(struct bnx2x_softc *sc __rte_unused,
  	 * the previous one.
  	 */
  	if (o->pending) {
-		PMD_DRV_LOG(ERR, sc, "Blocking transition since pending was %lx",
+		PMD_DRV_LOG(ERR, sc, "Blocking transition since pending was %x",
  			    o->pending);
  		return ECORE_BUSY;
  	}
@@ -4630,7 +4630,7 @@ void ecore_init_queue_obj(struct bnx2x_softc *sc,
  			  struct ecore_queue_sp_obj *obj,
  			  uint8_t cl_id, uint32_t * cids, uint8_t cid_cnt,
  			  uint8_t func_id, void *rdata,
-			  ecore_dma_addr_t rdata_mapping, unsigned long type)
+			  ecore_dma_addr_t rdata_mapping, uint32_t type)
  {
  	ECORE_MEMSET(obj, 0, sizeof(*obj));
 
@@ -4699,11 +4699,11 @@ ecore_func_state_change_comp(struct bnx2x_softc *sc __rte_unused,
  			     struct ecore_func_sp_obj *o,
  			     enum ecore_func_cmd cmd)
  {
-	unsigned long cur_pending = o->pending;
+	uint32_t cur_pending = o->pending;
 
  	if (!ECORE_TEST_AND_CLEAR_BIT(cmd, &cur_pending)) {
  		PMD_DRV_LOG(ERR, sc,
-			    "Bad MC reply %d for func %d in state %d pending 0x%lx, next_state %d",
+			    "Bad MC reply %d for func %d in state %d pending 0x%x, next_state %d",
  			    cmd, ECORE_FUNC_ID(sc), o->state, cur_pending,
  			    o->next_state);
  		return ECORE_INVAL;
@@ -5311,7 +5311,7 @@ int ecore_func_state_change(struct bnx2x_softc *sc,
  	struct ecore_func_sp_obj *o = params->f_obj;
  	int rc, cnt = 300;
  	enum ecore_func_cmd cmd = params->cmd;
-	unsigned long *pending = &o->pending;
+	uint32_t *pending = &o->pending;
 
  	ECORE_MUTEX_LOCK(&o->one_pending_mutex);
 
drivers/net/bnx2x/ecore_sp.h +54 -52
index cc1db377a..d58072dac 100644
@@ -14,6 +14,7 @@
  #ifndef ECORE_SP_H
  #define ECORE_SP_H
 
+#include <rte_bitops.h>
  #include <rte_byteorder.h>
 
  #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
@@ -73,10 +74,11 @@ typedef rte_spinlock_t ECORE_MUTEX_SPIN;
  #define ECORE_SET_BIT_NA(bit, var)         (*var |= (1 << bit))
  #define ECORE_CLEAR_BIT_NA(bit, var)       (*var &= ~(1 << bit))
 
-#define ECORE_TEST_BIT(bit, var)           bnx2x_test_bit(bit, var)
-#define ECORE_SET_BIT(bit, var)            bnx2x_set_bit(bit, var)
-#define ECORE_CLEAR_BIT(bit, var)          bnx2x_clear_bit(bit, var)
-#define ECORE_TEST_AND_CLEAR_BIT(bit, var) bnx2x_test_and_clear_bit(bit, var)
+#define ECORE_TEST_BIT(bit, var)           rte_bit_relaxed_get32(bit, var)
+#define ECORE_SET_BIT(bit, var)            rte_bit_relaxed_set32(bit, var)
+#define ECORE_CLEAR_BIT(bit, var)          rte_bit_relaxed_clear32(bit, var)
+#define ECORE_TEST_AND_CLEAR_BIT(bit, var) \
+	rte_bit_relaxed_test_and_clear32(bit, var)
 
  #define atomic_load_acq_int                (int)*
  #define atomic_store_rel_int(a, v)         (*a = v)
@@ -485,7 +487,7 @@ struct ecore_raw_obj {
 
  	/* Ramrod state params */
  	int		state;   /* "ramrod is pending" state bit */
-	unsigned long	*pstate; /* pointer to state buffer */
+	uint32_t	*pstate; /* pointer to state buffer */
 
  	ecore_obj_type	obj_type;
 
@@ -538,7 +540,7 @@ struct ecore_vlan_mac_data {
  	/* used to contain the data related vlan_mac_flags bits from
  	 * ramrod parameters.
  	 */
-	unsigned long vlan_mac_flags;
+	uint32_t vlan_mac_flags;
 
  	/* Needed for MOVE command */
  	struct ecore_vlan_mac_obj *target_obj;
@@ -589,7 +591,7 @@ typedef int (*exe_q_optimize)(struct bnx2x_softc *sc,
  typedef int (*exe_q_execute)(struct bnx2x_softc *sc,
  			     union ecore_qable_obj *o,
  			     ecore_list_t *exe_chunk,
-			     unsigned long *ramrod_flags);
+			     uint32_t *ramrod_flags);
  typedef struct ecore_exeq_elem *
  			(*exe_q_get)(struct ecore_exe_queue_obj *o,
  				     struct ecore_exeq_elem *elem);
@@ -659,7 +661,7 @@ struct ecore_vlan_mac_registry_elem {
  	int			cam_offset;
 
  	/* Needed for DEL and RESTORE flows */
-	unsigned long		vlan_mac_flags;
+	uint32_t		vlan_mac_flags;
 
  	union ecore_classification_ramrod_data u;
  };
@@ -688,7 +690,7 @@ struct ecore_vlan_mac_ramrod_params {
  	struct ecore_vlan_mac_obj *vlan_mac_obj;
 
  	/* General command flags: COMP_WAIT, etc. */
-	unsigned long ramrod_flags;
+	uint32_t ramrod_flags;
 
  	/* Command specific configuration request */
  	struct ecore_vlan_mac_data user_req;
@@ -706,7 +708,7 @@ struct ecore_vlan_mac_obj {
  	 */
  	uint8_t		head_reader; /* Num. of readers accessing head list */
  	bool		head_exe_request; /* Pending execution request. */
-	unsigned long	saved_ramrod_flags; /* Ramrods of pending execution */
+	uint32_t	saved_ramrod_flags; /* Ramrods of pending execution */
 
  	/* Execution queue interface instance */
  	struct ecore_exe_queue_obj	exe_queue;
@@ -801,8 +803,8 @@ struct ecore_vlan_mac_obj {
  	 */
  	int (*delete_all)(struct bnx2x_softc *sc,
  			  struct ecore_vlan_mac_obj *o,
-			  unsigned long *vlan_mac_flags,
-			  unsigned long *ramrod_flags);
+			  uint32_t *vlan_mac_flags,
+			  uint32_t *ramrod_flags);
 
  	/**
  	 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
@@ -842,7 +844,7 @@ struct ecore_vlan_mac_obj {
  	 */
  	int (*complete)(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *o,
  			union event_ring_elem *cqe,
-			unsigned long *ramrod_flags);
+			uint32_t *ramrod_flags);
 
  	/**
  	 * Wait for completion of all commands. Don't schedule new ones,
@@ -883,13 +885,13 @@ enum {
 
  struct ecore_rx_mode_ramrod_params {
  	struct ecore_rx_mode_obj *rx_mode_obj;
-	unsigned long *pstate;
+	uint32_t *pstate;
  	int state;
  	uint8_t cl_id;
  	uint32_t cid;
  	uint8_t func_id;
-	unsigned long ramrod_flags;
-	unsigned long rx_mode_flags;
+	uint32_t ramrod_flags;
+	uint32_t rx_mode_flags;
 
  	/* rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
  	 * a tstorm_eth_mac_filter_config (e1x).
@@ -898,10 +900,10 @@ struct ecore_rx_mode_ramrod_params {
  	ecore_dma_addr_t rdata_mapping;
 
  	/* Rx mode settings */
-	unsigned long rx_accept_flags;
+	uint32_t rx_accept_flags;
 
  	/* internal switching settings */
-	unsigned long tx_accept_flags;
+	uint32_t tx_accept_flags;
  };
 
  struct ecore_rx_mode_obj {
@@ -928,7 +930,7 @@ struct ecore_mcast_ramrod_params {
  	struct ecore_mcast_obj *mcast_obj;
 
  	/* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
-	unsigned long ramrod_flags;
+	uint32_t ramrod_flags;
 
  	ecore_list_t mcast_list; /* list of struct ecore_mcast_list_elem */
  	/** TODO:
@@ -1144,22 +1146,22 @@ struct ecore_config_rss_params {
  	struct ecore_rss_config_obj *rss_obj;
 
  	/* may have RAMROD_COMP_WAIT set only */
-	unsigned long	ramrod_flags;
+	uint32_t ramrod_flags;
 
  	/* ECORE_RSS_X bits */
-	unsigned long	rss_flags;
+	uint32_t rss_flags;
 
  	/* Number hash bits to take into an account */
-	uint8_t		rss_result_mask;
+	uint8_t	 rss_result_mask;
 
  	/* Indirection table */
-	uint8_t		ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
+	uint8_t	 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
 
  	/* RSS hash values */
-	uint32_t		rss_key[10];
+	uint32_t rss_key[10];
 
  	/* valid only if ECORE_RSS_UPDATE_TOE is set */
-	uint16_t		toe_rss_bitmap;
+	uint16_t toe_rss_bitmap;
  };
 
  struct ecore_rss_config_obj {
@@ -1290,17 +1292,17 @@ enum ecore_q_type {
 
  struct ecore_queue_init_params {
  	struct {
-		unsigned long	flags;
-		uint16_t		hc_rate;
-		uint8_t		fw_sb_id;
-		uint8_t		sb_cq_index;
+		uint32_t flags;
+		uint16_t hc_rate;
+		uint8_t	 fw_sb_id;
+		uint8_t	 sb_cq_index;
  	} tx;
 
  	struct {
-		unsigned long	flags;
-		uint16_t		hc_rate;
-		uint8_t		fw_sb_id;
-		uint8_t		sb_cq_index;
+		uint32_t flags;
+		uint16_t hc_rate;
+		uint8_t	 fw_sb_id;
+		uint8_t	 sb_cq_index;
  	} rx;
 
  	/* CID context in the host memory */
@@ -1321,10 +1323,10 @@ struct ecore_queue_cfc_del_params {
  };
 
  struct ecore_queue_update_params {
-	unsigned long	update_flags; /* ECORE_Q_UPDATE_XX bits */
-	uint16_t		def_vlan;
-	uint16_t		silent_removal_value;
-	uint16_t		silent_removal_mask;
+	uint32_t	update_flags; /* ECORE_Q_UPDATE_XX bits */
+	uint16_t	def_vlan;
+	uint16_t	silent_removal_value;
+	uint16_t	silent_removal_mask;
  /* index within the tx_only cids of this queue object */
  	uint8_t		cid_index;
  };
@@ -1422,13 +1424,13 @@ struct ecore_queue_setup_params {
  	struct ecore_txq_setup_params txq_params;
  	struct ecore_rxq_setup_params rxq_params;
  	struct rxq_pause_params pause_params;
-	unsigned long flags;
+	uint32_t flags;
  };
 
  struct ecore_queue_setup_tx_only_params {
  	struct ecore_general_setup_params	gen_params;
  	struct ecore_txq_setup_params		txq_params;
-	unsigned long				flags;
+	uint32_t				flags;
  	/* index within the tx_only cids of this queue object */
  	uint8_t					cid_index;
  };
@@ -1440,7 +1442,7 @@ struct ecore_queue_state_params {
  	enum ecore_queue_cmd cmd;
 
  	/* may have RAMROD_COMP_WAIT set only */
-	unsigned long ramrod_flags;
+	uint32_t ramrod_flags;
 
  	/* Params according to the current command */
  	union {
@@ -1478,14 +1480,14 @@ struct ecore_queue_sp_obj {
  	enum ecore_q_state state, next_state;
 
  	/* bits from enum ecore_q_type */
-	unsigned long	type;
+	uint32_t	type;
 
  	/* ECORE_Q_CMD_XX bits. This object implements "one
  	 * pending" paradigm but for debug and tracing purposes it's
  	 * more convenient to have different bits for different
  	 * commands.
  	 */
-	unsigned long	pending;
+	uint32_t	pending;
 
  	/* Buffer to use as a ramrod data and its mapping */
  	void		*rdata;
@@ -1653,7 +1655,7 @@ struct ecore_func_start_params {
  };
 
  struct ecore_func_switch_update_params {
-	unsigned long changes; /* ECORE_F_UPDATE_XX bits */
+	uint32_t changes; /* ECORE_F_UPDATE_XX bits */
  	uint16_t vlan;
  	uint16_t vlan_eth_type;
  	uint8_t vlan_force_prio;
@@ -1704,7 +1706,7 @@ struct ecore_func_state_params {
  	enum ecore_func_cmd cmd;
 
  	/* may have RAMROD_COMP_WAIT set only */
-	unsigned long	ramrod_flags;
+	uint32_t ramrod_flags;
 
  	/* Params according to the current command */
  	union {
@@ -1753,7 +1755,7 @@ struct ecore_func_sp_obj {
  	 * more convenient to have different bits for different
  	 * commands.
  	 */
-	unsigned long		pending;
+	uint32_t		pending;
 
  	/* Buffer to use as a ramrod data and its mapping */
  	void			*rdata;
@@ -1821,7 +1823,7 @@ enum ecore_func_state ecore_func_get_state(struct bnx2x_softc *sc,
  void ecore_init_queue_obj(struct bnx2x_softc *sc,
  			  struct ecore_queue_sp_obj *obj, uint8_t cl_id, uint32_t *cids,
  			  uint8_t cid_cnt, uint8_t func_id, void *rdata,
-			  ecore_dma_addr_t rdata_mapping, unsigned long type);
+			  ecore_dma_addr_t rdata_mapping, uint32_t type);
 
  int ecore_queue_state_change(struct bnx2x_softc *sc,
  			     struct ecore_queue_state_params *params);
@@ -1834,7 +1836,7 @@ void ecore_init_mac_obj(struct bnx2x_softc *sc,
  			struct ecore_vlan_mac_obj *mac_obj,
  			uint8_t cl_id, uint32_t cid, uint8_t func_id, void *rdata,
  			ecore_dma_addr_t rdata_mapping, int state,
-			unsigned long *pstate, ecore_obj_type type,
+			uint32_t *pstate, ecore_obj_type type,
  			struct ecore_credit_pool_obj *macs_pool);
 
  void ecore_init_vlan_obj(struct bnx2x_softc *sc,
@@ -1842,7 +1844,7 @@ void ecore_init_vlan_obj(struct bnx2x_softc *sc,
  			 uint8_t cl_id, uint32_t cid, uint8_t func_id,
  			 void *rdata,
  			 ecore_dma_addr_t rdata_mapping, int state,
-			 unsigned long *pstate, ecore_obj_type type,
+			 uint32_t *pstate, ecore_obj_type type,
  			 struct ecore_credit_pool_obj *vlans_pool);
 
  void ecore_init_vlan_mac_obj(struct bnx2x_softc *sc,
@@ -1850,7 +1852,7 @@ void ecore_init_vlan_mac_obj(struct bnx2x_softc *sc,
  			     uint8_t cl_id, uint32_t cid, uint8_t func_id,
  			     void *rdata,
  			     ecore_dma_addr_t rdata_mapping, int state,
-			     unsigned long *pstate, ecore_obj_type type,
+			     uint32_t *pstate, ecore_obj_type type,
  			     struct ecore_credit_pool_obj *macs_pool,
  			     struct ecore_credit_pool_obj *vlans_pool);
 
@@ -1859,7 +1861,7 @@ void ecore_init_vxlan_fltr_obj(struct bnx2x_softc *sc,
  			       uint8_t cl_id, uint32_t cid, uint8_t func_id,
  			       void *rdata,
  			       ecore_dma_addr_t rdata_mapping, int state,
-			       unsigned long *pstate, ecore_obj_type type,
+			       uint32_t *pstate, ecore_obj_type type,
  			       struct ecore_credit_pool_obj *macs_pool,
  			       struct ecore_credit_pool_obj *vlans_pool);
 
@@ -1901,7 +1903,7 @@ void ecore_init_mcast_obj(struct bnx2x_softc *sc,
  			  struct ecore_mcast_obj *mcast_obj,
  			  uint8_t mcast_cl_id, uint32_t mcast_cid, uint8_t func_id,
  			  uint8_t engine_id, void *rdata, ecore_dma_addr_t rdata_mapping,
-			  int state, unsigned long *pstate,
+			  int state, uint32_t *pstate,
  			  ecore_obj_type type);
 
  /**
@@ -1943,7 +1945,7 @@ void ecore_init_rss_config_obj(struct bnx2x_softc *sc,
  			       struct ecore_rss_config_obj *rss_obj,
  			       uint8_t cl_id, uint32_t cid, uint8_t func_id, uint8_t engine_id,
  			       void *rdata, ecore_dma_addr_t rdata_mapping,
-			       int state, unsigned long *pstate,
+			       int state, uint32_t *pstate,
  			       ecore_obj_type type);
 
  /**
#136 lore raw

Re: [dpdk-dev] [PATCH v10 4/6] net/bnx2x: use common rte bit operation APIs instead

+Cc Julien Aube

17/02/2024 13:01, Mattias Rönnblom:

Quoted 1,366 lines · Joyce Kong
Quoted 3 lines

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

In an attempt to backtrack what the semantics of <rte_bitops.h> should/need actually be (because the API documentation doesn't say anything regarding atomicity), I found this commmit.

Joyce, you are replacing a set of atomic bit operations in this PMD, all of which are also full barriers, with a set of functions (from rte_bitops.h), all of which are *neither* guarateeed to be atomic *nor* has any memory ordering implications.

Either the Broadcom authors of this PMD put way too much restrictions on its bit operations, or this commit broke this driver.

I had a quick look in the Linux kernel bnx2x driver, and there was a mixture of __set_bit() (non-ordering, non-atomic) and set_bit() (full barrier, atomic).

Quoted 1,344 lines
---
  drivers/net/bnx2x/bnx2x.c    | 271 +++++++++++++++++------------------
  drivers/net/bnx2x/bnx2x.h    |  10 +-
  drivers/net/bnx2x/ecore_sp.c |  68 ++++-----
  drivers/net/bnx2x/ecore_sp.h | 106 +++++++-------
  4 files changed, 221 insertions(+), 234 deletions(-)
drivers/net/bnx2x/bnx2x.c +130 -141
index ff7646b25..8eb6d609b 100644
@@ -25,6 +25,7 @@
  #include <sys/stat.h>
  #include <fcntl.h>
  #include <zlib.h>
+#include <rte_bitops.h>
  #include <rte_string_fns.h>
 
  #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"
@@ -129,32 +130,6 @@ static void bnx2x_ack_sb(struct bnx2x_softc *sc, uint8_t igu_sb_id,
  			 uint8_t storm, uint16_t index, uint8_t op,
  			 uint8_t update);
 
-int bnx2x_test_bit(int nr, volatile unsigned long *addr)
-{
-	int res;
-
-	mb();
-	res = ((*addr) & (1UL << nr)) != 0;
-	mb();
-	return res;
-}
-
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-void bnx2x_clear_bit(int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-int bnx2x_test_and_clear_bit(int nr, volatile unsigned long *addr)
-{
-	unsigned long mask = (1UL << nr);
-	return __sync_fetch_and_and(addr, ~mask) & mask;
-}
-
  int bnx2x_cmpxchg(volatile int *addr, int old, int new)
  {
  	return __sync_val_compare_and_swap(addr, old, new);
@@ -1434,16 +1409,16 @@ static int
  bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
  		 int mac_type, uint8_t wait_for_comp)
  {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
  	int rc;
 
  	/* wait for completion of requested */
  	if (wait_for_comp) {
-		bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+		rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
  	}
 
  	/* Set the mac type of addresses we want to clear */
-	bnx2x_set_bit(mac_type, &vlan_mac_flags);
+	rte_bit_relaxed_set32(mac_type, &vlan_mac_flags);
 
  	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
  	if (rc < 0)
@@ -1454,8 +1429,7 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 
  static int
  bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
-			unsigned long *rx_accept_flags,
-			unsigned long *tx_accept_flags)
+			uint32_t *rx_accept_flags, uint32_t *tx_accept_flags)
  {
  	/* Clear the flags first */
  	*rx_accept_flags = 0;
@@ -1470,26 +1444,28 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
  		break;
 
  	case BNX2X_RX_MODE_NORMAL:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
  		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
  		break;
 
  	case BNX2X_RX_MODE_ALLMULTI:
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
  		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
  		break;
 
@@ -1500,19 +1476,23 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
  		 * should receive matched and unmatched (in resolution of port)
  		 * unicast packets.
  		 */
-		bnx2x_set_bit(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_UNICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
 
  		/* internal switching mode */
-		bnx2x_set_bit(ECORE_ACCEPT_ALL_MULTICAST, tx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
+				      tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
 
  		if (IS_MF_SI(sc)) {
-			bnx2x_set_bit(ECORE_ACCEPT_ALL_UNICAST, tx_accept_flags);
+			rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_UNICAST,
+					tx_accept_flags);
  		} else {
-			bnx2x_set_bit(ECORE_ACCEPT_UNICAST, tx_accept_flags);
+			rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST,
+					      tx_accept_flags);
  		}
 
  		break;
@@ -1524,8 +1504,8 @@ bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
 
  	/* Set ACCEPT_ANY_VLAN as we do not enable filtering by VLAN */
  	if (rx_mode != BNX2X_RX_MODE_NONE) {
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
-		bnx2x_set_bit(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
+		rte_bit_relaxed_set32(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
  	}
 
  	return 0;
@@ -1554,7 +1534,7 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
  	ramrod_param.rdata = BNX2X_SP(sc, rx_mode_rdata);
  	ramrod_param.rdata_mapping =
  	    (rte_iova_t)BNX2X_SP_MAPPING(sc, rx_mode_rdata),
-	    bnx2x_set_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	    rte_bit_relaxed_set32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
  	ramrod_param.ramrod_flags = ramrod_flags;
  	ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1573,8 +1553,8 @@ bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
 
  int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
  {
-	unsigned long rx_mode_flags = 0, ramrod_flags = 0;
-	unsigned long rx_accept_flags = 0, tx_accept_flags = 0;
+	uint32_t rx_mode_flags = 0, ramrod_flags = 0;
+	uint32_t rx_accept_flags = 0, tx_accept_flags = 0;
  	int rc;
 
  	rc = bnx2x_fill_accept_flags(sc, sc->rx_mode, &rx_accept_flags,
@@ -1583,9 +1563,9 @@ int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
  		return rc;
  	}
 
-	bnx2x_set_bit(RAMROD_RX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_TX, &ramrod_flags);
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_RX, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_TX, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
 
  	return bnx2x_set_q_rx_mode(sc, sc->fp[0].cl_id, rx_mode_flags,
  				 rx_accept_flags, tx_accept_flags,
@@ -1710,7 +1690,8 @@ static int bnx2x_func_wait_started(struct bnx2x_softc *sc)
  			    "Forcing STARTED-->TX_STOPPED-->STARTED");
 
  		func_params.f_obj = &sc->func_obj;
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
 
  		/* STARTED-->TX_STOPPED */
  		func_params.cmd = ECORE_F_CMD_TX_STOP;
@@ -1734,7 +1715,7 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
 
  	q_params.q_obj = &sc->sp_objs[fp->index].q_obj;
  	/* We want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
  	/* Stop the primary connection: */
 
@@ -1763,26 +1744,25 @@ static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
  }
 
  /* wait for the outstanding SP commands */
-static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, unsigned long mask)
+static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, uint32_t mask)
  {
-	unsigned long tmp;
+	uint32_t tmp;
  	int tout = 5000;	/* wait for 5 secs tops */
 
  	while (tout--) {
  		mb();
-		if (!(atomic_load_acq_long(&sc->sp_state) & mask)) {
+		if (!(atomic_load_acq_int(&sc->sp_state) & mask))
  			return TRUE;
-		}
 
  		DELAY(1000);
  	}
 
  	mb();
 
-	tmp = atomic_load_acq_long(&sc->sp_state);
+	tmp = atomic_load_acq_int(&sc->sp_state);
  	if (tmp & mask) {
  		PMD_DRV_LOG(INFO, sc, "Filtering completion timed out: "
-			    "sp_state 0x%lx, mask 0x%lx", tmp, mask);
+			    "sp_state 0x%x, mask 0x%x", tmp, mask);
  		return FALSE;
  	}
 
@@ -1795,7 +1775,7 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
  	int rc;
 
  	/* prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
  	func_params.f_obj = &sc->func_obj;
  	func_params.cmd = ECORE_F_CMD_STOP;
 
@@ -1809,7 +1789,8 @@ static int bnx2x_func_stop(struct bnx2x_softc *sc)
  	if (rc) {
  		PMD_DRV_LOG(NOTICE, sc, "FUNC_STOP ramrod failed. "
  			    "Running a dry transaction");
-		bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
+		rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY,
+				      &func_params.ramrod_flags);
  		return ecore_func_state_change(sc, &func_params);
  	}
 
@@ -1821,7 +1802,7 @@ static int bnx2x_reset_hw(struct bnx2x_softc *sc, uint32_t load_code)
  	struct ecore_func_state_params func_params = { NULL };
 
  	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
  	func_params.f_obj = &sc->func_obj;
  	func_params.cmd = ECORE_F_CMD_HW_RESET;
@@ -1878,11 +1859,11 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
  	 * a race between the completion code and this code.
  	 */
 
-	if (bnx2x_test_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state)) {
-		bnx2x_set_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state);
-	} else {
+	if (rte_bit_relaxed_get32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state))
+		rte_bit_relaxed_set32(ECORE_FILTER_RX_MODE_SCHED,
+				      &sc->sp_state);
+	else
  		bnx2x_set_storm_rx_mode(sc);
-	}
 
  	/* Clean up multicast configuration */
  	rparam.mcast_obj = &sc->mcast_obj;
@@ -1922,9 +1903,8 @@ bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_li
  	 * If SP settings didn't get completed so far - something
  	 * very wrong has happen.
  	 */
-	if (!bnx2x_wait_sp_comp(sc, ~0x0UL)) {
+	if (!bnx2x_wait_sp_comp(sc, ~0x0U))
  		PMD_DRV_LOG(NOTICE, sc, "Common slow path ramrods got stuck!");
-	}
 
  unload_error:
 
@@ -1964,7 +1944,7 @@ static void bnx2x_disable_close_the_gate(struct bnx2x_softc *sc)
   */
  static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
  {
-	unsigned long ramrod_flags = 0, vlan_mac_flags = 0;
+	uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
  	struct ecore_mcast_ramrod_params rparam = { NULL };
  	struct ecore_vlan_mac_obj *mac_obj = &sc->sp_objs->mac_obj;
  	int rc;
@@ -1972,12 +1952,12 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
  	/* Cleanup MACs' object first... */
 
  	/* Wait for completion of requested */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
  	/* Perform a dry cleanup */
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
 
  	/* Clean ETH primary MAC */
-	bnx2x_set_bit(ECORE_ETH_MAC, &vlan_mac_flags);
+	rte_bit_relaxed_set32(ECORE_ETH_MAC, &vlan_mac_flags);
  	rc = mac_obj->delete_all(sc, &sc->sp_objs->mac_obj, &vlan_mac_flags,
  				 &ramrod_flags);
  	if (rc != 0) {
@@ -1986,7 +1966,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
 
  	/* Cleanup UC list */
  	vlan_mac_flags = 0;
-	bnx2x_set_bit(ECORE_UC_LIST_MAC, &vlan_mac_flags);
+	rte_bit_relaxed_set32(ECORE_UC_LIST_MAC, &vlan_mac_flags);
  	rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
  	if (rc != 0) {
  		PMD_DRV_LOG(NOTICE, sc,
@@ -1996,7 +1976,7 @@ static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
  	/* Now clean mcast object... */
 
  	rparam.mcast_obj = &sc->mcast_obj;
-	bnx2x_set_bit(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
 
  	/* Add a DEL command... */
  	rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_DEL);
@@ -4310,13 +4290,13 @@ static void bnx2x_handle_mcast_eqe(struct bnx2x_softc *sc)
  static void
  bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *elem)
  {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
  	int rc = 0;
  	uint32_t cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK;
  	struct ecore_vlan_mac_obj *vlan_mac_obj;
 
  	/* always push next commands out, don't wait here */
-	bnx2x_set_bit(RAMROD_CONT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_CONT, &ramrod_flags);
 
  	switch (le32toh(elem->message.data.eth_event.echo) >> BNX2X_SWCID_SHIFT) {
  	case ECORE_FILTER_MAC_PENDING:
@@ -4347,12 +4327,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *e
 
  static void bnx2x_handle_rx_mode_eqe(struct bnx2x_softc *sc)
  {
-	bnx2x_clear_bit(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
+	rte_bit_relaxed_clear32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
 
  	/* send rx_mode command again if was requested */
-	if (bnx2x_test_and_clear_bit(ECORE_FILTER_RX_MODE_SCHED, &sc->sp_state)) {
+	if (rte_bit_relaxed_test_and_clear32(ECORE_FILTER_RX_MODE_SCHED,
+						&sc->sp_state))
  		bnx2x_set_storm_rx_mode(sc);
-	}
  }
 
  static void bnx2x_update_eq_prod(struct bnx2x_softc *sc, uint16_t prod)
@@ -4721,7 +4701,7 @@ static int bnx2x_init_hw(struct bnx2x_softc *sc, uint32_t load_code)
  	PMD_INIT_FUNC_TRACE(sc);
 
  	/* prepare the parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
  	func_params.f_obj = &sc->func_obj;
  	func_params.cmd = ECORE_F_CMD_HW_INIT;
@@ -4969,7 +4949,7 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
  {
  	struct bnx2x_fastpath *fp = &sc->fp[idx];
  	uint32_t cids[ECORE_MULTI_TX_COS] = { 0 };
-	unsigned long q_type = 0;
+	uint32_t q_type = 0;
  	int cos;
 
  	fp->sc = sc;
@@ -5016,8 +4996,8 @@ static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
  	bnx2x_update_fp_sb_idx(fp);
 
  	/* Configure Queue State object */
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_RX, &q_type);
-	bnx2x_set_bit(ECORE_Q_TYPE_HAS_TX, &q_type);
+	rte_bit_relaxed_set32(ECORE_Q_TYPE_HAS_RX, &q_type);
+	rte_bit_relaxed_set32(ECORE_Q_TYPE_HAS_TX, &q_type);
 
  	ecore_init_queue_obj(sc,
  			     &sc->sp_objs[idx].q_obj,
@@ -5831,7 +5811,7 @@ static int bnx2x_func_start(struct bnx2x_softc *sc)
  	    &func_params.params.start;
 
  	/* Prepare parameters for function state transitions */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
 
  	func_params.f_obj = &sc->func_obj;
  	func_params.cmd = ECORE_F_CMD_START;
@@ -6407,11 +6387,11 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
  	uint8_t cos;
  	int cxt_index, cxt_offset;
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC, &init_params->tx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC, &init_params->rx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC, &init_params->tx.flags);
 
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
-	bnx2x_set_bit(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
 
  	/* HC rate */
  	init_params->rx.hc_rate =
@@ -6442,10 +6422,10 @@ bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
  static unsigned long
  bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
  {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
  	/* PF driver will always initialize the Queue to an ACTIVE state */
-	bnx2x_set_bit(ECORE_Q_FLG_ACTIVE, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_ACTIVE, &flags);
 
  	/*
  	 * tx only connections collect statistics (on the same index as the
@@ -6453,9 +6433,9 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
  	 * connection is initialized.
  	 */
 
-	bnx2x_set_bit(ECORE_Q_FLG_STATS, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_STATS, &flags);
  	if (zero_stats) {
-		bnx2x_set_bit(ECORE_Q_FLG_ZERO_STATS, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_ZERO_STATS, &flags);
  	}
 
  	/*
@@ -6463,28 +6443,28 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
  	 * CoS-ness doesn't survive the loopback
  	 */
  	if (sc->flags & BNX2X_TX_SWITCHING) {
-		bnx2x_set_bit(ECORE_Q_FLG_TX_SWITCH, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_TX_SWITCH, &flags);
  	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
 
  	return flags;
  }
 
  static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)
  {
-	unsigned long flags = 0;
+	uint32_t flags = 0;
 
  	if (IS_MF_SD(sc)) {
-		bnx2x_set_bit(ECORE_Q_FLG_OV, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_OV, &flags);
  	}
 
  	if (leading) {
-		bnx2x_set_bit(ECORE_Q_FLG_LEADING_RSS, &flags);
-		bnx2x_set_bit(ECORE_Q_FLG_MCAST, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_LEADING_RSS, &flags);
+		rte_bit_relaxed_set32(ECORE_Q_FLG_MCAST, &flags);
  	}
 
-	bnx2x_set_bit(ECORE_Q_FLG_VLAN, &flags);
+	rte_bit_relaxed_set32(ECORE_Q_FLG_VLAN, &flags);
 
  	/* merge with common flags */
  	return flags | bnx2x_get_common_flags(sc, TRUE);
@@ -6605,7 +6585,7 @@ bnx2x_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, uint8_t lea
  	q_params.q_obj = &BNX2X_SP_OBJ(sc, fp).q_obj;
 
  	/* we want to wait for completion in this context */
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
 
  	/* prepare the INIT parameters */
  	bnx2x_pf_q_prep_init(sc, fp, &q_params.params.init);
@@ -6673,20 +6653,20 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
 
  	params.rss_obj = rss_obj;
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &params.ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &params.ramrod_flags);
 
-	bnx2x_set_bit(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_MODE_REGULAR, &params.rss_flags);
 
  	/* RSS configuration */
-	bnx2x_set_bit(ECORE_RSS_IPV4, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV4_TCP, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6, &params.rss_flags);
-	bnx2x_set_bit(ECORE_RSS_IPV6_TCP, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV4, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV4_TCP, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV6, &params.rss_flags);
+	rte_bit_relaxed_set32(ECORE_RSS_IPV6_TCP, &params.rss_flags);
  	if (rss_obj->udp_rss_v4) {
-		bnx2x_set_bit(ECORE_RSS_IPV4_UDP, &params.rss_flags);
+		rte_bit_relaxed_set32(ECORE_RSS_IPV4_UDP, &params.rss_flags);
  	}
  	if (rss_obj->udp_rss_v6) {
-		bnx2x_set_bit(ECORE_RSS_IPV6_UDP, &params.rss_flags);
+		rte_bit_relaxed_set32(ECORE_RSS_IPV6_UDP, &params.rss_flags);
  	}
 
  	/* Hash bits */
@@ -6701,7 +6681,7 @@ bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj
  			params.rss_key[i] = (uint32_t) rte_rand();
  		}
 
-		bnx2x_set_bit(ECORE_RSS_SET_SRCH, &params.rss_flags);
+		rte_bit_relaxed_set32(ECORE_RSS_SET_SRCH, &params.rss_flags);
  	}
 
  	if (IS_PF(sc))
@@ -6746,7 +6726,7 @@ static int bnx2x_init_rss_pf(struct bnx2x_softc *sc)
  static int
  bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
  		struct ecore_vlan_mac_obj *obj, uint8_t set, int mac_type,
-		unsigned long *ramrod_flags)
+		uint32_t *ramrod_flags)
  {
  	struct ecore_vlan_mac_ramrod_params ramrod_param;
  	int rc;
@@ -6758,11 +6738,12 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
  	ramrod_param.ramrod_flags = *ramrod_flags;
 
  	/* fill a user request section if needed */
-	if (!bnx2x_test_bit(RAMROD_CONT, ramrod_flags)) {
+	if (!rte_bit_relaxed_get32(RAMROD_CONT, ramrod_flags)) {
  		rte_memcpy(ramrod_param.user_req.u.mac.mac, mac,
  				 ETH_ALEN);
 
-		bnx2x_set_bit(mac_type, &ramrod_param.user_req.vlan_mac_flags);
+		rte_bit_relaxed_set32(mac_type,
+				      &ramrod_param.user_req.vlan_mac_flags);
 
  /* Set the command: ADD or DEL */
  		ramrod_param.user_req.cmd = (set) ? ECORE_VLAN_MAC_ADD :
@@ -6785,11 +6766,11 @@ bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
 
  static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)
  {
-	unsigned long ramrod_flags = 0;
+	uint32_t ramrod_flags = 0;
 
  	PMD_DRV_LOG(DEBUG, sc, "Adding Ethernet MAC");
 
-	bnx2x_set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
+	rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
 
  	/* Eth MAC is set on RSS leading client (fp[0]) */
  	return bnx2x_set_mac_one(sc, sc->link_params.mac_addr,
@@ -6921,24 +6902,26 @@ bnx2x_fill_report_data(struct bnx2x_softc *sc, struct bnx2x_link_report_data *da
 
  	/* Link is down */
  	if (!sc->link_vars.link_up || (sc->flags & BNX2X_MF_FUNC_DIS)) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_LINK_DOWN,
  			    &data->link_report_flags);
  	}
 
  	/* Full DUPLEX */
  	if (sc->link_vars.duplex == DUPLEX_FULL) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_FULL_DUPLEX,
  			    &data->link_report_flags);
  	}
 
  	/* Rx Flow Control is ON */
  	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_RX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_RX_FC_ON, &data->link_report_flags);
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_RX_FC_ON,
+				&data->link_report_flags);
  	}
 
  	/* Tx Flow Control is ON */
  	if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_TX) {
-		bnx2x_set_bit(BNX2X_LINK_REPORT_TX_FC_ON, &data->link_report_flags);
+		rte_bit_relaxed_set32(BNX2X_LINK_REPORT_TX_FC_ON,
+				&data->link_report_flags);
  	}
  }
 
@@ -6957,14 +6940,14 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 
  	/* Don't report link down or exactly the same link status twice */
  	if (!memcmp(&cur_data, &sc->last_reported_link, sizeof(cur_data)) ||
-	    (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	    (rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
  			  &sc->last_reported_link.link_report_flags) &&
-	     bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	     rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
  			  &cur_data.link_report_flags))) {
  		return;
  	}
 
-	ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %lx, last_reported_link = %lx",
+	ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %x, last_reported_link = %x",
  		       cur_data.link_report_flags,
  		       sc->last_reported_link.link_report_flags);
 
@@ -6974,15 +6957,16 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
  	/* report new link params and remember the state for the next time */
  	rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
 
-	if (bnx2x_test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+	if (rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
  			 &cur_data.link_report_flags)) {
  		ELINK_DEBUG_P0(sc, "NIC Link is Down");
  	} else {
  		__rte_unused const char *duplex;
  		__rte_unused const char *flow;
 
-		if (bnx2x_test_and_clear_bit(BNX2X_LINK_REPORT_FULL_DUPLEX,
-					   &cur_data.link_report_flags)) {
+		if (rte_bit_relaxed_test_and_clear32
+					(BNX2X_LINK_REPORT_FULL_DUPLEX,
+					 &cur_data.link_report_flags)) {
  			duplex = "full";
  				ELINK_DEBUG_P0(sc, "link set to full duplex");
  		} else {
@@ -6996,20 +6980,25 @@ static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
   * enabled.
   */
  		if (cur_data.link_report_flags) {
-			if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			if (rte_bit_relaxed_get32
+					(BNX2X_LINK_REPORT_RX_FC_ON,
  					 &cur_data.link_report_flags) &&
-			    bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			    rte_bit_relaxed_get32(BNX2X_LINK_REPORT_TX_FC_ON,
  					 &cur_data.link_report_flags)) {
  				flow = "ON - receive & transmit";
-			} else if (bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
-						&cur_data.link_report_flags) &&
-				   !bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+			} else if (rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_RX_FC_ON,
+						 &cur_data.link_report_flags) &&
+				   !rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_TX_FC_ON,
  						 &cur_data.link_report_flags)) {
  				flow = "ON - receive";
-			} else if (!bnx2x_test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+			} else if (!rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_RX_FC_ON,
  						 &cur_data.link_report_flags) &&
-				   bnx2x_test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
-						&cur_data.link_report_flags)) {
+				   rte_bit_relaxed_get32
+						(BNX2X_LINK_REPORT_TX_FC_ON,
+						 &cur_data.link_report_flags)) {
  				flow = "ON - transmit";
  			} else {
  				flow = "none";	/* possible? */
@@ -7429,7 +7418,7 @@ int bnx2x_nic_load(struct bnx2x_softc *sc)
  	bnx2x_set_rx_mode(sc);
 
  	/* wait for all pending SP commands to complete */
-	if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0UL)) {
+	if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0U)) {
  		PMD_DRV_LOG(NOTICE, sc, "Timeout waiting for all SPs to complete!");
  		bnx2x_periodic_stop(sc);
  		bnx2x_nic_unload(sc, UNLOAD_CLOSE, FALSE);
drivers/net/bnx2x/bnx2x.h +3 -7
index 3cadb5d82..69cc1430a 100644
@@ -1000,8 +1000,8 @@ struct bnx2x_sp_objs {
   * link parameters twice.
   */
  struct bnx2x_link_report_data {
-	uint16_t      line_speed;        /* Effective line speed */
-	unsigned long link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
+	uint16_t line_speed;        /* Effective line speed */
+	uint32_t link_report_flags; /* BNX2X_LINK_REPORT_XXX flags */
  };
 
  enum {
@@ -1232,7 +1232,7 @@ struct bnx2x_softc {
  	/* slow path */
  	struct bnx2x_dma      sp_dma;
  	struct bnx2x_slowpath *sp;
-	unsigned long       sp_state;
+	uint32_t	    sp_state;
 
  	/* slow path queue */
  	struct bnx2x_dma spq_dma;
@@ -1816,10 +1816,6 @@ static const uint32_t dmae_reg_go_c[] = {
  #define PCI_PM_D0    1
  #define PCI_PM_D3hot 2
 
-int  bnx2x_test_bit(int nr, volatile unsigned long * addr);
-void bnx2x_set_bit(unsigned int nr, volatile unsigned long * addr);
-void bnx2x_clear_bit(int nr, volatile unsigned long * addr);
-int  bnx2x_test_and_clear_bit(int nr, volatile unsigned long * addr);
  int  bnx2x_cmpxchg(volatile int *addr, int old, int new);
 
  int bnx2x_dma_alloc(struct bnx2x_softc *sc, size_t size,
drivers/net/bnx2x/ecore_sp.c +34 -34
index 00c33a317..61f99c640 100644
@@ -161,7 +161,7 @@ static inline void ecore_exe_queue_reset_pending(struct bnx2x_softc *sc,
   */
  static int ecore_exe_queue_step(struct bnx2x_softc *sc,
  				struct ecore_exe_queue_obj *o,
-				unsigned long *ramrod_flags)
+				uint32_t *ramrod_flags)
  {
  	struct ecore_exeq_elem *elem, spacer;
  	int cur_len = 0, rc;
@@ -282,7 +282,7 @@ static void ecore_raw_set_pending(struct ecore_raw_obj *o)
   *
   */
  static int ecore_state_wait(struct bnx2x_softc *sc, int state,
-			    unsigned long *pstate)
+			    uint32_t *pstate)
  {
  	/* can take a while if any port is running */
  	int cnt = 5000;
@@ -396,9 +396,9 @@ static void __ecore_vlan_mac_h_exec_pending(struct bnx2x_softc *sc,
  					    struct ecore_vlan_mac_obj *o)
  {
  	int rc;
-	unsigned long ramrod_flags = o->saved_ramrod_flags;
+	uint32_t ramrod_flags = o->saved_ramrod_flags;
 
-	ECORE_MSG(sc, "vlan_mac_lock execute pending command with ramrod flags %lu",
+	ECORE_MSG(sc, "vlan_mac_lock execute pending command with ramrod flags %u",
  		  ramrod_flags);
  	o->head_exe_request = FALSE;
  	o->saved_ramrod_flags = 0;
@@ -425,11 +425,11 @@ static void __ecore_vlan_mac_h_exec_pending(struct bnx2x_softc *sc,
   */
  static void __ecore_vlan_mac_h_pend(struct bnx2x_softc *sc __rte_unused,
  				    struct ecore_vlan_mac_obj *o,
-				    unsigned long ramrod_flags)
+				    uint32_t ramrod_flags)
  {
  	o->head_exe_request = TRUE;
  	o->saved_ramrod_flags = ramrod_flags;
-	ECORE_MSG(sc, "Placing pending execution with ramrod flags %lu",
+	ECORE_MSG(sc, "Placing pending execution with ramrod flags %u",
  		  ramrod_flags);
  }
 
@@ -804,7 +804,7 @@ static void ecore_set_one_mac_e2(struct bnx2x_softc *sc,
  	int rule_cnt = rule_idx + 1, cmd = elem->cmd_data.vlan_mac.cmd;
  	union eth_classify_rule_cmd *rule_entry = &data->rules[rule_idx];
  	bool add = (cmd == ECORE_VLAN_MAC_ADD) ? TRUE : FALSE;
-	unsigned long *vlan_mac_flags = &elem->cmd_data.vlan_mac.vlan_mac_flags;
+	uint32_t *vlan_mac_flags = &elem->cmd_data.vlan_mac.vlan_mac_flags;
  	uint8_t *mac = elem->cmd_data.vlan_mac.u.mac.mac;
 
  	/* Set LLH CAM entry: currently only iSCSI and ETH macs are
@@ -1326,7 +1326,7 @@ static int ecore_wait_vlan_mac(struct bnx2x_softc *sc,
 
  static int __ecore_vlan_mac_execute_step(struct bnx2x_softc *sc,
  					 struct ecore_vlan_mac_obj *o,
-					 unsigned long *ramrod_flags)
+					 uint32_t *ramrod_flags)
  {
  	int rc = ECORE_SUCCESS;
 
@@ -1362,7 +1362,7 @@ static int __ecore_vlan_mac_execute_step(struct bnx2x_softc *sc,
  static int ecore_complete_vlan_mac(struct bnx2x_softc *sc,
  				   struct ecore_vlan_mac_obj *o,
  				   union event_ring_elem *cqe,
-				   unsigned long *ramrod_flags)
+				   uint32_t *ramrod_flags)
  {
  	struct ecore_raw_obj *r = &o->raw;
  	int rc;
@@ -1518,7 +1518,7 @@ static int ecore_vlan_mac_get_registry_elem(struct bnx2x_softc *sc,
  static int ecore_execute_vlan_mac(struct bnx2x_softc *sc,
  				  union ecore_qable_obj *qo,
  				  ecore_list_t * exe_chunk,
-				  unsigned long *ramrod_flags)
+				  uint32_t *ramrod_flags)
  {
  	struct ecore_exeq_elem *elem;
  	struct ecore_vlan_mac_obj *o = &qo->vlan_mac, *cam_obj;
@@ -1678,7 +1678,7 @@ int ecore_config_vlan_mac(struct bnx2x_softc *sc,
  {
  	int rc = ECORE_SUCCESS;
  	struct ecore_vlan_mac_obj *o = p->vlan_mac_obj;
-	unsigned long *ramrod_flags = &p->ramrod_flags;
+	uint32_t *ramrod_flags = &p->ramrod_flags;
  	int cont = ECORE_TEST_BIT(RAMROD_CONT, ramrod_flags);
  	struct ecore_raw_obj *raw = &o->raw;
 
@@ -1758,8 +1758,8 @@ int ecore_config_vlan_mac(struct bnx2x_softc *sc,
   */
  static int ecore_vlan_mac_del_all(struct bnx2x_softc *sc,
  				  struct ecore_vlan_mac_obj *o,
-				  unsigned long *vlan_mac_flags,
-				  unsigned long *ramrod_flags)
+				  uint32_t *vlan_mac_flags,
+				  uint32_t *ramrod_flags)
  {
  	struct ecore_vlan_mac_registry_elem *pos = NULL;
  	int rc = 0, read_lock;
@@ -1836,7 +1836,7 @@ static void ecore_init_raw_obj(struct ecore_raw_obj *raw, uint8_t cl_id,
  			       uint32_t cid, uint8_t func_id,
  			       void *rdata,
  			       ecore_dma_addr_t rdata_mapping, int state,
-			       unsigned long *pstate, ecore_obj_type type)
+			       uint32_t *pstate, ecore_obj_type type)
  {
  	raw->func_id = func_id;
  	raw->cid = cid;
@@ -1856,7 +1856,7 @@ static void ecore_init_vlan_mac_common(struct ecore_vlan_mac_obj *o,
  				       uint8_t cl_id, uint32_t cid,
  				       uint8_t func_id, void *rdata,
  				       ecore_dma_addr_t rdata_mapping,
-				       int state, unsigned long *pstate,
+				       int state, uint32_t *pstate,
  				       ecore_obj_type type,
  				       struct ecore_credit_pool_obj
  				       *macs_pool, struct ecore_credit_pool_obj
@@ -1883,7 +1883,7 @@ void ecore_init_mac_obj(struct bnx2x_softc *sc,
  			struct ecore_vlan_mac_obj *mac_obj,
  			uint8_t cl_id, uint32_t cid, uint8_t func_id,
  			void *rdata, ecore_dma_addr_t rdata_mapping, int state,
-			unsigned long *pstate, ecore_obj_type type,
+			uint32_t *pstate, ecore_obj_type type,
  			struct ecore_credit_pool_obj *macs_pool)
  {
  	union ecore_qable_obj *qable_obj = (union ecore_qable_obj *)mac_obj;
@@ -2034,8 +2034,8 @@ static void ecore_rx_mode_set_rdata_hdr_e2(uint32_t cid, struct eth_classify_hea
  	hdr->rule_cnt = rule_cnt;
  }
 
-static void ecore_rx_mode_set_cmd_state_e2(unsigned long *accept_flags, struct eth_filter_rules_cmd
-					   *cmd, int clear_accept_all)
+static void ecore_rx_mode_set_cmd_state_e2(uint32_t *accept_flags,
+			struct eth_filter_rules_cmd *cmd, int clear_accept_all)
  {
  	uint16_t state;
 
@@ -2157,7 +2157,7 @@ static int ecore_set_rx_mode_e2(struct bnx2x_softc *sc,
  	ecore_rx_mode_set_rdata_hdr_e2(p->cid, &data->header, rule_idx);
 
  	    ECORE_MSG
-	    (sc, "About to configure %d rules, rx_accept_flags 0x%lx, tx_accept_flags 0x%lx",
+	    (sc, "About to configure %d rules, rx_accept_flags 0x%x, tx_accept_flags 0x%x",
  	     data->header.rule_cnt, p->rx_accept_flags, p->tx_accept_flags);
 
  	/* No need for an explicit memory barrier here as long we would
@@ -3132,7 +3132,7 @@ void ecore_init_mcast_obj(struct bnx2x_softc *sc,
  			  uint8_t mcast_cl_id, uint32_t mcast_cid,
  			  uint8_t func_id, uint8_t engine_id, void *rdata,
  			  ecore_dma_addr_t rdata_mapping, int state,
-			  unsigned long *pstate, ecore_obj_type type)
+			  uint32_t *pstate, ecore_obj_type type)
  {
  	ECORE_MEMSET(mcast_obj, 0, sizeof(*mcast_obj));
 
@@ -3598,7 +3598,7 @@ void ecore_init_rss_config_obj(struct bnx2x_softc *sc __rte_unused,
  			       uint8_t cl_id, uint32_t cid, uint8_t func_id,
  			       uint8_t engine_id,
  			       void *rdata, ecore_dma_addr_t rdata_mapping,
-			       int state, unsigned long *pstate,
+			       int state, uint32_t *pstate,
  			       ecore_obj_type type)
  {
  	ecore_init_raw_obj(&rss_obj->raw, cl_id, cid, func_id, rdata,
@@ -3627,7 +3627,7 @@ int ecore_queue_state_change(struct bnx2x_softc *sc,
  {
  	struct ecore_queue_sp_obj *o = params->q_obj;
  	int rc, pending_bit;
-	unsigned long *pending = &o->pending;
+	uint32_t *pending = &o->pending;
 
  	/* Check that the requested transition is legal */
  	rc = o->check_transition(sc, o, params);
@@ -3638,9 +3638,9 @@ int ecore_queue_state_change(struct bnx2x_softc *sc,
  	}
 
  	/* Set "pending" bit */
-	ECORE_MSG(sc, "pending bit was=%lx", o->pending);
+	ECORE_MSG(sc, "pending bit was=%x", o->pending);
  	pending_bit = o->set_pending(o, params);
-	ECORE_MSG(sc, "pending bit now=%lx", o->pending);
+	ECORE_MSG(sc, "pending bit now=%x", o->pending);
 
  	/* Don't send a command if only driver cleanup was requested */
  	if (ECORE_TEST_BIT(RAMROD_DRV_CLR_ONLY, &params->ramrod_flags))
@@ -3704,11 +3704,11 @@ static int ecore_queue_comp_cmd(struct bnx2x_softc *sc __rte_unused,
  				struct ecore_queue_sp_obj *o,
  				enum ecore_queue_cmd cmd)
  {
-	unsigned long cur_pending = o->pending;
+	uint32_t cur_pending = o->pending;
 
  	if (!ECORE_TEST_AND_CLEAR_BIT(cmd, &cur_pending)) {
  		PMD_DRV_LOG(ERR, sc,
-			    "Bad MC reply %d for queue %d in state %d pending 0x%lx, next_state %d",
+			    "Bad MC reply %d for queue %d in state %d pending 0x%x, next_state %d",
  			    cmd, o->cids[ECORE_PRIMARY_CID_INDEX], o->state,
  			    cur_pending, o->next_state);
  		return ECORE_INVAL;
@@ -3762,7 +3762,7 @@ static void ecore_q_fill_init_general_data(struct bnx2x_softc *sc __rte_unused,
  					   struct ecore_queue_sp_obj *o,
  					   struct ecore_general_setup_params
  					   *params, struct client_init_general_data
-					   *gen_data, unsigned long *flags)
+					   *gen_data, uint32_t *flags)
  {
  	gen_data->client_id = o->cl_id;
 
@@ -3794,7 +3794,7 @@ static void ecore_q_fill_init_general_data(struct bnx2x_softc *sc __rte_unused,
 
  static void ecore_q_fill_init_tx_data(struct ecore_txq_setup_params *params,
  				      struct client_init_tx_data *tx_data,
-				      unsigned long *flags)
+				      uint32_t *flags)
  {
  	tx_data->enforce_security_flg =
  	    ECORE_TEST_BIT(ECORE_Q_FLG_TX_SEC, flags);
@@ -3840,7 +3840,7 @@ static void ecore_q_fill_init_pause_data(struct rxq_pause_params *params,
 
  static void ecore_q_fill_init_rx_data(struct ecore_rxq_setup_params *params,
  				      struct client_init_rx_data *rx_data,
-				      unsigned long *flags)
+				      uint32_t *flags)
  {
  	rx_data->tpa_en = ECORE_TEST_BIT(ECORE_Q_FLG_TPA, flags) *
  	    CLIENT_INIT_RX_DATA_TPA_EN_IPV4;
@@ -4421,7 +4421,7 @@ static int ecore_queue_chk_transition(struct bnx2x_softc *sc __rte_unused,
  	 * the previous one.
  	 */
  	if (o->pending) {
-		PMD_DRV_LOG(ERR, sc, "Blocking transition since pending was %lx",
+		PMD_DRV_LOG(ERR, sc, "Blocking transition since pending was %x",
  			    o->pending);
  		return ECORE_BUSY;
  	}
@@ -4630,7 +4630,7 @@ void ecore_init_queue_obj(struct bnx2x_softc *sc,
  			  struct ecore_queue_sp_obj *obj,
  			  uint8_t cl_id, uint32_t * cids, uint8_t cid_cnt,
  			  uint8_t func_id, void *rdata,
-			  ecore_dma_addr_t rdata_mapping, unsigned long type)
+			  ecore_dma_addr_t rdata_mapping, uint32_t type)
  {
  	ECORE_MEMSET(obj, 0, sizeof(*obj));
 
@@ -4699,11 +4699,11 @@ ecore_func_state_change_comp(struct bnx2x_softc *sc __rte_unused,
  			     struct ecore_func_sp_obj *o,
  			     enum ecore_func_cmd cmd)
  {
-	unsigned long cur_pending = o->pending;
+	uint32_t cur_pending = o->pending;
 
  	if (!ECORE_TEST_AND_CLEAR_BIT(cmd, &cur_pending)) {
  		PMD_DRV_LOG(ERR, sc,
-			    "Bad MC reply %d for func %d in state %d pending 0x%lx, next_state %d",
+			    "Bad MC reply %d for func %d in state %d pending 0x%x, next_state %d",
  			    cmd, ECORE_FUNC_ID(sc), o->state, cur_pending,
  			    o->next_state);
  		return ECORE_INVAL;
@@ -5311,7 +5311,7 @@ int ecore_func_state_change(struct bnx2x_softc *sc,
  	struct ecore_func_sp_obj *o = params->f_obj;
  	int rc, cnt = 300;
  	enum ecore_func_cmd cmd = params->cmd;
-	unsigned long *pending = &o->pending;
+	uint32_t *pending = &o->pending;
 
  	ECORE_MUTEX_LOCK(&o->one_pending_mutex);
 
drivers/net/bnx2x/ecore_sp.h +54 -52
index cc1db377a..d58072dac 100644
@@ -14,6 +14,7 @@
  #ifndef ECORE_SP_H
  #define ECORE_SP_H
 
+#include <rte_bitops.h>
  #include <rte_byteorder.h>
 
  #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
@@ -73,10 +74,11 @@ typedef rte_spinlock_t ECORE_MUTEX_SPIN;
  #define ECORE_SET_BIT_NA(bit, var)         (*var |= (1 << bit))
  #define ECORE_CLEAR_BIT_NA(bit, var)       (*var &= ~(1 << bit))
 
-#define ECORE_TEST_BIT(bit, var)           bnx2x_test_bit(bit, var)
-#define ECORE_SET_BIT(bit, var)            bnx2x_set_bit(bit, var)
-#define ECORE_CLEAR_BIT(bit, var)          bnx2x_clear_bit(bit, var)
-#define ECORE_TEST_AND_CLEAR_BIT(bit, var) bnx2x_test_and_clear_bit(bit, var)
+#define ECORE_TEST_BIT(bit, var)           rte_bit_relaxed_get32(bit, var)
+#define ECORE_SET_BIT(bit, var)            rte_bit_relaxed_set32(bit, var)
+#define ECORE_CLEAR_BIT(bit, var)          rte_bit_relaxed_clear32(bit, var)
+#define ECORE_TEST_AND_CLEAR_BIT(bit, var) \
+	rte_bit_relaxed_test_and_clear32(bit, var)
 
  #define atomic_load_acq_int                (int)*
  #define atomic_store_rel_int(a, v)         (*a = v)
@@ -485,7 +487,7 @@ struct ecore_raw_obj {
 
  	/* Ramrod state params */
  	int		state;   /* "ramrod is pending" state bit */
-	unsigned long	*pstate; /* pointer to state buffer */
+	uint32_t	*pstate; /* pointer to state buffer */
 
  	ecore_obj_type	obj_type;
 
@@ -538,7 +540,7 @@ struct ecore_vlan_mac_data {
  	/* used to contain the data related vlan_mac_flags bits from
  	 * ramrod parameters.
  	 */
-	unsigned long vlan_mac_flags;
+	uint32_t vlan_mac_flags;
 
  	/* Needed for MOVE command */
  	struct ecore_vlan_mac_obj *target_obj;
@@ -589,7 +591,7 @@ typedef int (*exe_q_optimize)(struct bnx2x_softc *sc,
  typedef int (*exe_q_execute)(struct bnx2x_softc *sc,
  			     union ecore_qable_obj *o,
  			     ecore_list_t *exe_chunk,
-			     unsigned long *ramrod_flags);
+			     uint32_t *ramrod_flags);
  typedef struct ecore_exeq_elem *
  			(*exe_q_get)(struct ecore_exe_queue_obj *o,
  				     struct ecore_exeq_elem *elem);
@@ -659,7 +661,7 @@ struct ecore_vlan_mac_registry_elem {
  	int			cam_offset;
 
  	/* Needed for DEL and RESTORE flows */
-	unsigned long		vlan_mac_flags;
+	uint32_t		vlan_mac_flags;
 
  	union ecore_classification_ramrod_data u;
  };
@@ -688,7 +690,7 @@ struct ecore_vlan_mac_ramrod_params {
  	struct ecore_vlan_mac_obj *vlan_mac_obj;
 
  	/* General command flags: COMP_WAIT, etc. */
-	unsigned long ramrod_flags;
+	uint32_t ramrod_flags;
 
  	/* Command specific configuration request */
  	struct ecore_vlan_mac_data user_req;
@@ -706,7 +708,7 @@ struct ecore_vlan_mac_obj {
  	 */
  	uint8_t		head_reader; /* Num. of readers accessing head list */
  	bool		head_exe_request; /* Pending execution request. */
-	unsigned long	saved_ramrod_flags; /* Ramrods of pending execution */
+	uint32_t	saved_ramrod_flags; /* Ramrods of pending execution */
 
  	/* Execution queue interface instance */
  	struct ecore_exe_queue_obj	exe_queue;
@@ -801,8 +803,8 @@ struct ecore_vlan_mac_obj {
  	 */
  	int (*delete_all)(struct bnx2x_softc *sc,
  			  struct ecore_vlan_mac_obj *o,
-			  unsigned long *vlan_mac_flags,
-			  unsigned long *ramrod_flags);
+			  uint32_t *vlan_mac_flags,
+			  uint32_t *ramrod_flags);
 
  	/**
  	 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
@@ -842,7 +844,7 @@ struct ecore_vlan_mac_obj {
  	 */
  	int (*complete)(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *o,
  			union event_ring_elem *cqe,
-			unsigned long *ramrod_flags);
+			uint32_t *ramrod_flags);
 
  	/**
  	 * Wait for completion of all commands. Don't schedule new ones,
@@ -883,13 +885,13 @@ enum {
 
  struct ecore_rx_mode_ramrod_params {
  	struct ecore_rx_mode_obj *rx_mode_obj;
-	unsigned long *pstate;
+	uint32_t *pstate;
  	int state;
  	uint8_t cl_id;
  	uint32_t cid;
  	uint8_t func_id;
-	unsigned long ramrod_flags;
-	unsigned long rx_mode_flags;
+	uint32_t ramrod_flags;
+	uint32_t rx_mode_flags;
 
  	/* rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
  	 * a tstorm_eth_mac_filter_config (e1x).
@@ -898,10 +900,10 @@ struct ecore_rx_mode_ramrod_params {
  	ecore_dma_addr_t rdata_mapping;
 
  	/* Rx mode settings */
-	unsigned long rx_accept_flags;
+	uint32_t rx_accept_flags;
 
  	/* internal switching settings */
-	unsigned long tx_accept_flags;
+	uint32_t tx_accept_flags;
  };
 
  struct ecore_rx_mode_obj {
@@ -928,7 +930,7 @@ struct ecore_mcast_ramrod_params {
  	struct ecore_mcast_obj *mcast_obj;
 
  	/* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
-	unsigned long ramrod_flags;
+	uint32_t ramrod_flags;
 
  	ecore_list_t mcast_list; /* list of struct ecore_mcast_list_elem */
  	/** TODO:
@@ -1144,22 +1146,22 @@ struct ecore_config_rss_params {
  	struct ecore_rss_config_obj *rss_obj;
 
  	/* may have RAMROD_COMP_WAIT set only */
-	unsigned long	ramrod_flags;
+	uint32_t ramrod_flags;
 
  	/* ECORE_RSS_X bits */
-	unsigned long	rss_flags;
+	uint32_t rss_flags;
 
  	/* Number hash bits to take into an account */
-	uint8_t		rss_result_mask;
+	uint8_t	 rss_result_mask;
 
  	/* Indirection table */
-	uint8_t		ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
+	uint8_t	 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
 
  	/* RSS hash values */
-	uint32_t		rss_key[10];
+	uint32_t rss_key[10];
 
  	/* valid only if ECORE_RSS_UPDATE_TOE is set */
-	uint16_t		toe_rss_bitmap;
+	uint16_t toe_rss_bitmap;
  };
 
  struct ecore_rss_config_obj {
@@ -1290,17 +1292,17 @@ enum ecore_q_type {
 
  struct ecore_queue_init_params {
  	struct {
-		unsigned long	flags;
-		uint16_t		hc_rate;
-		uint8_t		fw_sb_id;
-		uint8_t		sb_cq_index;
+		uint32_t flags;
+		uint16_t hc_rate;
+		uint8_t	 fw_sb_id;
+		uint8_t	 sb_cq_index;
  	} tx;
 
  	struct {
-		unsigned long	flags;
-		uint16_t		hc_rate;
-		uint8_t		fw_sb_id;
-		uint8_t		sb_cq_index;
+		uint32_t flags;
+		uint16_t hc_rate;
+		uint8_t	 fw_sb_id;
+		uint8_t	 sb_cq_index;
  	} rx;
 
  	/* CID context in the host memory */
@@ -1321,10 +1323,10 @@ struct ecore_queue_cfc_del_params {
  };
 
  struct ecore_queue_update_params {
-	unsigned long	update_flags; /* ECORE_Q_UPDATE_XX bits */
-	uint16_t		def_vlan;
-	uint16_t		silent_removal_value;
-	uint16_t		silent_removal_mask;
+	uint32_t	update_flags; /* ECORE_Q_UPDATE_XX bits */
+	uint16_t	def_vlan;
+	uint16_t	silent_removal_value;
+	uint16_t	silent_removal_mask;
  /* index within the tx_only cids of this queue object */
  	uint8_t		cid_index;
  };
@@ -1422,13 +1424,13 @@ struct ecore_queue_setup_params {
  	struct ecore_txq_setup_params txq_params;
  	struct ecore_rxq_setup_params rxq_params;
  	struct rxq_pause_params pause_params;
-	unsigned long flags;
+	uint32_t flags;
  };
 
  struct ecore_queue_setup_tx_only_params {
  	struct ecore_general_setup_params	gen_params;
  	struct ecore_txq_setup_params		txq_params;
-	unsigned long				flags;
+	uint32_t				flags;
  	/* index within the tx_only cids of this queue object */
  	uint8_t					cid_index;
  };
@@ -1440,7 +1442,7 @@ struct ecore_queue_state_params {
  	enum ecore_queue_cmd cmd;
 
  	/* may have RAMROD_COMP_WAIT set only */
-	unsigned long ramrod_flags;
+	uint32_t ramrod_flags;
 
  	/* Params according to the current command */
  	union {
@@ -1478,14 +1480,14 @@ struct ecore_queue_sp_obj {
  	enum ecore_q_state state, next_state;
 
  	/* bits from enum ecore_q_type */
-	unsigned long	type;
+	uint32_t	type;
 
  	/* ECORE_Q_CMD_XX bits. This object implements "one
  	 * pending" paradigm but for debug and tracing purposes it's
  	 * more convenient to have different bits for different
  	 * commands.
  	 */
-	unsigned long	pending;
+	uint32_t	pending;
 
  	/* Buffer to use as a ramrod data and its mapping */
  	void		*rdata;
@@ -1653,7 +1655,7 @@ struct ecore_func_start_params {
  };
 
  struct ecore_func_switch_update_params {
-	unsigned long changes; /* ECORE_F_UPDATE_XX bits */
+	uint32_t changes; /* ECORE_F_UPDATE_XX bits */
  	uint16_t vlan;
  	uint16_t vlan_eth_type;
  	uint8_t vlan_force_prio;
@@ -1704,7 +1706,7 @@ struct ecore_func_state_params {
  	enum ecore_func_cmd cmd;
 
  	/* may have RAMROD_COMP_WAIT set only */
-	unsigned long	ramrod_flags;
+	uint32_t ramrod_flags;
 
  	/* Params according to the current command */
  	union {
@@ -1753,7 +1755,7 @@ struct ecore_func_sp_obj {
  	 * more convenient to have different bits for different
  	 * commands.
  	 */
-	unsigned long		pending;
+	uint32_t		pending;
 
  	/* Buffer to use as a ramrod data and its mapping */
  	void			*rdata;
@@ -1821,7 +1823,7 @@ enum ecore_func_state ecore_func_get_state(struct bnx2x_softc *sc,
  void ecore_init_queue_obj(struct bnx2x_softc *sc,
  			  struct ecore_queue_sp_obj *obj, uint8_t cl_id, uint32_t *cids,
  			  uint8_t cid_cnt, uint8_t func_id, void *rdata,
-			  ecore_dma_addr_t rdata_mapping, unsigned long type);
+			  ecore_dma_addr_t rdata_mapping, uint32_t type);
 
  int ecore_queue_state_change(struct bnx2x_softc *sc,
  			     struct ecore_queue_state_params *params);
@@ -1834,7 +1836,7 @@ void ecore_init_mac_obj(struct bnx2x_softc *sc,
  			struct ecore_vlan_mac_obj *mac_obj,
  			uint8_t cl_id, uint32_t cid, uint8_t func_id, void *rdata,
  			ecore_dma_addr_t rdata_mapping, int state,
-			unsigned long *pstate, ecore_obj_type type,
+			uint32_t *pstate, ecore_obj_type type,
  			struct ecore_credit_pool_obj *macs_pool);
 
  void ecore_init_vlan_obj(struct bnx2x_softc *sc,
@@ -1842,7 +1844,7 @@ void ecore_init_vlan_obj(struct bnx2x_softc *sc,
  			 uint8_t cl_id, uint32_t cid, uint8_t func_id,
  			 void *rdata,
  			 ecore_dma_addr_t rdata_mapping, int state,
-			 unsigned long *pstate, ecore_obj_type type,
+			 uint32_t *pstate, ecore_obj_type type,
  			 struct ecore_credit_pool_obj *vlans_pool);
 
  void ecore_init_vlan_mac_obj(struct bnx2x_softc *sc,
@@ -1850,7 +1852,7 @@ void ecore_init_vlan_mac_obj(struct bnx2x_softc *sc,
  			     uint8_t cl_id, uint32_t cid, uint8_t func_id,
  			     void *rdata,
  			     ecore_dma_addr_t rdata_mapping, int state,
-			     unsigned long *pstate, ecore_obj_type type,
+			     uint32_t *pstate, ecore_obj_type type,
  			     struct ecore_credit_pool_obj *macs_pool,
  			     struct ecore_credit_pool_obj *vlans_pool);
 
@@ -1859,7 +1861,7 @@ void ecore_init_vxlan_fltr_obj(struct bnx2x_softc *sc,
  			       uint8_t cl_id, uint32_t cid, uint8_t func_id,
  			       void *rdata,
  			       ecore_dma_addr_t rdata_mapping, int state,
-			       unsigned long *pstate, ecore_obj_type type,
+			       uint32_t *pstate, ecore_obj_type type,
  			       struct ecore_credit_pool_obj *macs_pool,
  			       struct ecore_credit_pool_obj *vlans_pool);
 
@@ -1901,7 +1903,7 @@ void ecore_init_mcast_obj(struct bnx2x_softc *sc,
  			  struct ecore_mcast_obj *mcast_obj,
  			  uint8_t mcast_cl_id, uint32_t mcast_cid, uint8_t func_id,
  			  uint8_t engine_id, void *rdata, ecore_dma_addr_t rdata_mapping,
-			  int state, unsigned long *pstate,
+			  int state, uint32_t *pstate,
  			  ecore_obj_type type);
 
  /**
@@ -1943,7 +1945,7 @@ void ecore_init_rss_config_obj(struct bnx2x_softc *sc,
  			       struct ecore_rss_config_obj *rss_obj,
  			       uint8_t cl_id, uint32_t cid, uint8_t func_id, uint8_t engine_id,
  			       void *rdata, ecore_dma_addr_t rdata_mapping,
-			       int state, unsigned long *pstate,
+			       int state, uint32_t *pstate,
  			       ecore_obj_type type);
 
  /**
author
#137 lore raw

PATCH v10 5/6 net/qede: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/qede/base/bcm_osal.c          | 22 +------------
 drivers/net/qede/base/bcm_osal.h          | 14 ++++-----
 drivers/net/qede/base/ecore.h             |  6 ++--
 drivers/net/qede/base/ecore_cxt.c         |  6 ++--
 drivers/net/qede/base/ecore_dcbx.c        |  8 ++---
 drivers/net/qede/base/ecore_dev.c         | 38 +++++++++++------------
 drivers/net/qede/base/ecore_dev_api.h     |  2 +-
 drivers/net/qede/base/ecore_l2.c          |  6 ++--
 drivers/net/qede/base/ecore_mcp.c         |  4 +--
 drivers/net/qede/base/ecore_sp_commands.c | 12 +++----
 drivers/net/qede/base/ecore_spq.c         |  2 +-
 drivers/net/qede/base/ecore_spq.h         | 10 +++---
 drivers/net/qede/qede_main.c              |  4 +--
 13 files changed, 56 insertions(+), 78 deletions(-)
drivers/net/qede/base/bcm_osal.c +1 -21
index 48d016e24..54e5e4f98 100644
@@ -46,26 +46,6 @@ u32 qede_osal_log2(u32 val)
 	return log;
 }
 
-inline void qede_set_bit(u32 nr, unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-inline void qede_clr_bit(u32 nr, unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-inline bool qede_test_bit(u32 nr, unsigned long *addr)
-{
-	bool res;
-
-	rte_mb();
-	res = ((*addr) & (1UL << nr)) != 0;
-	rte_mb();
-	return res;
-}
-
 static inline u32 qede_ffb(unsigned long word)
 {
 	unsigned long first_bit;
@@ -95,7 +75,7 @@ static inline u32 qede_ffz(unsigned long word)
 	return first_zero ? (first_zero - 1) : OSAL_BITS_PER_UL;
 }
 
-inline u32 qede_find_first_zero_bit(unsigned long *addr, u32 limit)
+inline u32 qede_find_first_zero_bit(u32 *addr, u32 limit)
 {
 	u32 i;
 	u32 nwords = 0;
drivers/net/qede/base/bcm_osal.h +6 -8
index 8b2faec5b..88a2500a5 100644
@@ -8,6 +8,7 @@
 #define __BCM_OSAL_H
 
 #include <stdbool.h>
+#include <rte_bitops.h>
 #include <rte_byteorder.h>
 #include <rte_spinlock.h>
 #include <rte_malloc.h>
@@ -308,23 +309,20 @@ typedef struct osal_list_t {
 #define OSAL_BITS_PER_UL_MASK		(OSAL_BITS_PER_UL - 1)
 
 /* Bitops */
-void qede_set_bit(u32, unsigned long *);
 #define OSAL_SET_BIT(bit, bitmap) \
-	qede_set_bit(bit, bitmap)
+	rte_bit_relaxed_set32(bit, bitmap)
 
-void qede_clr_bit(u32, unsigned long *);
 #define OSAL_CLEAR_BIT(bit, bitmap) \
-	qede_clr_bit(bit, bitmap)
+	rte_bit_relaxed_clear32(bit, bitmap)
 
-bool qede_test_bit(u32, unsigned long *);
-#define OSAL_TEST_BIT(bit, bitmap) \
-	qede_test_bit(bit, bitmap)
+#define OSAL_GET_BIT(bit, bitmap) \
+	rte_bit_relaxed_get32(bit, bitmap)
 
 u32 qede_find_first_bit(unsigned long *, u32);
 #define OSAL_FIND_FIRST_BIT(bitmap, length) \
 	qede_find_first_bit(bitmap, length)
 
-u32 qede_find_first_zero_bit(unsigned long *, u32);
+u32 qede_find_first_zero_bit(u32 *bitmap, u32 length);
 #define OSAL_FIND_FIRST_ZERO_BIT(bitmap, length) \
 	qede_find_first_zero_bit(bitmap, length)
 
drivers/net/qede/base/ecore.h +3 -3
index b2077bc46..498bb6f09 100644
@@ -422,8 +422,8 @@ struct ecore_hw_info {
 	u8 max_chains_per_vf;
 
 	u32 port_mode;
-	u32	hw_mode;
-	unsigned long device_capabilities;
+	u32 hw_mode;
+	u32 device_capabilities;
 
 	/* Default DCBX mode */
 	u8 dcbx_mode;
@@ -807,7 +807,7 @@ struct ecore_dev {
 
 	u8				path_id;
 
-	unsigned long			mf_bits;
+	u32				mf_bits;
 	enum ecore_mf_mode		mf_mode;
 #define IS_MF_DEFAULT(_p_hwfn)	\
 	(((_p_hwfn)->p_dev)->mf_mode == ECORE_MF_DEFAULT)
drivers/net/qede/base/ecore_cxt.c +3 -3
index 773b75ecd..dda47ea67 100644
@@ -154,7 +154,7 @@ struct ecore_ilt_client_cfg {
 struct ecore_cid_acquired_map {
 	u32 start_cid;
 	u32 max_count;
-	unsigned long *cid_map;
+	u32 *cid_map;
 };
 
 struct ecore_src_t2 {
@@ -1991,7 +1991,7 @@ static bool ecore_cxt_test_cid_acquired(struct ecore_hwfn *p_hwfn,
 	}
 
 	rel_cid = cid - (*pp_map)->start_cid;
-	if (!OSAL_TEST_BIT(rel_cid, (*pp_map)->cid_map)) {
+	if (!OSAL_GET_BIT(rel_cid, (*pp_map)->cid_map)) {
 		DP_NOTICE(p_hwfn, true,
 			  "CID %d [vifd %02x] not acquired", cid, vfid);
 		goto fail;
@@ -2102,7 +2102,7 @@ enum _ecore_status_t ecore_cxt_set_pf_params(struct ecore_hwfn *p_hwfn)
 
 		count = p_params->num_arfs_filters;
 
-		if (!OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS,
+		if (!OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS,
 				   &p_hwfn->p_dev->mf_bits))
 			p_hwfn->p_cxt_mngr->arfs_count = count;
 
drivers/net/qede/base/ecore_dcbx.c +4 -4
index ccd4383bb..31234f18c 100644
@@ -148,7 +148,7 @@ ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
 	p_data->arr[type].update = UPDATE_DCB_DSCP;
 
 	/* Do not add valn tag 0 when DCB is enabled and port is in UFP mode */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		p_data->arr[type].dont_add_vlan0 = true;
 
 	/* QM reconf data */
@@ -156,8 +156,8 @@ ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
 		p_hwfn->hw_info.offload_tc = tc;
 
 	/* Configure dcbx vlan priority in doorbell block for roce EDPM */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits) &&
-	    (type == DCBX_PROTOCOL_ROCE)) {
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits) &&
+	    type == DCBX_PROTOCOL_ROCE) {
 		ecore_wr(p_hwfn, p_ptt, DORQ_REG_TAG1_OVRD_MODE, 1);
 		ecore_wr(p_hwfn, p_ptt, DORQ_REG_PF_PCP, prio << 1);
 	}
@@ -293,7 +293,7 @@ ecore_dcbx_process_tlv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	}
 
 	/* If Eth TLV is not detected, use UFP TC as default TC */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC,
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC,
 			  &p_hwfn->p_dev->mf_bits) && !eth_tlv)
 		p_data->arr[DCBX_PROTOCOL_ETH].tc = p_hwfn->ufp_info.tc;
 
drivers/net/qede/base/ecore_dev.c +19 -19
index 86ecfb269..e18c2fa89 100644
@@ -805,7 +805,7 @@ static enum _ecore_status_t ecore_llh_hw_init_pf(struct ecore_hwfn *p_hwfn,
 		ecore_wr(p_hwfn, p_ptt, addr, p_hwfn->rel_pf_id);
 	}
 
-	if (OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
+	if (OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
 	    !ECORE_IS_FCOE_PERSONALITY(p_hwfn)) {
 		rc = ecore_llh_add_mac_filter(p_dev, 0,
 					      p_hwfn->hw_info.hw_mac_addr);
@@ -1044,7 +1044,7 @@ ecore_llh_add_filter(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	filter_details.enable = 1;
 	filter_details.value = ((u64)high << 32) | low;
 	filter_details.hdr_sel =
-		OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits) ?
+		OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits) ?
 		1 : /* inner/encapsulated header */
 		0;  /* outer/tunnel header */
 	filter_details.protocol_type = filter_prot_type;
@@ -1083,7 +1083,7 @@ enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return ECORE_AGAIN;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	OSAL_MEM_ZERO(&filter, sizeof(filter));
@@ -1220,7 +1220,7 @@ ecore_llh_add_protocol_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return ECORE_AGAIN;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_llh_protocol_filter_stringify(p_dev, type,
@@ -1287,7 +1287,7 @@ void ecore_llh_remove_mac_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	OSAL_MEM_ZERO(&filter, sizeof(filter));
@@ -1342,7 +1342,7 @@ void ecore_llh_remove_protocol_filter(struct ecore_dev *p_dev, u8 ppfid,
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_llh_protocol_filter_stringify(p_dev, type,
@@ -1396,8 +1396,8 @@ void ecore_llh_clear_ppfid_filters(struct ecore_dev *p_dev, u8 ppfid)
 	if (p_ptt == OSAL_NULL)
 		return;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
-	    !OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
+	    !OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		goto out;
 
 	rc = ecore_abs_ppfid(p_dev, ppfid, &abs_ppfid);
@@ -1423,8 +1423,8 @@ void ecore_llh_clear_all_filters(struct ecore_dev *p_dev)
 {
 	u8 ppfid;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
-	    !OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_LLH_PROTO_CLSS, &p_dev->mf_bits) &&
+	    !OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits))
 		return;
 
 	for (ppfid = 0; ppfid < p_dev->p_llh_info->num_ppfid; ppfid++)
@@ -2674,7 +2674,7 @@ static enum _ecore_status_t ecore_calc_hw_mode(struct ecore_hwfn *p_hwfn)
 		return ECORE_INVAL;
 	}
 
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
 		hw_mode |= 1 << MODE_MF_SD;
 	else
 		hw_mode |= 1 << MODE_MF_SI;
@@ -3382,7 +3382,7 @@ static enum _ecore_status_t ecore_hw_init_port(struct ecore_hwfn *p_hwfn,
 		 * The ppfid should be set in the vector, except in BB which has
 		 * a bug in the LLH where the ppfid is actually engine based.
 		 */
-		if (OSAL_TEST_BIT(ECORE_MF_NEED_DEF_PF, &p_dev->mf_bits)) {
+		if (OSAL_GET_BIT(ECORE_MF_NEED_DEF_PF, &p_dev->mf_bits)) {
 			u8 pf_id = p_hwfn->rel_pf_id;
 
 			if (!ECORE_IS_BB(p_dev))
@@ -3715,11 +3715,11 @@ enum _ecore_status_t ecore_hw_init(struct ecore_dev *p_dev,
 		if (rc != ECORE_SUCCESS)
 			return rc;
 
-		if (IS_PF(p_dev) && (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING,
+		if (IS_PF(p_dev) && (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING,
 						   &p_dev->mf_bits) ||
-				     OSAL_TEST_BIT(ECORE_MF_8021AD_TAGGING,
+				     OSAL_GET_BIT(ECORE_MF_8021AD_TAGGING,
 						   &p_dev->mf_bits))) {
-			if (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING,
+			if (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING,
 					  &p_dev->mf_bits))
 				ether_type = ETHER_TYPE_VLAN;
 			else
@@ -4119,7 +4119,7 @@ enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev)
 		OSAL_MSLEEP(1);
 
 		if (IS_LEAD_HWFN(p_hwfn) &&
-		    OSAL_TEST_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
+		    OSAL_GET_BIT(ECORE_MF_LLH_MAC_CLSS, &p_dev->mf_bits) &&
 		    !ECORE_IS_FCOE_PERSONALITY(p_hwfn))
 			ecore_llh_remove_mac_filter(p_dev, 0,
 						   p_hwfn->hw_info.hw_mac_addr);
@@ -5113,7 +5113,7 @@ ecore_hw_get_nvm_info(struct ecore_hwfn *p_hwfn,
 			p_hwfn->p_dev->mf_bits |= 1 << ECORE_MF_NEED_DEF_PF;
 		break;
 	}
-	DP_INFO(p_hwfn, "Multi function mode is 0x%lx\n",
+	DP_INFO(p_hwfn, "Multi function mode is 0x%x\n",
 		p_hwfn->p_dev->mf_bits);
 
 	if (ECORE_IS_CMT(p_hwfn->p_dev))
@@ -6218,7 +6218,7 @@ enum _ecore_status_t
 ecore_llh_set_function_as_default(struct ecore_hwfn *p_hwfn,
 				  struct ecore_ptt *p_ptt)
 {
-	if (OSAL_TEST_BIT(ECORE_MF_NEED_DEF_PF, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_NEED_DEF_PF, &p_hwfn->p_dev->mf_bits)) {
 		ecore_wr(p_hwfn, p_ptt,
 			 NIG_REG_LLH_TAGMAC_DEF_PF_VECTOR,
 			 1 << p_hwfn->abs_pf_id / 2);
@@ -6795,5 +6795,5 @@ void ecore_set_fw_mac_addr(__le16 *fw_msb,
 
 bool ecore_is_mf_fip_special(struct ecore_dev *p_dev)
 {
-	return !!OSAL_TEST_BIT(ECORE_MF_FIP_SPECIAL, &p_dev->mf_bits);
+	return !!OSAL_GET_BIT(ECORE_MF_FIP_SPECIAL, &p_dev->mf_bits);
 }
drivers/net/qede/base/ecore_dev_api.h +1 -1
index 5ea8427a0..9ddf502eb 100644
@@ -212,7 +212,7 @@ enum _ecore_status_t ecore_db_recovery_del(struct ecore_dev *p_dev,
 
 static OSAL_INLINE bool ecore_is_mf_ufp(struct ecore_hwfn *p_hwfn)
 {
-	return !!OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits);
+	return !!OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits);
 }
 
 #endif
drivers/net/qede/base/ecore_l2.c +3 -3
index b20d83762..af234dec8 100644
@@ -29,7 +29,7 @@
 
 struct ecore_l2_info {
 	u32 queues;
-	unsigned long **pp_qid_usage;
+	u32 **pp_qid_usage;
 
 	/* The lock is meant to synchronize access to the qid usage */
 	osal_mutex_t lock;
@@ -38,7 +38,7 @@ struct ecore_l2_info {
 enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn)
 {
 	struct ecore_l2_info *p_l2_info;
-	unsigned long **pp_qids;
+	u32 **pp_qids;
 	u32 i;
 
 	if (!ECORE_IS_L2_PERSONALITY(p_hwfn))
@@ -2116,7 +2116,7 @@ void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn,
 			       struct ecore_ptt *p_ptt,
 			       struct ecore_arfs_config_params *p_cfg_params)
 {
-	if (OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS, &p_hwfn->p_dev->mf_bits))
 		return;
 
 	if (p_cfg_params->mode != ECORE_FILTER_CONFIG_MODE_DISABLE) {
drivers/net/qede/base/ecore_mcp.c +2 -2
index 7518765a0..a7485967b 100644
@@ -1732,7 +1732,7 @@ static void ecore_mcp_update_stag(struct ecore_hwfn *p_hwfn,
 	p_hwfn->mcp_info->func_info.ovlan = (u16)shmem_info.ovlan_stag &
 						 FUNC_MF_CFG_OV_STAG_MASK;
 	p_hwfn->hw_info.ovlan = p_hwfn->mcp_info->func_info.ovlan;
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits)) {
 		if (p_hwfn->hw_info.ovlan != ECORE_MCP_VLAN_UNSET) {
 			ecore_wr(p_hwfn, p_ptt, NIG_REG_LLH_FUNC_TAG_VALUE,
 				 p_hwfn->hw_info.ovlan);
@@ -2026,7 +2026,7 @@ ecore_mcp_read_ufp_config(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
 	struct public_func shmem_info;
 	u32 port_cfg, val;
 
-	if (!OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (!OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		return;
 
 	OSAL_MEMSET(&p_hwfn->ufp_info, 0, sizeof(p_hwfn->ufp_info));
drivers/net/qede/base/ecore_sp_commands.c +6 -6
index 9860a62b5..44ced135d 100644
@@ -335,16 +335,16 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	p_ramrod->dont_log_ramrods = 0;
 	p_ramrod->log_type_mask = OSAL_CPU_TO_LE16(0x8f);
 
-	if (OSAL_TEST_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
 		p_ramrod->mf_mode = MF_OVLAN;
 	else
 		p_ramrod->mf_mode = MF_NPAR;
 
 	p_ramrod->outer_tag_config.outer_tag.tci =
 		OSAL_CPU_TO_LE16(p_hwfn->hw_info.ovlan);
-	if (OSAL_TEST_BIT(ECORE_MF_8021Q_TAGGING, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING, &p_hwfn->p_dev->mf_bits)) {
 		p_ramrod->outer_tag_config.outer_tag.tpid = ETH_P_8021Q;
-	} else if (OSAL_TEST_BIT(ECORE_MF_8021AD_TAGGING,
+	} else if (OSAL_GET_BIT(ECORE_MF_8021AD_TAGGING,
 		 &p_hwfn->p_dev->mf_bits)) {
 		p_ramrod->outer_tag_config.outer_tag.tpid = ETH_P_8021AD;
 		p_ramrod->outer_tag_config.enable_stag_pri_change = 1;
@@ -357,7 +357,7 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	/* enable_stag_pri_change should be set if port is in BD mode or,
 	 * UFP with Host Control mode.
 	 */
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits)) {
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits)) {
 		if (p_hwfn->ufp_info.pri_type == ECORE_UFP_PRI_OS)
 			p_ramrod->outer_tag_config.enable_stag_pri_change = 1;
 		else
@@ -378,7 +378,7 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 	ecore_tunn_set_pf_start_params(p_hwfn, p_tunn,
 				       &p_ramrod->tunnel_config);
 
-	if (OSAL_TEST_BIT(ECORE_MF_INTER_PF_SWITCH,
+	if (OSAL_GET_BIT(ECORE_MF_INTER_PF_SWITCH,
 			  &p_hwfn->p_dev->mf_bits))
 		p_ramrod->allow_npar_tx_switching = allow_npar_tx_switch;
 
@@ -638,7 +638,7 @@ enum _ecore_status_t ecore_sp_heartbeat_ramrod(struct ecore_hwfn *p_hwfn)
 	if (rc != ECORE_SUCCESS)
 		return rc;
 
-	if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
+	if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
 		p_ent->ramrod.pf_update.mf_vlan |=
 			OSAL_CPU_TO_LE16(((u16)p_hwfn->ufp_info.tc << 13));
 
drivers/net/qede/base/ecore_spq.c +1 -1
index 6c386821f..02f613688 100644
@@ -977,7 +977,7 @@ enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
 			 * for the first successive completed entries.
 			 */
 			SPQ_COMP_BMAP_SET_BIT(p_spq, echo);
-			while (SPQ_COMP_BMAP_TEST_BIT(p_spq,
+			while (SPQ_COMP_BMAP_GET_BIT(p_spq,
 						      p_spq->comp_bitmap_idx)) {
 				SPQ_COMP_BMAP_CLEAR_BIT(p_spq,
 							p_spq->comp_bitmap_idx);
drivers/net/qede/base/ecore_spq.h +5 -5
index 6142c399a..0958e5a0a 100644
@@ -121,17 +121,17 @@ struct ecore_spq {
 #define SPQ_RING_SIZE		\
 	(CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element))
 /* BITS_PER_LONG */
-#define SPQ_COMP_BMAP_SIZE	(SPQ_RING_SIZE / (sizeof(unsigned long) * 8))
-	unsigned long			p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
-	u8				comp_bitmap_idx;
+#define SPQ_COMP_BMAP_SIZE	(SPQ_RING_SIZE / (sizeof(u32) * 8))
+	u32			p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
+	u8			comp_bitmap_idx;
 #define SPQ_COMP_BMAP_SET_BIT(p_spq, idx)				\
 	(OSAL_SET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
 #define SPQ_COMP_BMAP_CLEAR_BIT(p_spq, idx)				\
 	(OSAL_CLEAR_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
-#define SPQ_COMP_BMAP_TEST_BIT(p_spq, idx)	\
-	(OSAL_TEST_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
+#define SPQ_COMP_BMAP_GET_BIT(p_spq, idx)	\
+	(OSAL_GET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
 
 	/* Statistics */
 	u32				unlimited_pending_count;
drivers/net/qede/qede_main.c +2 -2
index 8580cbcd7..bd63c0ac7 100644
@@ -382,8 +382,8 @@ qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info)
 
 	if (IS_PF(edev)) {
 		dev_info->b_inter_pf_switch =
-			OSAL_TEST_BIT(ECORE_MF_INTER_PF_SWITCH, &edev->mf_bits);
-		if (!OSAL_TEST_BIT(ECORE_MF_DISABLE_ARFS, &edev->mf_bits))
+			OSAL_GET_BIT(ECORE_MF_INTER_PF_SWITCH, &edev->mf_bits);
+		if (!OSAL_GET_BIT(ECORE_MF_DISABLE_ARFS, &edev->mf_bits))
 			dev_info->b_arfs_capable = true;
 		dev_info->tx_switching = false;
 
Signature · 1 line
2.17.1
author
#138 lore raw

PATCH v10 6/6 net/hinic: use common rte bit operation APIs instead

In reply to Joyce Kong

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---
 drivers/net/hinic/Makefile            |  1 +
 drivers/net/hinic/base/hinic_compat.h | 33 +--------------------------
 drivers/net/hinic/hinic_pmd_ethdev.c  | 18 ++++++++-------
 drivers/net/hinic/hinic_pmd_ethdev.h  |  2 +-
 drivers/net/hinic/meson.build         |  2 ++
 5 files changed, 15 insertions(+), 41 deletions(-)
drivers/net/hinic/Makefile +1 -0
index 87fd843e4..f087baac5 100644
@@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 LIB = librte_pmd_hinic.a
 
 CFLAGS += -O3
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 ifeq ($(CONFIG_RTE_ARCH_ARM64),y)
drivers/net/hinic/base/hinic_compat.h +1 -32
index 921b83012..2d21b7b67 100644
@@ -10,6 +10,7 @@
 #include <unistd.h>
 #include <pthread.h>
 #include <rte_common.h>
+#include <rte_bitops.h>
 #include <rte_byteorder.h>
 #include <rte_memzone.h>
 #include <rte_memcpy.h>
@@ -116,38 +117,6 @@ extern int hinic_logtype;
 
 #define HINIC_PAGE_SIZE_DPDK	6
 
-static inline int hinic_test_bit(int nr, volatile unsigned long *addr)
-{
-	int res;
-
-	res = ((*addr) & (1UL << nr)) != 0;
-	return res;
-}
-
-static inline void hinic_set_bit(unsigned int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_or(addr, (1UL << nr));
-}
-
-static inline void hinic_clear_bit(int nr, volatile unsigned long *addr)
-{
-	__sync_fetch_and_and(addr, ~(1UL << nr));
-}
-
-static inline int hinic_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 int hinic_test_and_set_bit(int nr, volatile unsigned long *addr)
-{
-	unsigned long mask = (1UL << nr);
-
-	return __sync_fetch_and_or(addr, mask) & mask;
-}
-
 void *dma_zalloc_coherent(void *dev, size_t size, dma_addr_t *dma_handle,
 			  unsigned int socket_id);
 
drivers/net/hinic/hinic_pmd_ethdev.c +10 -8
index cfbca6405..dbf79b19c 100644
@@ -271,7 +271,7 @@ static void hinic_dev_interrupt_handler(void *param)
 	struct rte_eth_dev *dev = param;
 	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	if (!hinic_test_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status)) {
+	if (!rte_bit_relaxed_get32(HINIC_DEV_INTR_EN, &nic_dev->dev_status)) {
 		PMD_DRV_LOG(WARNING, "Device's interrupt is disabled, ignore interrupt event, dev_name: %s, port_id: %d",
 			    nic_dev->proc_dev_name, dev->data->port_id);
 		return;
@@ -1067,7 +1067,7 @@ static int hinic_dev_start(struct rte_eth_dev *dev)
 	if (dev->data->dev_conf.intr_conf.lsc != 0)
 		(void)hinic_link_update(dev, 0);
 
-	hinic_set_bit(HINIC_DEV_START, &nic_dev->dev_status);
+	rte_bit_relaxed_set32(HINIC_DEV_START, &nic_dev->dev_status);
 
 	return 0;
 
@@ -1192,7 +1192,8 @@ static void hinic_dev_stop(struct rte_eth_dev *dev)
 	name = dev->data->name;
 	port_id = dev->data->port_id;
 
-	if (!hinic_test_and_clear_bit(HINIC_DEV_START, &nic_dev->dev_status)) {
+	if (!rte_bit_relaxed_test_and_clear32(HINIC_DEV_START,
+					      &nic_dev->dev_status)) {
 		PMD_DRV_LOG(INFO, "Device %s already stopped", name);
 		return;
 	}
@@ -1237,7 +1238,7 @@ static void hinic_disable_interrupt(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	int ret, retries = 0;
 
-	hinic_clear_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
+	rte_bit_relaxed_clear32(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
 
 	/* disable msix interrupt in hardware */
 	hinic_set_msix_state(nic_dev->hwdev, 0, HINIC_MSIX_DISABLE);
@@ -2915,7 +2916,8 @@ static void hinic_dev_close(struct rte_eth_dev *dev)
 {
 	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	if (hinic_test_and_set_bit(HINIC_DEV_CLOSE, &nic_dev->dev_status)) {
+	if (rte_bit_relaxed_test_and_set32(HINIC_DEV_CLOSE,
+					   &nic_dev->dev_status)) {
 		PMD_DRV_LOG(WARNING, "Device %s already closed",
 			    dev->data->name);
 		return;
@@ -3115,7 +3117,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 			    eth_dev->data->name);
 		goto enable_intr_fail;
 	}
-	hinic_set_bit(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
+	rte_bit_relaxed_set32(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
 
 	/* initialize filter info */
 	filter_info = &nic_dev->filter;
@@ -3130,7 +3132,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 	TAILQ_INIT(&nic_dev->filter_fdir_rule_list);
 	TAILQ_INIT(&nic_dev->hinic_flow_list);
 
-	hinic_set_bit(HINIC_DEV_INIT, &nic_dev->dev_status);
+	rte_bit_relaxed_set32(HINIC_DEV_INIT, &nic_dev->dev_status);
 	PMD_DRV_LOG(INFO, "Initialize %s in primary successfully",
 		    eth_dev->data->name);
 
@@ -3186,7 +3188,7 @@ static int hinic_dev_uninit(struct rte_eth_dev *dev)
 	struct hinic_nic_dev *nic_dev;
 
 	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
-	hinic_clear_bit(HINIC_DEV_INIT, &nic_dev->dev_status);
+	rte_bit_relaxed_clear32(HINIC_DEV_INIT, &nic_dev->dev_status);
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
drivers/net/hinic/hinic_pmd_ethdev.h +1 -1
index 3322fb90b..42c40c382 100644
@@ -274,7 +274,7 @@ struct hinic_nic_dev {
 	unsigned int flags;
 	struct nic_service_cap nic_cap;
 	u32 rx_mode_status;	/* promisc or allmulticast */
-	unsigned long dev_status;
+	u32 dev_status;
 
 	char proc_dev_name[HINIC_DEV_NAME_LEN];
 	/* PF0->COS4, PF1->COS5, PF2->COS6, PF3->COS7,
drivers/net/hinic/meson.build +2 -0
index bc7e24639..8c7ee9dfc 100644
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Huawei Technologies Co., Ltd
 
+allow_experimental_apis = true
+
 subdir('base')
 objs = [base_objs]
 
Signature · 1 line
2.17.1
#139 lore raw

Re: [dpdk-dev] [PATCH v10 6/6] net/hinic: use common rte bit operation APIs instead

27/04/2020 09:58, Joyce Kong:

Quoted 9 lines

Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.

---

drivers/net/hinic/Makefile +1 -0
+CFLAGS += -DALLOW_EXPERIMENTAL_API

[...]

drivers/net/hinic/meson.build line 4

Quoted 3 lines
drivers/net/hinic/meson.build +1 -0
+allow_experimental_apis = true

Not needed in DPDK 20.08.
I will remove it while merging.

#140 lore raw

Re: [dpdk-dev] [PATCH v10 0/6] implement common bit operation APIs

In reply to Joyce Kong

27/04/2020 09:58, Joyce Kong:

Quoted 7 lines

Joyce Kong (6):
lib/eal: implement the family of common bit operation APIs test/bitops: add bit operation test case net/axgbe: use common rte bit operation APIs instead net/bnx2x: use common rte bit operation APIs instead net/qede: use common rte bit operation APIs instead net/hinic: use common rte bit operation APIs instead

There was no comment on replacement in PMDs (axgbe, bnx2x, qede, hinic).

Applied, thanks