implement common rte bit operation APIs in PMDs
Subsystems (2)
cover implement common rte bit operation APIs in PMDs
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
Joyce Kong (5):
lib/eal: implement the family of rte bit operation APIs net/axgbe: use common rte bit operation APIs instead net/bnx2x: use common rte bit operation APIs instead net/hinic: use common rte bit operation APIs instead net/qede: use common rte bit operation APIs instead
drivers/net/axgbe/axgbe_common.h | 29 +---- drivers/net/axgbe/axgbe_ethdev.c | 14 +- drivers/net/axgbe/axgbe_mdio.c | 14 +- drivers/net/bnx2x/bnx2x.c | 202 +++++++++++++---------------- drivers/net/bnx2x/bnx2x.h | 5 +- drivers/net/bnx2x/ecore_sp.h | 8 +- drivers/net/hinic/base/hinic_compat.h | 35 +---- drivers/net/hinic/hinic_pmd_ethdev.c | 16 +-- drivers/net/qede/base/bcm_osal.c | 20 --- drivers/net/qede/base/bcm_osal.h | 10 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++ lib/librte_eal/common/meson.build | 1 + 13 files changed, 180 insertions(+), 231 deletions(-) create mode 100644 lib/librte_eal/common/include/rte_bitops.h
Signature · 1 line
2.7.4
PATCH 1/5 lib/eal: implement the family of rte bit operation APIs
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use __ATOMIC_ACQ_REL to ensure the ordering.
--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 58 insertions(+) create mode 100644 lib/librte_eal/common/include/rte_bitops.h
lib/librte_eal/common/Makefile +1 -0
@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h +INC += rte_bitops.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.h
lib/librte_eal/common/include/rte_bitops.h new file +56 -0
56 lines not on this page · raw message
lib/librte_eal/common/meson.build +1 -0
@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', + 'include/rte_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h',
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bit operation APIs
Quoted 28 lines · On Tue, 15 Oct 2019 15:49:57 +0800 Joyce Kong <[email protected]> wrote:
lib/librte_eal/common/include/rte_bitops.h new file +28
-0+static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) +{ +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); +} + +static inline void +rte_clear_bit (int nr,unsigned long *addr) +{ +__atomic_fetch_and (addr, ~(1UL << nr), __ATOMIC_ACQ_REL); +} + +static inline int +rte_test_bit (int nr,unsigned long *addr) +{ +int res; +rte_mb (); + res = ((*addr) & (1UL << nr)) !=0 ; +rte_mb (); + +return res; +} + +static inline int +rte_test_and_set_bit (int nr,unsigned long *addr) +{ +unsigned long mask = (1UL << nr); +
lib/librte_eal/common/include/rte_bitops.h line 55
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h new file +10
-0+return __atomic_fetch_or (addr, mask, __ATOMIC_ACQ_REL) & mask; +} + +static inline int +rte_test_and_clear_bit (int nr,unsigned long *addr) +{ +unsigned long mask = (1UL << nr); + +return __atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL) & mask; +}
These functions need to be part of API, and have doxygen comments?
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bit operation APIs
Quoted 48 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, October 16, 2019 12:54 AM
To: Joyce Kong (Arm Technology China) <[email protected]>
Cc: [email protected]; nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bit operation APIsQuoted 13 lines · On Tue, 15 Oct 2019 15:49:57 +0800 Joyce Kong <[email protected]> wrote:
lib/librte_eal/common/include/rte_bitops.h new file +13
-0+static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); } + +static inline void +rte_clear_bit (int nr,unsigned long *addr) { +__atomic_fetch_and (addr, ~(1UL << nr), __ATOMIC_ACQ_REL); } + +static inline int +rte_test_bit (int nr,unsigned long *addr) { +int res; +rte_mb (); + res = ((*addr) & (1UL << nr)) !=0 ;lib/librte_eal/common/include/rte_bitops.h
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h new file +10
-0+rte_mb (); + +return res; +} + +static inline int +rte_test_and_set_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_clear_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_and(addr, ~mask, __ATOMIC_ACQ_REL) &mask; }
Quoted 1 line
These functions need to be part of API, and have doxygen comments?
Will add doxygen comments in next version.
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bit operation APIs
In reply to Joyce KongQuoted 12 lines · Joyce Kong
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use
__ATOMIC_ACQ_RELto ensure the ordering.Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 +
lib/librte_eal/common/include/rte_bitops.h line 22
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) +{ +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); +}
If it is specific for IO the IMO, it makes sense call the API to rte_io_set_bit() like rte_io_rmb
and change the header file to rte_io_bitops.h.
The barries are only needed for IO operations. Explicitly is not conveying it in API name
would call for using it for normal cases.
Other option could be to introduce, generic and IO specific bit operations operations
separately.
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bit operation APIs
Quoted 37 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Wednesday, October 16, 2019 3:54 PM
To: Joyce Kong (Arm Technology China) <[email protected]>
Cc: dpdk-dev <[email protected]>; nd <[email protected]>; [email protected]; [email protected]; [email protected]; Ziyang Xuan <[email protected]>; Xiaoyun Wang <[email protected]>; Guoyang Zhou <[email protected]>; Rasesh Mody <[email protected]>; Shahed Shaikh <[email protected]>; Honnappa Nagarahalli <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bit operation APIsQuoted 10 lines · Joyce Kong
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use
__ATOMIC_ACQ_RELto ensure the ordering.Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56++++++++++++++++++++++++++++++
lib/librte_eal/common/include/rte_bitops.h
Quoted 5 lines
lib/librte_eal/common/meson.build | 1 +lib/librte_eal/common/include/rte_bitops.h new file +4
-0+ +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); }If it is specific for IO the IMO, it makes sense call the API to
rte_io_set_bit()likerte_io_rmb
and change the header file torte_io_bitops.h.
Quoted 5 lines
The barries are only needed for IO operations. Explicitly is not conveying it in API name would call for using it for normal cases.
Other option could be to introduce, generic and IO specific bit operations operations separately.
Would do some related changes in next version.
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bit operation APIs
Quoted 22 lines
Quoted 22 lines · Joyce Kong
Quoted 10 lines
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use
__ATOMIC_ACQ_RELto ensure the ordering.Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56++++++++++++++++++++++++++++++
lib/librte_eal/common/include/rte_bitops.h
Quoted 5 lines
lib/librte_eal/common/meson.build | 1 +lib/librte_eal/common/include/rte_bitops.h new file +4
-0+ +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); }If it is specific for IO the IMO, it makes sense call the API to
rte_io_set_bit()likerte_io_rmb
and change the header file torte_io_bitops.h.
Quoted 7 lines
Quoted 5 lines
The barries are only needed for IO operations. Explicitly is not conveying it in API name would call for using it for normal cases.
Other option could be to introduce, generic and IO specific bit operations operations separately.
Would do some related changes in next version.
As bit operations are mostly applied to IO devices, change the header file to rte_io_bitops.h to introduce IO specific bit operations now. And do this change in v2.
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bit operation APIs
In reply to Joyce KongQuoted 7 lines · On Tue, 15 Oct 2019 15:49:57 +0800 Joyce Kong <[email protected]> wrote:
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use
__ATOMIC_ACQ_RELto ensure the ordering.Signed-off-by Joyce Kong <[email protected]>
'include/rte_common.h',
Patchwork reports several build failures for this patch set.
/tmp/UB1604-64_K4.4.0_Clang3.8.0/x86_64-native-linuxapp-clang/62c86b2c1091439598f2f1688566632c/dpdk/x86_64-native-linuxapp-clang/lib/librte_pmd_bnx2x.a(bnx2x.o): In function `bnx2x_set_storm_rx_mode':
/tmp/UB1604-64_K4.4.0_Clang3.8.0/x86_64-native-linuxapp-clang/62c86b2c1091439598f2f1688566632c/dpdk/drivers/net/bnx2x/bnx2x.c:(.text+0x1602): undefined reference to `ret_set_bit'
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIs
In reply to Joyce KongQuoted 9 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong
Sent: Tuesday, October 15, 2019 9:50 AMThere are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use
__ATOMIC_ACQ_RELto ensure the ordering.
Good initiative.
Quoted 60 lines
Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 58 insertions(+) create mode 100644 lib/librte_eal/common/include/rte_bitops.hlib/librte_eal/common/Makefile +1
-0@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h +INC += rte_bitops.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h
rte_prefetch.h
GENERIC_INC+=rte_memcpy.hrte_cpuflags.hlib/librte_eal/common/include/rte_bitops.h new file +29
-0@@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Corporation +*/ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a generic API for bit operations. +*/ + +#include <stdint.h> +#include <rte_atomic.h> + +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) +{ +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); +} + +static inline void +rte_clear_bit (int nr,unsigned long *addr) +{ +__atomic_fetch_and (addr, ~(1UL << nr), __ATOMIC_ACQ_REL); +} +
lib/librte_eal/common/include/rte_bitops.h line 39
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h new file +10
-0+static inline int +rte_test_bit (int nr,unsigned long *addr) +{ +int res; +rte_mb (); + res = ((*addr) & (1UL << nr)) !=0 ; +rte_mb (); + +return res; +}
Why does rte_test_bit() not use any of the __atomic_xx functions instead? E.g.:
static inline intrte_test_bit(int nr, unsigned long *addr)
{
return __atomic_load_n(addr, __ATOMIC_ACQUIRE);
}Quoted 31 lines
lib/librte_eal/common/include/rte_bitops.h new file +17
-0+ +static inline int +rte_test_and_set_bit (int nr,unsigned long *addr) +{ +unsigned long mask = (1UL << nr); + +return __atomic_fetch_or (addr, mask, __ATOMIC_ACQ_REL) & mask; +} + +static inline int +rte_test_and_clear_bit (int nr,unsigned long *addr) +{ +unsigned long mask = (1UL << nr); + +return __atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL) & mask; +} +#endif /* _RTE_BITOPS_H_ */ lib/librte_eal/common/meson.build +1
-1@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', + 'include/rte_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', --
Quoted 2 lines
2.7.4
These functions use unsigned long as the type of their value, like they do in the PMDs.
However, a generic bit operations library should preferably work with multiple types, like the __atomic_xx functions. Or use an well defined uint_NN_t type. Or have individually named functions for each type size, e.g. rte_set_bit_32() and rte_set_bit_64().
Med venlig hilsen / kind regards
- Morten Brørup
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIs
Hi Morten,
Quoted 93 lines
-----Original Message-----
From: Morten Brørup <[email protected]>
Sent: Thursday, October 17, 2019 9:32 PM
To: Joyce Kong (Arm Technology China) <[email protected]>; [email protected]
Cc: nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>; Stephen Hemminger <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIsQuoted 8 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong
Sent: Tuesday, October 15, 2019 9:50 AMThere are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use
__ATOMIC_ACQ_RELto ensure the ordering.Good initiative.
Quoted 53 lines
Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 58 insertions(+) create mode 100644 lib/librte_eal/common/include/rte_bitops.h(quoted diff) +0
-0b/lib/librte_eal/common/Makefile index a00d4fc..8586ca8 100644
lib/librte_eal/common/Makefile +1
-0@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h
rte_vfio.hrte_hypervisor.hrte_test.hINC +=rte_reciprocal.hrte_fbarray.hrte_uuid.h
+INC +=rte_bitops.h
GENERIC_INC:=rte_atomic.hrte_byteorder.hrte_cycles.hrte_prefetch.hGENERIC_INC+=rte_memcpy.hrte_cpuflags.hdiff --gita/lib/librte_eal/common/include/rte_bitops.hb/lib/librte_eal/common/include/rte_bitops.h
new file mode 100644
index 0000000..4d7c5a3lib/librte_eal/common/include/rte_bitops.h new file +24
-0@@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Corporation +*/ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a generic API for bit operations. +*/ + +#include <stdint.h> +#include <rte_atomic.h> + +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); } + +static inline void +rte_clear_bit (int nr,unsigned long *addr) { +__atomic_fetch_and (addr, ~(1UL << nr), __ATOMIC_ACQ_REL); }lib/librte_eal/common/include/rte_bitops.h line 34
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h new file +10
-0+ +static inline int +rte_test_bit (int nr,unsigned long *addr) { +int res; +rte_mb (); + res = ((*addr) & (1UL << nr)) !=0 ; +rte_mb (); + +return res; +}Why does
rte_test_bit()not use any of the__atomic_xxfunctions instead? E.g.:
Quoted 4 lines
static inline int
rte_test_bit(int nr, unsigned long *addr) { return __atomic_load_n(addr, __ATOMIC_ACQUIRE); }
You re right, it's better to use __atomic_xx here to keep the consistent with other APIs.
Quoted 35 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_set_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_clear_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_and(addr, ~mask, __ATOMIC_ACQ_REL) &mask; }
Quoted 15 lines
lib/librte_eal/common/include/rte_bitops.h new file +1
-0+#endif /* _RTE_BITOPS_H_ */ lib/librte_eal/common/meson.build +1
-1@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', + 'include/rte_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', --Quoted 2 lines
2.7.4
These functions use unsigned long as the type of their value, like they do in the PMDs.
Quoted 5 lines
However, a generic bit operations library should preferably work with multiple types, like the
__atomic_xxfunctions. Or use an well defineduint_NN_ttype. Or have individually named functions for each type size, e.g.rte_set_bit_32()andrte_set_bit_64().
Good suggestion! And will do this in next version.
Quoted 2 lines
Med venlig hilsen / kind regards
- Morten Brørup
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIs
Quoted 120 lines
Quoted 78 lines
Quoted 8 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong
Sent: Tuesday, October 15, 2019 9:50 AMThere are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use
__ATOMIC_ACQ_RELto ensure the ordering.Good initiative.
Quoted 53 lines
Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 58 insertions(+) create mode 100644 lib/librte_eal/common/include/rte_bitops.h(quoted diff) +0
-0b/lib/librte_eal/common/Makefile index a00d4fc..8586ca8 100644
lib/librte_eal/common/Makefile +0
-0@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.hINC
+= rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h
rte_fbarray.hrte_uuid.h
+INC +=rte_bitops.h
GENERIC_INC:=rte_atomic.hrte_byteorder.hrte_cycles.hrte_prefetch.hGENERIC_INC+=rte_memcpy.hrte_cpuflags.hdiff --gita/lib/librte_eal/common/include/rte_bitops.hb/lib/librte_eal/common/include/rte_bitops.h
new file mode 100644
index 0000000..4d7c5a3lib/librte_eal/common/include/rte_bitops.h new file +23
-0@@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Corporation */ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a generic API for bit operations. +*/ + +#include <stdint.h> +#include <rte_atomic.h> + +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); } + +static inline void +rte_clear_bit (int nr,unsigned long *addr) { +__atomic_fetch_and (addr, ~(1UL << nr), __ATOMIC_ACQ_REL); }lib/librte_eal/common/include/rte_bitops.h line 33
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h new file +10
-0+ +static inline int +rte_test_bit (int nr,unsigned long *addr) { +int res; +rte_mb (); + res = ((*addr) & (1UL << nr)) !=0 ; +rte_mb (); + +return res; +}Why does
rte_test_bit()not use any of the__atomic_xxfunctions instead? E.g.:Quoted 4 lines
static inline int
rte_test_bit(int nr, unsigned long *addr) { return __atomic_load_n(addr, __ATOMIC_ACQUIRE); }You re right, it's better to use
__atomic_xxhere to keep the consistent with other APIs.Quoted 35 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_set_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_clear_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_and(addr, ~mask, __ATOMIC_ACQ_REL) &mask; }
Quoted 15 lines
lib/librte_eal/common/include/rte_bitops.h new file +1
-0+#endif /* _RTE_BITOPS_H_ */ lib/librte_eal/common/meson.build +1
-1@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', + 'include/rte_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', --Quoted 2 lines
2.7.4
These functions use unsigned long as the type of their value, like they do in the PMDs.
Quoted 7 lines
Quoted 3 lines
However, a generic bit operations library should preferably work with multiple types, like the
__atomic_xxfunctions. Or use an well defineduint_NN_ttype. Or have individually named functions for each type size,e.g.
Quoted 2 lines
rte_set_bit_32()andrte_set_bit_64().Good suggestion! And will do this in next version.
The PMDs which use the common API now are all 32bit operation, so change the definition to uint_32_t type instead of individually naming functions for each type size.
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIs
Quoted 139 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong (Arm Technology China)
Sent: Wednesday, October 23, 2019 5:08 AMQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong
Sent: Tuesday, October 15, 2019 9:50 AMThere are a lot functions of bit operations scattered and
duplicated
Quoted 1 line
Quoted 1 line
Quoted 1 line
in PMDs, consolidating them into a common API family is
necessary.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Furthermore, the bit operation is mostly applied to the IO
devices,
Quoted 61 lines
Quoted 61 lines
Quoted 1 line
so use
__ATOMIC_ACQ_RELto ensure the ordering.Good initiative.
Quoted 57 lines
Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 58 insertions(+) create mode 100644 lib/librte_eal/common/include/rte_bitops.h(quoted diff) +0
-0b/lib/librte_eal/common/Makefile index a00d4fc..8586ca8 100644
lib/librte_eal/common/Makefile +0
-0@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.hINC
+= rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h
rte_fbarray.hrte_uuid.h
+INC +=rte_bitops.h
GENERIC_INC:=rte_atomic.hrte_byteorder.hrte_cycles.hrte_prefetch.hGENERIC_INC+=rte_memcpy.hrte_cpuflags.hdiff --gita/lib/librte_eal/common/include/rte_bitops.hb/lib/librte_eal/common/include/rte_bitops.h
new file mode 100644
index 0000000..4d7c5a3lib/librte_eal/common/include/rte_bitops.h new file +27
-0@@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Corporation */ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a generic API for bit operations. +*/ + +#include <stdint.h> +#include <rte_atomic.h> + +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); } + +static inline void +rte_clear_bit (int nr,unsigned long *addr) { +__atomic_fetch_and (addr, ~(1UL << nr), __ATOMIC_ACQ_REL); } + +static inline int +rte_test_bit (int nr,unsigned long *addr) { +int res;Quoted 8 lines
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h line 39
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+rte_mb (); + res = ((*addr) & (1UL << nr)) !=0 ; +rte_mb (); + +return res; +}Why does
rte_test_bit()not use any of the__atomic_xxfunctionsinstead?
Quoted 7 lines
Quoted 6 lines
E.g.:
static inline int
rte_test_bit(int nr, unsigned long *addr) { return __atomic_load_n(addr, __ATOMIC_ACQUIRE); }You re right, it's better to use
__atomic_xxhere to keep theconsistent with
Quoted 38 lines
other APIs.
Quoted 36 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_set_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_clear_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_and(addr, ~mask, __ATOMIC_ACQ_REL) &mask; }
Quoted 15 lines
lib/librte_eal/common/include/rte_bitops.h new file +1
-0+#endif /* _RTE_BITOPS_H_ */ lib/librte_eal/common/meson.build +1
-1@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', + 'include/rte_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', --Quoted 2 lines
2.7.4
These functions use unsigned long as the type of their value, like they do in the PMDs.
However, a generic bit operations library should preferably work
with
Quoted 1 line
Quoted 1 line
multiple types, like the
__atomic_xxfunctions. Or use an welldefined
Quoted 1 line
Quoted 1 line
uint_NN_ttype. Or have individually named functions for each typesize,
Quoted 3 lines
e.g.
Quoted 2 lines
rte_set_bit_32()andrte_set_bit_64().
Quoted 7 lines
Quoted 1 line
Good suggestion! And will do this in next version.
The PMDs which use the common API now are all 32bit operation, so change
the definition touint_32_ttype instead of individually naming functions for
each type size.
Unless you are certain that all current and future I/O devices only need 32 bit, it should provide variants for different types, like the rte_atomic_xxx API.
There might also be a need to support both big and little endian byte ordering? Perhaps the CPU uses a different byte ordering than the I/O device being accessed through this API. I don't know; I'm only providing half baked feedback on this point.
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIs
Quoted 142 lines
Quoted 65 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong (Arm Technology China)
Sent: Wednesday, October 23, 2019 5:08 AMQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong
Sent: Tuesday, October 15, 2019 9:50 AMThere are a lot functions of bit operations scattered and
duplicated
Quoted 1 line
Quoted 1 line
Quoted 1 line
in PMDs, consolidating them into a common API family is
necessary.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Furthermore, the bit operation is mostly applied to the IO
devices,
Quoted 49 lines
Quoted 49 lines
Quoted 1 line
so use
__ATOMIC_ACQ_RELto ensure the ordering.Good initiative.
Quoted 45 lines
Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 58 insertions(+) create mode 100644
lib/librte_eal/common/include/rte_bitops.h(quoted diff) +0
-0b/lib/librte_eal/common/Makefile index a00d4fc..8586ca8 100644
lib/librte_eal/common/Makefile +0
-0@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.hINC
+= rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h
rte_fbarray.hrte_uuid.h
+INC +=rte_bitops.h
GENERIC_INC:=rte_atomic.hrte_byteorder.hrte_cycles.hrte_prefetch.hGENERIC_INC+=rte_memcpy.hrte_cpuflags.hdiff --gita/lib/librte_eal/common/include/rte_bitops.hb/lib/librte_eal/common/include/rte_bitops.h
new file mode 100644
index 0000000..4d7c5a3lib/librte_eal/common/include/rte_bitops.h new file +15
-0@@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Corporation */ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a generic API for bit operations. +*/ + +#include <stdint.h> +#include <rte_atomic.h> Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h new file +8
-0+ +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); } + +static inline void +rte_clear_bit (int nr,unsigned long *addr) { + __atomic_fetch_and(addr, ~(1UL << nr),
__ATOMIC_ACQ_REL); }Quoted 30 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_eal/common/include/rte_bitops.h new file +4
-0+ +static inline int +rte_test_bit (int nr,unsigned long *addr) { +int res;Quoted 8 lines
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h line 39
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+rte_mb (); + res = ((*addr) & (1UL << nr)) !=0 ; +rte_mb (); + +return res; +}Why does
rte_test_bit()not use any of the__atomic_xxfunctionsinstead?
Quoted 7 lines
Quoted 6 lines
E.g.:
static inline int
rte_test_bit(int nr, unsigned long *addr) { return __atomic_load_n(addr, __ATOMIC_ACQUIRE); }You re right, it's better to use
__atomic_xxhere to keep theconsistent with
Quoted 9 lines
other APIs.
Quoted 7 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_set_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_clear_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + +return __atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL)&
Quoted 31 lines
Quoted 22 lines
Quoted 22 lines
mask; }
Quoted 15 lines
lib/librte_eal/common/include/rte_bitops.h new file +1
-0+#endif /* _RTE_BITOPS_H_ */ lib/librte_eal/common/meson.build +1
-1@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', + 'include/rte_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', --Quoted 2 lines
2.7.4
These functions use unsigned long as the type of their value, like they do in the PMDs.
Quoted 1 line
Quoted 1 line
However, a generic bit operations library should preferably work
with
Quoted 1 line
Quoted 1 line
multiple types, like the
__atomic_xxfunctions. Or use an welldefined
Quoted 1 line
Quoted 1 line
uint_NN_ttype. Or have individually named functions for each typesize,
Quoted 3 lines
e.g.
Quoted 2 lines
rte_set_bit_32()andrte_set_bit_64().
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Good suggestion! And will do this in next version.
The PMDs which use the common API now are all 32bit operation, so change the definition to
uint_32_ttype instead of individually naming functions for each type size.Unless you are certain that all current and future I/O devices only need 32 bit, it should provide variants for different types, like the
rte_atomic_xxxAPI.
Why not do these using macros? The __atomic_xxx APIs anyway work with multiple types. Then we do not have to provide variants for all sizes.
Quoted 5 lines
There might also be a need to support both big and little endian byte ordering? Perhaps the CPU uses a different byte ordering than the I/O device being accessed through this API. I don't know; I'm only providing half baked feedback on this point.
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIs
Quoted 168 lines
-----Original Message-----
From: Honnappa Nagarahalli <[email protected]>
Sent: Thursday, October 24, 2019 1:30 AM
To: Morten Brørup <[email protected]>; Joyce Kong (Arm Technology China) <[email protected]>; [email protected]
Cc: nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Gavin Hu (Arm Technology China) <[email protected]>; Stephen Hemminger <[email protected]>; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIsQuoted 3 lines
Quoted 3 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong(Arm
Quoted 5 lines
Quoted 5 lines
Technology China)
Sent: Wednesday, October 23, 2019 5:08 AMQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of JoyceKong
Quoted 22 lines
Quoted 22 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Sent: Tuesday, October 15, 2019 9:50 AM
There are a lot functions of bit operations scattered and
duplicated
Quoted 1 line
Quoted 1 line
Quoted 1 line
in PMDs, consolidating them into a common API family is
necessary.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Furthermore, the bit operation is mostly applied to the IO
devices,
Quoted 14 lines
Quoted 14 lines
Quoted 1 line
so use
__ATOMIC_ACQ_RELto ensure the ordering.Good initiative.
Quoted 10 lines
Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 58 insertions(+) create mode 100644
lib/librte_eal/common/include/rte_bitops.hQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_eal/common/Makefile INC += rte_malloc.h rte_keepalive.h
Quoted 5 lines
(quoted diff) +0
-0b/lib/librte_eal/common/Makefile index a00d4fc..8586ca8 100644
lib/librte_eal/common/Makefile +0
-0@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h
rte_time.hQuoted 113 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
INC
+= rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h
rte_fbarray.hrte_uuid.h
+INC +=rte_bitops.h
GENERIC_INC:=rte_atomic.hrte_byteorder.hrte_cycles.hrte_prefetch.hGENERIC_INC+=rte_memcpy.hrte_cpuflags.hdiff --gita/lib/librte_eal/common/include/rte_bitops.hb/lib/librte_eal/common/include/rte_bitops.h
new file mode 100644
index 0000000..4d7c5a3lib/librte_eal/common/include/rte_bitops.h new file +15
-0@@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Corporation */ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a generic API for bit operations. +*/ + +#include <stdint.h> +#include <rte_atomic.h> Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h new file +8
-0+ +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); } + +static inline void +rte_clear_bit (int nr,unsigned long *addr) { +__atomic_fetch_and(addr, ~(1UL << nr),
__ATOMIC_ACQ_REL); }Quoted 30 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_eal/common/include/rte_bitops.h new file +4
-0+ +static inline int +rte_test_bit (int nr,unsigned long *addr) { +int res;Quoted 8 lines
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h line 39
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+rte_mb (); +res = ((*addr) & (1UL << nr)) !=0 ; +rte_mb (); + +return res; +}Why does
rte_test_bit()not use any of the__atomic_xxfunctionsinstead?
Quoted 7 lines
Quoted 6 lines
E.g.:
static inline int
rte_test_bit(int nr, unsigned long *addr){
return__atomic_load_n(addr, __ATOMIC_ACQUIRE); }You re right, it's better to use
__atomic_xxhere to keep theconsistent with
Quoted 9 lines
other APIs.
Quoted 7 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_set_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + +return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_clear_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + +return __atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL)&
Quoted 36 lines
Quoted 22 lines
Quoted 22 lines
mask; }
Quoted 15 lines
lib/librte_eal/common/include/rte_bitops.h new file +1
-0+#endif /* _RTE_BITOPS_H_ */ lib/librte_eal/common/meson.build +1
-1@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', +'include/rte_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', --Quoted 2 lines
2.7.4
These functions use unsigned long as the type of their value, like they do in the PMDs.
Quoted 1 line
Quoted 1 line
However, a generic bit operations library should preferably work
with
Quoted 1 line
Quoted 1 line
multiple types, like the
__atomic_xxfunctions. Or use an welldefined
Quoted 1 line
Quoted 1 line
uint_NN_ttype. Or have individually named functions for each typesize,
Quoted 4 lines
e.g.
Quoted 2 lines
rte_set_bit_32()andrte_set_bit_64().Good suggestion! And will do this in next version.
The PMDs which use the common API now are all 32bit operation, so change the definition to
uint_32_ttype instead of individually naming functions for each type size.
Quoted 5 lines
Quoted 1 line
Unless you are certain that all current and future I/O devices only need 32
bit,
Quoted 1 line
it should provide variants for different types, like the
rte_atomic_xxxAPI.Why not do these using macros? The
__atomic_xxxAPIs anyway work with multiple types. Then we do not have to provide variants for all sizes.
We really come to the point for the community to give a guideline: how to generalize APIs to support multiple-sized arguments.
Looks like macros was disliked by the community, for readability and debuggability reasons.
Besides macros, there are an alternative: _Generic https://gcc.gnu.org/onlinedocs/gccint/GENERIC.html, but it is not supported by older gcc(<4.9), this made a hard requirement for gcc/clang.
We have to compromise over all these: code duplication, readability and debuggability. /Gavin
Quoted 8 lines
Quoted 2 lines
There might also be a need to support both big and little endian byte
ordering?
Quoted 2 lines
Perhaps the CPU uses a different byte ordering than the I/O device being accessed through this API. I don't know; I'm only providing half baked
feedback
Quoted 1 line
on this point.
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIs
Quoted 156 lines
Quoted 156 lines
Quoted 4 lines
Quoted 4 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong(Arm
Quoted 5 lines
Quoted 5 lines
Technology China)
Sent: Wednesday, October 23, 2019 5:08 AMQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of JoyceKong
Quoted 22 lines
Quoted 22 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Sent: Tuesday, October 15, 2019 9:50 AM
There are a lot functions of bit operations scattered and
duplicated
Quoted 1 line
Quoted 1 line
Quoted 1 line
in PMDs, consolidating them into a common API family is
necessary.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Furthermore, the bit operation is mostly applied to the IO
devices,
Quoted 14 lines
Quoted 14 lines
Quoted 1 line
so use
__ATOMIC_ACQ_RELto ensure the ordering.Good initiative.
Quoted 10 lines
Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 58 insertions(+) create mode 100644
lib/librte_eal/common/include/rte_bitops.hQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/common/Makefile INC += rte_malloc.h rte_keepalive.h
Quoted 6 lines
(quoted diff) +0
-0b/lib/librte_eal/common/Makefile index a00d4fc..8586ca8 100644
lib/librte_eal/common/Makefile +0
-0@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h
rte_time.hQuoted 107 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
INC
+=rte_service.hrte_service_component.hINC +=+rte_bitmap.hrte_vfio.hrte_hypervisor.hrte_test.hINC +=rte_reciprocal.hrte_fbarray.hrte_uuid.h
+INC +=rte_bitops.h
GENERIC_INC:=rte_atomic.hrte_byteorder.hrte_cycles.hrte_prefetch.hGENERIC_INC+=rte_memcpy.hrte_cpuflags.hlib/librte_eal/common/include/rte_bitops.h new file +15
-0@@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Corporation */ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a generic API for bit operations. +*/ + +#include <stdint.h> +#include <rte_atomic.h> Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h line 23
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h new file +8
-0+ +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); } + +static inline void +rte_clear_bit (int nr,unsigned long *addr) { +__atomic_fetch_and(addr, ~(1UL << nr),
__ATOMIC_ACQ_REL); }Quoted 28 lines
Quoted 10 lines
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h line 30
Quoted 7 lines
lib/librte_eal/common/include/rte_bitops.h new file +7
-0+ +static inline int +rte_test_bit (int nr,unsigned long *addr) {int res; +rte_mb (); res = ((*addr) & (1UL << nr)) !=0 ;rte_mb (); + +return res; +}Why does
rte_test_bit()not use any of the__atomic_xxfunctionsinstead?
Quoted 7 lines
Quoted 6 lines
E.g.:
static inline int
rte_test_bit(int nr, unsigned long *addr){ return__atomic_load_n(addr, __ATOMIC_ACQUIRE); }You re right, it's better to use
__atomic_xxhere to keep theconsistent with
Quoted 9 lines
other APIs.
Quoted 7 lines
lib/librte_eal/common/include/rte_bitops.h line 36
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_set_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + +return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h line 42
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_clear_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + +return __atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL)&
Quoted 32 lines
Quoted 21 lines
Quoted 21 lines
mask; }
Quoted 14 lines
lib/librte_eal/common/include/rte_bitops.h new file +1
-0+#endif /* _RTE_BITOPS_H_ */ lib/librte_eal/common/meson.build +1
-1@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', +'include/rte_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', --Quoted 2 lines
2.7.4
These functions use unsigned long as the type of their value, like they do in the PMDs.
Quoted 2 lines
Quoted 2 lines
However, a generic bit operations library should preferably work
with
Quoted 1 line
Quoted 1 line
multiple types, like the
__atomic_xxfunctions. Or use an welldefined
Quoted 2 lines
Quoted 2 lines
uint_NN_ttype. Or have individually named functions for each typesize,
Quoted 3 lines
e.g.
Quoted 2 lines
rte_set_bit_32()andrte_set_bit_64().Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Good suggestion! And will do this in next version.
The PMDs which use the common API now are all 32bit operation, so change the definition to
uint_32_ttype instead of individually naming functions for each type size.Unless you are certain that all current and future I/O devices only need 32
bit,
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
it should provide variants for different types, like the
rte_atomic_xxxAPI.Why not do these using macros? The
__atomic_xxxAPIs anyway work with multiple types. Then we do not have to provide variants for all sizes.We really come to the point for the community to give a guideline: how to generalize APIs to support multiple-sized arguments.
Looks like macros was disliked by the community, for readability and debuggability reasons.
IMO, it should not be considered as a blanket ban on using macros. It should be considered case by case basis. For ex: I do not see a point in writing the same API for 32b/64b/128b especially when the APIs are one liners.
Quoted 18 lines
Besides macros, there are an alternative:
_Generic
https://gcc.gnu.org/onlinedocs/gccint/GENERIC.html, but it is not supported by older gcc(<4.9), this made a hard requirement for gcc/clang.We have to compromise over all these: code duplication, readability and debuggability.
/GavinQuoted 10 lines
Quoted 3 lines
There might also be a need to support both big and little endian byte
ordering?
Quoted 3 lines
Perhaps the CPU uses a different byte ordering than the I/O device being accessed through this API. I don't know; I'm only providing half baked
feedback
Quoted 1 line
on this point.
Re: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIs
Hi Honnappa,
Quoted 177 lines
-----Original Message-----
From: Honnappa Nagarahalli <[email protected]>
Sent: Friday, November 1, 2019 9:48 PM
To: Gavin Hu (Arm Technology China) <[email protected]>; Morten Brørup <[email protected]>; Joyce Kong (Arm Technology China) <[email protected]>; [email protected]
Cc: nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Stephen Hemminger <[email protected]>; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bitoperation APIsQuoted 149 lines
Quoted 149 lines
Quoted 4 lines
Quoted 4 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong(Arm
Quoted 5 lines
Quoted 5 lines
Technology China)
Sent: Wednesday, October 23, 2019 5:08 AMQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of JoyceKong
Quoted 22 lines
Quoted 22 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Sent: Tuesday, October 15, 2019 9:50 AM
There are a lot functions of bit operations scattered and
duplicated
Quoted 1 line
Quoted 1 line
Quoted 1 line
in PMDs, consolidating them into a common API family is
necessary.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Furthermore, the bit operation is mostly applied to the IO
devices,
Quoted 14 lines
Quoted 14 lines
Quoted 1 line
so use
__ATOMIC_ACQ_RELto ensure the ordering.Good initiative.
Quoted 10 lines
Signed-off-by Joyce Kong <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 58 insertions(+) create mode 100644
lib/librte_eal/common/include/rte_bitops.hQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/common/Makefile INC += rte_malloc.h rte_keepalive.h
Quoted 6 lines
(quoted diff) +0
-0b/lib/librte_eal/common/Makefile index a00d4fc..8586ca8 100644
lib/librte_eal/common/Makefile +0
-0@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h
rte_time.hQuoted 109 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
INC
+=rte_service.hrte_service_component.hINC +=+rte_bitmap.hrte_vfio.hrte_hypervisor.hrte_test.hINC +=rte_reciprocal.hrte_fbarray.hrte_uuid.h
+INC +=rte_bitops.h
GENERIC_INC:=rte_atomic.hrte_byteorder.hrte_cycles.hrte_prefetch.hGENERIC_INC+=rte_memcpy.hrte_cpuflags.hlib/librte_eal/common/include/rte_bitops.h new file +15
-0@@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Corporation */ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a generic API for bit operations. +*/ + +#include <stdint.h> +#include <rte_atomic.h> Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h line 23
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h new file +8
-0+ +static inline void +rte_set_bit (unsigned int nr,unsigned long *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); } + +static inline void +rte_clear_bit (int nr,unsigned long *addr) { +__atomic_fetch_and(addr, ~(1UL << nr),
__ATOMIC_ACQ_REL); }Quoted 28 lines
Quoted 10 lines
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h line 30
Quoted 7 lines
lib/librte_eal/common/include/rte_bitops.h new file +7
-0+ +static inline int +rte_test_bit (int nr,unsigned long *addr) {int res; +rte_mb (); res = ((*addr) & (1UL << nr)) !=0 ;rte_mb (); + +return res; +}Why does
rte_test_bit()not use any of the__atomic_xxfunctionsinstead?
Quoted 7 lines
Quoted 6 lines
E.g.:
static inline int
rte_test_bit(int nr, unsigned long *addr){ return__atomic_load_n(addr, __ATOMIC_ACQUIRE); }You re right, it's better to use
__atomic_xxhere to keep theconsistent with
Quoted 9 lines
other APIs.
Quoted 7 lines
lib/librte_eal/common/include/rte_bitops.h line 36
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_set_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + +return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h line 42
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+ +static inline int +rte_test_and_clear_bit (int nr,unsigned long *addr) { +unsigned long mask = (1UL << nr); + +return __atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL)&
Quoted 34 lines
Quoted 21 lines
Quoted 21 lines
mask; }
Quoted 14 lines
lib/librte_eal/common/include/rte_bitops.h new file +1
-0+#endif /* _RTE_BITOPS_H_ */ lib/librte_eal/common/meson.build +1
-1@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', +'include/rte_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', --Quoted 2 lines
2.7.4
These functions use unsigned long as the type of their value, like they do in the PMDs.
Quoted 2 lines
Quoted 2 lines
However, a generic bit operations library should preferably work
with
Quoted 1 line
Quoted 1 line
multiple types, like the
__atomic_xxfunctions. Or use an welldefined
Quoted 2 lines
Quoted 2 lines
uint_NN_ttype. Or have individually named functions for each typesize,
Quoted 4 lines
e.g.
Quoted 2 lines
rte_set_bit_32()andrte_set_bit_64().Good suggestion! And will do this in next version.
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
The PMDs which use the common API now are all 32bit operation, so change the definition to
uint_32_ttype instead of individually naming functions for each type size.Unless you are certain that all current and future I/O devices only need 32
bit,
Quoted 1 line
it should provide variants for different types, like the
rte_atomic_xxxAPI.
Quoted 1 line
Quoted 1 line
Why not do these using macros? The
__atomic_xxxAPIs anyway workwith
Quoted 2 lines
Quoted 1 line
multiple types. Then we do not have to provide variants for all sizes.
Quoted 7 lines
Quoted 4 lines
We really come to the point for the community to give a guideline: how to generalize APIs to support multiple-sized arguments.
Looks like macros was disliked by the community, for readability and debuggability reasons.IMO, it should not be considered as a blanket ban on using macros. It should be considered case by case basis. For ex: I do not see a point in writing the same API for 32b/64b/128b especially when the APIs are one liners.
Jerin and Morten have different opinions, they thought the MACRO based scheme only as of the last resort. Another argument is the API familiarity(similar to rte io read APIs).
Joyce made a new version and let's see how the community balance the duplication and other considerations. /Gavin
Quoted 21 lines
Quoted 3 lines
Besides macros, there are an alternative:
_Generic
https://gcc.gnu.org/onlinedocs/gccint/GENERIC.html, but it is notsupported
Quoted 16 lines
by older gcc(<4.9), this made a hard requirement for gcc/clang.
We have to compromise over all these: code duplication, readability and debuggability.
/GavinQuoted 10 lines
Quoted 3 lines
There might also be a need to support both big and little endian byte
ordering?
Quoted 3 lines
Perhaps the CPU uses a different byte ordering than the I/O device being accessed through this API. I don't know; I'm only providing half baked
feedback
Quoted 1 line
on this point.
PATCH 2/5 net/axgbe: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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_mdio.c | 14 +++++++------- 3 files changed, 15 insertions(+), 42 deletions(-)
drivers/net/axgbe/axgbe_common.h +1 -28
@@ -22,6 +22,7 @@#include <pthread.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memory.h> #include <rte_malloc.h> #include <rte_hexdump.h>
@@ -1674,34 +1675,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
@@ -201,8 +201,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_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_clear_bit (AXGBE_DOWN , &pdata->dev_state);return 0 ; }
@@ -216,17 +216,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_test_bit (AXGBE_STOPPED , &pdata->dev_state))return ; -axgbe_set_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_set_bit (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_bit (AXGBE_DOWN , &pdata->dev_state); }/* Clear all resources like TX/RX queues. */
@@ -598,8 +598,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_bit (AXGBE_DOWN , &pdata->dev_state); +rte_set_bit (AXGBE_STOPPED , &pdata->dev_state); pdata->eth_dev = eth_dev; pci_dev =RTE_DEV_TO_PCI (eth_dev->device);
drivers/net/axgbe/axgbe_mdio.c +7 -7
@@ -743,7 +743,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) {int ret; -axgbe_set_bit (AXGBE_LINK_INIT , &pdata->dev_state); +rte_set_bit (AXGBE_LINK_INIT , &pdata->dev_state); pdata->link_check =rte_get_timer_cycles (); ret = pdata->phy_if.phy_impl.an_config (pdata);
@@ -807,9 +807,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_bit (AXGBE_LINK_ERR , &pdata->dev_state);else -axgbe_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state); +rte_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state);pthread_mutex_unlock (&pdata->an_mutex);
@@ -880,7 +880,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)unsigned int link_aneg;int an_restart; -if (axgbe_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { +if (rte_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { pdata->phy.link =0 ; goto adjust_link; }
@@ -900,10 +900,10 @@ static void axgbe_phy_status(struct axgbe_port *pdata)return ; }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_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) +rte_clear_bit (AXGBE_LINK_INIT , &pdata->dev_state); }else { -if (axgbe_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) { +if (rte_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) {axgbe_check_link_timeout (pdata);if (link_aneg)
Signature · 1 line
2.7.4
PATCH 3/5 net/bnx2x: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/bnx2x/bnx2x.c | 202 +++++++++++++++++++------------------------ drivers/net/bnx2x/bnx2x.h | 5 +- drivers/net/bnx2x/ecore_sp.h | 8 +- 3 files changed, 94 insertions(+), 121 deletions(-)
drivers/net/bnx2x/bnx2x.c +89 -113
@@ -129,32 +129,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);
@@ -1427,11 +1401,11 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,/* wait for completion of requested */ if (wait_for_comp) { -bnx2x_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); +rte_set_bit (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_bit (mac_type, &vlan_mac_flags); rc = mac_obj->delete_all (sc, mac_obj, &vlan_mac_flags, &ramrod_flags);if (rc <0 )
@@ -1458,26 +1432,26 @@ 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_bit (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit (ECORE_ACCEPT_MULTICAST , rx_accept_flags); +rte_set_bit (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_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit (ECORE_ACCEPT_MULTICAST , tx_accept_flags); +rte_set_bit (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_bit (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +ret_set_bit (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_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_set_bit (ECORE_ACCEPT_BROADCAST , tx_accept_flags);break ;
@@ -1488,19 +1462,19 @@ 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_bit (ECORE_ACCEPT_UNMATCHED , rx_accept_flags); +rte_set_bit (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_set_bit (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_bit (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_set_bit (ECORE_ACCEPT_BROADCAST , tx_accept_flags);if (IS_MF_SI (sc)) { -bnx2x_set_bit (ECORE_ACCEPT_ALL_UNICAST , tx_accept_flags); +rte_set_bit (ECORE_ACCEPT_ALL_UNICAST , tx_accept_flags); }else { -bnx2x_set_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); }break ;
@@ -1512,8 +1486,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_bit (ECORE_ACCEPT_ANY_VLAN , rx_accept_flags); +rte_set_bit (ECORE_ACCEPT_ANY_VLAN , tx_accept_flags); }return 0 ;
@@ -1542,7 +1516,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_bit (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); ramrod_param.ramrod_flags = ramrod_flags; ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1571,9 +1545,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_bit (RAMROD_RX , &ramrod_flags); +rte_set_bit (RAMROD_TX , &ramrod_flags); +rte_set_bit (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,
@@ -1698,7 +1672,7 @@ 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_bit (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);/* STARTED-->TX_STOPPED */ func_params.cmd =ECORE_F_CMD_TX_STOP ;
@@ -1722,7 +1696,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_bit (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* Stop the primary connection: */
@@ -1783,7 +1757,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_bit (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_STOP ;
@@ -1797,7 +1771,7 @@ 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_bit (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);return ecore_func_state_change (sc, &func_params); }
@@ -1809,7 +1783,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_bit (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_RESET ;
@@ -1866,8 +1840,8 @@ 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); +if (rte_test_bit (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state)) { +rte_set_bit (ECORE_FILTER_RX_MODE_SCHED , &sc->sp_state); }else {bnx2x_set_storm_rx_mode (sc); }
@@ -1960,12 +1934,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_bit (RAMROD_COMP_WAIT , &ramrod_flags);/* Perform a dry cleanup */ -bnx2x_set_bit (RAMROD_DRV_CLR_ONLY , &ramrod_flags); +rte_set_bit (RAMROD_DRV_CLR_ONLY , &ramrod_flags);/* Clean ETH primary MAC */ -bnx2x_set_bit (ECORE_ETH_MAC , &vlan_mac_flags); +rte_set_bit (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 ) {
@@ -1974,7 +1948,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_bit (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,
@@ -1984,7 +1958,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_bit (RAMROD_DRV_CLR_ONLY , &rparam.ramrod_flags);/* Add a DEL command... */ rc =ecore_config_mcast (sc, &rparam,ECORE_MCAST_CMD_DEL );
@@ -4288,7 +4262,7 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estruct 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_bit (RAMROD_CONT , &ramrod_flags);switch (le32toh (elem->message.data.eth_event.echo) >>BNX2X_SWCID_SHIFT ) {case ECORE_FILTER_MAC_PENDING :
@@ -4319,10 +4293,10 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estatic void bnx2x_handle_rx_mode_eqe (struct bnx2x_softc *sc) { -bnx2x_clear_bit (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); +rte_clear_bit (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_bit (ECORE_FILTER_RX_MODE_SCHED , &sc->sp_state)) {bnx2x_set_storm_rx_mode (sc); } }
@@ -4693,7 +4667,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_bit (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_INIT ;
@@ -4988,8 +4962,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_bit (ECORE_Q_TYPE_HAS_RX , &q_type); +rte_set_bit (ECORE_Q_TYPE_HAS_TX , &q_type); ecore_init_queue_obj(sc, &sc->sp_objs[idx].q_obj,
@@ -5803,7 +5777,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_bit (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_START ;
@@ -6379,11 +6353,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_bit (ECORE_Q_FLG_HC , &init_params->rx.flags); +rte_set_bit (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_bit (ECORE_Q_FLG_HC_EN , &init_params->rx.flags); +rte_set_bit (ECORE_Q_FLG_HC_EN , &init_params->tx.flags);/* HC rate */ init_params->rx.hc_rate =
@@ -6417,7 +6391,7 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)unsigned long flags =0 ;/* PF driver will always initialize the Queue to an ACTIVE state */ -bnx2x_set_bit (ECORE_Q_FLG_ACTIVE , &flags); +rte_set_bit (ECORE_Q_FLG_ACTIVE , &flags);/* * tx only connections collect statistics (on the same index as the
@@ -6425,9 +6399,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_bit (ECORE_Q_FLG_STATS , &flags);if (zero_stats) { -bnx2x_set_bit (ECORE_Q_FLG_ZERO_STATS , &flags); +rte_set_bit (ECORE_Q_FLG_ZERO_STATS , &flags); }/*
@@ -6435,10 +6409,10 @@ 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_bit (ECORE_Q_FLG_TX_SWITCH , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_PCSUM_ON_PKT , &flags); +rte_set_bit (ECORE_Q_FLG_PCSUM_ON_PKT , &flags);return flags; }
@@ -6448,15 +6422,15 @@ static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)unsigned long flags =0 ;if (IS_MF_SD (sc)) { -bnx2x_set_bit (ECORE_Q_FLG_OV , &flags); +rte_set_bit (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_bit (ECORE_Q_FLG_LEADING_RSS , &flags); +rte_set_bit (ECORE_Q_FLG_MCAST , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_VLAN , &flags); +rte_set_bit (ECORE_Q_FLG_VLAN , &flags);/* merge with common flags */ return flags |bnx2x_get_common_flags (sc, TRUE);
@@ -6577,7 +6551,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_bit (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* prepare the INIT parameters */ bnx2x_pf_q_prep_init (sc, fp, &q_params.params.init);
@@ -6645,20 +6619,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 , ¶ms.ramrod_flags); +rte_set_bit (RAMROD_COMP_WAIT , ¶ms.ramrod_flags); -bnx2x_set_bit (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags); +rte_set_bit (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags);/* RSS configuration */ -bnx2x_set_bit (ECORE_RSS_IPV4 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags); +rte_set_bit (ECORE_RSS_IPV4 , ¶ms.rss_flags); +rte_set_bit (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); +rte_set_bit (ECORE_RSS_IPV6 , ¶ms.rss_flags); +rte_set_bit (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags);if (rss_obj->udp_rss_v4) { -bnx2x_set_bit (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); +rte_set_bit (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); }if (rss_obj->udp_rss_v6) { -bnx2x_set_bit (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); +rte_set_bit (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); }/* Hash bits */
@@ -6673,7 +6647,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 , ¶ms.rss_flags); +rte_set_bit (ECORE_RSS_SET_SRCH , ¶ms.rss_flags); }if (IS_PF (sc))
@@ -6730,11 +6704,11 @@ 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_test_bit (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_bit (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 :
@@ -6761,7 +6735,7 @@ static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)PMD_DRV_LOG (DEBUG , sc,"Adding Ethernet MAC" ); -bnx2x_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); +rte_set_bit (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,
@@ -6893,24 +6867,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_bit (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_bit (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_bit (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_bit (BNX2X_LINK_REPORT_TX_FC_ON , + &data->link_report_flags); } }
@@ -6929,9 +6905,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_test_bit (BNX2X_LINK_REPORT_LINK_DOWN , &sc->last_reported_link.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_LINK_DOWN , +rte_test_bit (BNX2X_LINK_REPORT_LINK_DOWN , &cur_data.link_report_flags))) {return ; }
@@ -6946,14 +6922,14 @@ 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_test_bit (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 , +if (rte_test_and_clear_bit (BNX2X_LINK_REPORT_FULL_DUPLEX , &cur_data.link_report_flags)) { duplex ="full" ;ELINK_DEBUG_P0 (sc,"link set to full duplex" );
@@ -6968,19 +6944,19 @@ 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_test_bit (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_test_bit (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 , + }else if (rte_test_bit (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && - !bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , + !rte_test_bit (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_test_bit (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , &cur_data.link_report_flags)) { flow ="ON - transmit" ; }else {
drivers/net/bnx2x/bnx2x.h +1 -4
@@ -15,6 +15,7 @@#define __BNX2X_H__#include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_spinlock.h> #include <rte_bus_pci.h> #include <rte_io.h>
@@ -1809,10 +1810,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 +4 -4
@@ -73,10 +73,10 @@ 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_test_bit(bit, var) +#define ECORE_SET_BIT (bit, var) rte_set_bit(bit, var) +#define ECORE_CLEAR_BIT (bit, var) rte_clear_bit(bit, var) +#define ECORE_TEST_AND_CLEAR_BIT (bit, var) rte_test_and_clear_bit(bit, var)#define atomic_load_acq_int (int)*#define atomic_store_rel_int (a, v) (*a = v)
Signature · 1 line
2.7.4
PATCH 4/5 net/hinic: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/hinic/base/hinic_compat.h | 35 +---------------------------------- drivers/net/hinic/hinic_pmd_ethdev.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 42 deletions(-)
drivers/net/hinic/base/hinic_compat.h +1 -34
@@ -11,6 +11,7 @@#include <pthread.h> #include <rte_common.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memzone.h> #include <rte_memcpy.h> #include <rte_malloc.h>
@@ -117,40 +118,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; - -rte_mb (); - res = ((*addr) & (1UL << nr)) !=0 ; -rte_mb (); -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 +8 -8
@@ -227,7 +227,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_test_bit (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 ;
@@ -907,7 +907,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_bit (HINIC_DEV_START , &nic_dev->dev_status);return 0 ;
@@ -1030,7 +1030,7 @@ 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_bit (HINIC_DEV_START , &nic_dev->dev_status)) {PMD_DRV_LOG (INFO ,"Device %s already stopped" , name);return ; }
@@ -1073,7 +1073,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_bit (HINIC_DEV_INTR_EN , &nic_dev->dev_status);/* disable msix interrupt in hardware */ hinic_set_msix_state (nic_dev->hwdev,0 ,HINIC_MSIX_DISABLE );
@@ -2197,9 +2197,9 @@ 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_bit (HINIC_DEV_INTR_EN , &nic_dev->dev_status); -hinic_set_bit (HINIC_DEV_INIT , &nic_dev->dev_status); +rte_set_bit (HINIC_DEV_INIT , &nic_dev->dev_status);PMD_DRV_LOG (INFO ,"Initialize %s in primary successfully" , eth_dev->data->name);
@@ -2236,7 +2236,7 @@ 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_bit (HINIC_DEV_CLOSE , &nic_dev->dev_status)) {PMD_DRV_LOG (WARNING ,"Device %s already closed" , dev->data->name);return ;
@@ -2316,7 +2316,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_bit (HINIC_DEV_INIT , &nic_dev->dev_status);if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ;
Signature · 1 line
2.7.4
PATCH 5/5 net/qede: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/qede/base/bcm_osal.c | 20 -------------------- drivers/net/qede/base/bcm_osal.h | 10 ++++------ 2 files changed, 4 insertions(+), 26 deletions(-)
drivers/net/qede/base/bcm_osal.c +0 -20
@@ -45,26 +45,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;
drivers/net/qede/base/bcm_osal.h +4 -6
@@ -8,6 +8,7 @@#define __BCM_OSAL_H#include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_spinlock.h> #include <rte_malloc.h> #include <rte_atomic.h>
@@ -311,17 +312,14 @@ 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_bit(bit, bitmap) -void qede_clr_bit (u32 ,unsigned long *);#define OSAL_CLEAR_BIT (bit, bitmap) \ - qede_clr_bit(bit, bitmap) + rte_clear_bit(bit, bitmap) -bool qede_test_bit (u32 ,unsigned long *);#define OSAL_TEST_BIT (bit, bitmap) \ - qede_test_bit(bit, bitmap) + rte_test_bit(bit, bitmap)u32 qede_find_first_bit (unsigned long *,u32 );#define OSAL_FIND_FIRST_BIT (bitmap, length) \
Signature · 1 line
2.7.4
Quoted 11 lines · On Tue, 15 Oct 2019 15:49:56 +0800 Joyce Kong <[email protected]> wrote:
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
Joyce Kong (5):
lib/eal: implement the family of rte bit operation APIs net/axgbe: use common rte bit operation APIs instead net/bnx2x: use common rte bit operation APIs instead net/hinic: use common rte bit operation APIs instead net/qede: use common rte bit operation APIs instead
Quoted 16 lines
drivers/net/axgbe/axgbe_common.h | 29 +---- drivers/net/axgbe/axgbe_ethdev.c | 14 +- drivers/net/axgbe/axgbe_mdio.c | 14 +- drivers/net/bnx2x/bnx2x.c | 202 +++++++++++++---------------- drivers/net/bnx2x/bnx2x.h | 5 +- drivers/net/bnx2x/ecore_sp.h | 8 +- drivers/net/hinic/base/hinic_compat.h | 35 +---- drivers/net/hinic/hinic_pmd_ethdev.c | 16 +-- drivers/net/qede/base/bcm_osal.c | 20 --- drivers/net/qede/base/bcm_osal.h | 10 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++ lib/librte_eal/common/meson.build | 1 + 13 files changed, 180 insertions(+), 231 deletions(-) create mode 100644 lib/librte_eal/common/include/rte_bitops.h
This is a really good idea, and should have been done long ago. Could you add tests for these as well?
Quoted 45 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, October 16, 2019 12:51 AM
To: Joyce Kong (Arm Technology China) <[email protected]>
Cc: [email protected]; nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 0/5] implement common rte bit operation APIs in PMDsQuoted 25 lines · On Tue, 15 Oct 2019 15:49:56 +0800 Joyce Kong <[email protected]> wrote:
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
Joyce Kong (5):
lib/eal: implement the family of rte bit operation APIs net/axgbe: use common rte bit operation APIs instead net/bnx2x: use common rte bit operation APIs instead net/hinic: use common rte bit operation APIs instead net/qede: use common rte bit operation APIs insteaddrivers/net/axgbe/axgbe_common.h | 29 +---- drivers/net/axgbe/axgbe_ethdev.c | 14 +- drivers/net/axgbe/axgbe_mdio.c | 14 +- drivers/net/bnx2x/bnx2x.c | 202 +++++++++++++---------------- drivers/net/bnx2x/bnx2x.h | 5 +- drivers/net/bnx2x/ecore_sp.h | 8 +- drivers/net/hinic/base/hinic_compat.h | 35 +---- drivers/net/hinic/hinic_pmd_ethdev.c | 16 +-- drivers/net/qede/base/bcm_osal.c | 20 --- drivers/net/qede/base/bcm_osal.h | 10 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 56 ++++++++ lib/librte_eal/common/meson.build | 1 + 13 files changed, 180 insertions(+), 231 deletions(-) create modeQuoted 2 lines
100644
lib/librte_eal/common/include/rte_bitops.h
Quoted 2 lines
This is a really good idea, and should have been done long ago. Could you add tests for these as well?
Yes. Will add some tests for these APIs in next version.
v2 cover implement common rte bit operation APIs in PMDs
In reply to Joyce KongThere are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
v2:
1. Add doxygen comments for the rte bit operation API(suggested by Stephen Hemminger).
2. Add test cases for common rte bit operation API(suggested by Stephen Hemminger).
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 (suggested by Jerin Jacob).
4. Use an well defined uint_NN_t type(suggested by Morten Brørup).
Joyce Kong (6):
lib/eal: implement the family of rte bit operation APIs test/iobitops: add io bit operation test case net/axgbe: use common rte bit operation APIs instead net/bnx2x: use common rte bit operation APIs instead net/hinic: use common rte bit operation APIs instead net/qede: use common rte bit operation APIs instead
app/test/Makefile | 1 + app/test/test_io_bitops.c | 86 +++++++++++ drivers/net/axgbe/axgbe_common.h | 29 +--- drivers/net/axgbe/axgbe_ethdev.c | 14 +- drivers/net/axgbe/axgbe_mdio.c | 14 +- drivers/net/bnx2x/bnx2x.c | 209 ++++++++++++-------------- drivers/net/bnx2x/bnx2x.h | 4 - drivers/net/bnx2x/ecore_sp.h | 9 +- drivers/net/hinic/base/hinic_compat.h | 35 +---- drivers/net/hinic/hinic_pmd_ethdev.c | 16 +- drivers/net/qede/base/bcm_osal.c | 20 --- drivers/net/qede/base/bcm_osal.h | 10 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_io_bitops.h | 112 ++++++++++++++ lib/librte_eal/common/meson.build | 1 + 15 files changed, 327 insertions(+), 234 deletions(-) create mode 100644 app/test/test_io_bitops.c create mode 100644 lib/librte_eal/common/include/rte_io_bitops.h
Signature · 1 line
2.7.4
PATCH v2 1/6 lib/eal: implement the family of rte bit operation APIs
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use __ATOMIC_ACQ_REL to ensure the ordering.
--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_io_bitops.h | 112 ++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 114 insertions(+) create mode 100644 lib/librte_eal/common/include/rte_io_bitops.h
lib/librte_eal/common/Makefile +1 -0
@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h +INC += rte_io_bitops.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.h
lib/librte_eal/common/include/rte_io_bitops.h new file +112 -0
112 lines not on this page · raw message
lib/librte_eal/common/meson.build +1 -0
@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', + 'include/rte_io_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h',
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v2 1/6] lib/eal: implement the family of rte bit operation APIs
Hi Joyce,
Thanks for the patch, few comments.
<snip>
Quoted 5 lines
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use
__ATOMIC_ACQ_RELto ensure the ordering.
The APIs are not taking memory ordering as a parameter. This presents the same problem as the rte_atomic_xxx APIs. IMO, the APIs should take memory ordering as a parameter.
Quoted 48 lines
Signed-off-by Joyce Kong <[email protected]>Reviewed-by Gavin Hu <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_io_bitops.h | 112 ++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 114 insertions(+) create mode 100644 lib/librte_eal/common/include/rte_io_bitops.h(quoted diff) +0
-0b/lib/librte_eal/common/Makefile index a00d4fc..3831313 100644
lib/librte_eal/common/Makefile +0
-0@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC +=
rte_service.hrte_service_component.hINC +=rte_bitmap.hrte_vfio.hrte_hypervisor.hrte_test.hINC +=rte_reciprocal.hrte_fbarray.hrte_uuid.h+INC +=rte_io_bitops.h
GENERIC_INC:=rte_atomic.hrte_byteorder.hrte_cycles.hrte_prefetch.hGENERIC_INC+=rte_memcpy.hrte_cpuflags.hdiff --gita/lib/librte_eal/common/include/rte_io_bitops.hb/lib/librte_eal/common/include/rte_io_bitops.h
new file mode 100644
index 0000000..5f778b8lib/librte_eal/common/include/rte_io_bitops.h new file +19
-0@@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_IO_BITOPS_H_ +#define _RTE_IO_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a generic API for bit operations. +*/ + +#include <rte_lcore.h> + +/** +* Get a bit. +*
lib/librte_eal/common/include/rte_io_bitops.h line 29
Quoted 10 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +10
-0+* @param nr +* The bit to get. +* @param addr +* The address to count from. +* @return +* The value of the bit. +*/ +static inline int32_t +rte_io_get_bit (uint32_t nr,uint64_t *addr) { +return __atomic_load_n (addr, __ATOMIC_ACQUIRE) & (1UL << nr); }
Some use cases might need 'relaxed' memory order for this API. So, the user of this API should be able to provide the memory order.
lib/librte_eal/common/include/rte_io_bitops.h
Quoted 12 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +12
-0+ +/** +* Set a bit to 1. +* +* @param nr +* The bit to set. +* @param addr +* The address to count from. +*/ +static inline void +rte_io_set_bit (uint32_t nr,uint64_t *addr) { +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); }
Some use cases might need 'release' or 'relaxed' memory order. Similar requirements apply to other APIs too.
Quoted 77 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +26
-0+ +/** +* Set a bit to 0. +* +* @param nr +* The bit to set. +* @param addr +* The address to count from. +*/ +static inline void +rte_io_clear_bit (int32_t nr,uint64_t *addr) { +__atomic_fetch_and (addr, ~(1UL << nr), __ATOMIC_ACQ_REL); } + +/** +* Test if a bit is 1. +* +* @param nr +* The bit to test. +* @param addr +* The address to count from. +* @return +* 1 if the bit is 1; else 0. +*/ +static inline int32_t +rte_io_test_bit (int32_t nr,uint64_t *addr) { + return (__atomic_load_n(addr, __ATOMIC_ACQUIRE) & (1UL <<nr)) != 0; }
lib/librte_eal/common/include/rte_io_bitops.h new file +16
-0+ +/** +* Set a bit to 1 and return its old value. +* +* @param nr +* The bit to set. +* @param addr +* The address to count from. +* @return +* The old value of the bit. +*/ +static inline int32_t +rte_io_test_and_set_bit (int32_t nr,uint64_t *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
lib/librte_eal/common/include/rte_io_bitops.h new file +16
-0+ +/** +* Set a bit to 0 and return its old value. +* +* @param nr +* The bit to set. +* @param addr +* The address to count from. +* @return +* The old value of the bit. +*/ +static inline int32_t +rte_io_test_and_clear_bit (int32_t nr,uint64_t *addr) { +unsigned long mask = (1UL << nr); + + return __atomic_fetch_and(addr, ~mask, __ATOMIC_ACQ_REL) &mask; }
lib/librte_eal/common/include/rte_io_bitops.h new file +1
-0+#endif /* _RTE_IO_BITOPS_H_ */ lib/librte_eal/common/meson.build +1
-1@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', + 'include/rte_io_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', --2.7.4
Re: [dpdk-dev] [PATCH v2 1/6] lib/eal: implement the family of rte bit operation APIs
In reply to Joyce KongQuoted 7 lines · Joyce Kong
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use
__ATOMIC_ACQ_RELto ensure the ordering.
Quoted 6 lines
Signed-off-by Joyce Kong <[email protected]>Reviewed-by Gavin Hu <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_io_bitops.h | 112 ++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 +
Missing doc/api/doxy-api-index.md update
Quoted 6 lines
3 files changed, 114 insertions(+) create mode 100644 lib/librte_eal/common/include/rte_io_bitops.hlib/librte_eal/common/include/rte_io_bitops.h new file +2
-0+ +/**
lib/librte_eal/common/include/rte_io_bitops.h line 27
Quoted 10 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +10
-0+* Get a bit. +* +* @param nr +* The bit to get. +* @param addr +* The address to count from. +* @return +* The value of the bit. +*/ +static inline int32_t
Missing __rte_experimental
Quoted 5 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +5
-0+rte_io_get_bit(uint32_t nr, uint64_t *addr) +{ + return __atomic_load_n(addr, __ATOMIC_ACQUIRE) & (1UL << nr); +} +
Re: [dpdk-dev] [PATCH v2 1/6] lib/eal: implement the family of rte bit operation APIs
In reply to Joyce KongQuoted 44 lines
-----Original Message-----
From: Joyce Kong [mailto:[email protected]]
Sent: Wednesday, October 23, 2019 4:55 AMThere are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, the bit operation is mostly applied to the IO devices, so use
__ATOMIC_ACQ_RELto ensure the ordering.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Gavin Hu <[email protected]>--- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_io_bitops.h | 112 ++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 3 files changed, 114 insertions(+) create mode 100644 lib/librte_eal/common/include/rte_io_bitops.hlib/librte_eal/common/Makefile +1
-0@@ -18,6 +18,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h +INC += rte_io_bitops.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h
rte_prefetch.h
GENERIC_INC+=rte_memcpy.hrte_cpuflags.hlib/librte_eal/common/include/rte_io_bitops.h new file +3
-0@@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/
lib/librte_eal/common/include/rte_io_bitops.h line 13
Quoted 10 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +10
-0+ +#ifndef _RTE_IO_BITOPS_H_ +#define _RTE_IO_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a generic API for bit operations. +*/
-> This file defines a generic API for I/O device bit operations.
lib/librte_eal/common/include/rte_io_bitops.h line 15
Quoted 2 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +2
-0+ +#include <rte_lcore.h>
This library doesn't do any lcore operations. Please use the appropriate headers.
lib/librte_eal/common/include/rte_io_bitops.h line 23
Quoted 8 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +8
-0+ +/** +* Get a bit. +* +* @param nr +* The bit to get. +* @param addr +* The address to count from.
The address to count from. -> The address holding the bit. (Applies to all functions.)
lib/librte_eal/common/include/rte_io_bitops.h line 25
Quoted 2 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +2
-0+* @return +* The value of the bit.
The description of the return value can be misinterpreted. The return value is not the value of the bit, which is 0 or 1, but the value of the word holding the bit, masked with the bit position. (Applies to all functions returning a value.)
lib/librte_eal/common/include/rte_io_bitops.h line 28
Quoted 3 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +3
-0+*/ +static inline int32_t +rte_io_get_bit (uint32_t nr,uint64_t *addr)
The return type should be an unsigned type. (Applies to all functions returning a value.)
The addr type for 32 bit operations should not be uint64_t *, but uint32_t *. The __atomic_xxx functions actually use this type for something, and I think it would access the wrong 32 bits on a big endian CPU.
In some of the functions below, nr is signed (int32_t); it should be unsigned (uint32_t).
And a suggestion: Consider changing the type of nr from uint32_t to unsigned int.
Quoted 46 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +46
-0+{ +return __atomic_load_n (addr, __ATOMIC_ACQUIRE) & (1UL << nr); +} + +/** +* Set a bit to 1. +* +* @param nr +* The bit to set. +* @param addr +* The address to count from. +*/ +static inline void +rte_io_set_bit (uint32_t nr,uint64_t *addr) +{ +__atomic_fetch_or (addr, (1UL << nr), __ATOMIC_ACQ_REL); +} + +/** +* Set a bit to 0. +* +* @param nr +* The bit to set. +* @param addr +* The address to count from. +*/ +static inline void +rte_io_clear_bit (int32_t nr,uint64_t *addr) +{ +__atomic_fetch_and (addr, ~(1UL << nr), __ATOMIC_ACQ_REL); +} + +/** +* Test if a bit is 1. +* +* @param nr +* The bit to test. +* @param addr +* The address to count from. +* @return +* 1 if the bit is 1; else 0. +*/ +static inline int32_t +rte_io_test_bit (int32_t nr,uint64_t *addr) +{ + return (__atomic_load_n(addr, __ATOMIC_ACQUIRE) & (1UL << nr)) !=
Quoted 2 lines
0;
+}
All the other functions in this library return a word with the bit masked. This function returns 0 or 1. I think it should return a word value, similar to the other functions.
Quoted 5 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +5
-0+ +/** +* Set a bit to 1 and return its old value. +* +* @param nr
lib/librte_eal/common/include/rte_io_bitops.h line 90
Quoted 10 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +10
-0+* The bit to set. +* @param addr +* The address to count from. +* @return +* The old value of the bit. +*/ +static inline int32_t +rte_io_test_and_set_bit (int32_t nr,uint64_t *addr) +{ +unsigned long mask = (1UL << nr);
unsigned long mask -> uint32_t mask. (Also applies to other functions.)
Quoted 38 lines
lib/librte_eal/common/include/rte_io_bitops.h new file +22
-0+ + return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) & mask; +} + +/** +* Set a bit to 0 and return its old value. +* +* @param nr +* The bit to set. +* @param addr +* The address to count from. +* @return +* The old value of the bit. +*/ +static inline int32_t +rte_io_test_and_clear_bit (int32_t nr,uint64_t *addr) +{ +unsigned long mask = (1UL << nr); + +return __atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL) & mask; +} +#endif /* _RTE_IO_BITOPS_H_ */ lib/librte_eal/common/meson.build +1
-1@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', + 'include/rte_io_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', --2.7.4
PATCH v2 2/6 test/iobitops: add io bit operation test case
In reply to Joyce KongAdd test cases for set bit, clear bit, test and set bit, test and clear bit operations.
--- app/test/Makefile | 1 + app/test/test_io_bitops.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 app/test/test_io_bitops.c
app/test/Makefile +1 -0
@@ -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_io_bitops.c SRCS-y += test_reciprocal_division.c SRCS-y += test_reciprocal_division_perf.c SRCS-y += test_fbarray.c
app/test/test_io_bitops.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 3/6 net/axgbe: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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_mdio.c | 14 +++++++------- 3 files changed, 15 insertions(+), 42 deletions(-)
drivers/net/axgbe/axgbe_common.h +1 -28
@@ -22,6 +22,7 @@#include <pthread.h> #include <rte_byteorder.h> +#include <rte_io_bitops.h> #include <rte_memory.h> #include <rte_malloc.h> #include <rte_hexdump.h>
@@ -1674,34 +1675,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
@@ -201,8 +201,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_io_clear_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_io_clear_bit (AXGBE_DOWN , &pdata->dev_state);return 0 ; }
@@ -216,17 +216,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_io_test_bit (AXGBE_STOPPED , &pdata->dev_state))return ; -axgbe_set_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_io_set_bit (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_io_set_bit (AXGBE_DOWN , &pdata->dev_state); }/* Clear all resources like TX/RX queues. */
@@ -598,8 +598,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_io_set_bit (AXGBE_DOWN , &pdata->dev_state); +rte_io_set_bit (AXGBE_STOPPED , &pdata->dev_state); pdata->eth_dev = eth_dev; pci_dev =RTE_DEV_TO_PCI (eth_dev->device);
drivers/net/axgbe/axgbe_mdio.c +7 -7
@@ -743,7 +743,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) {int ret; -axgbe_set_bit (AXGBE_LINK_INIT , &pdata->dev_state); +rte_io_set_bit (AXGBE_LINK_INIT , &pdata->dev_state); pdata->link_check =rte_get_timer_cycles (); ret = pdata->phy_if.phy_impl.an_config (pdata);
@@ -807,9 +807,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_io_set_bit (AXGBE_LINK_ERR , &pdata->dev_state);else -axgbe_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state); +rte_io_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state);pthread_mutex_unlock (&pdata->an_mutex);
@@ -880,7 +880,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)unsigned int link_aneg;int an_restart; -if (axgbe_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { +if (rte_io_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { pdata->phy.link =0 ; goto adjust_link; }
@@ -900,10 +900,10 @@ static void axgbe_phy_status(struct axgbe_port *pdata)return ; }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_io_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) +rte_io_clear_bit (AXGBE_LINK_INIT , &pdata->dev_state); }else { -if (axgbe_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) { +if (rte_io_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) {axgbe_check_link_timeout (pdata);if (link_aneg)
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v2 3/6] net/axgbe: use common rte bit operation APIs instead
<snip>
Quoted 29 lines
Remove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
Signed-off-by Joyce Kong <[email protected]>Reviewed-by Gavin Hu <[email protected]>--- drivers/net/axgbe/axgbe_common.h | 29 +---------------------------- drivers/net/axgbe/axgbe_ethdev.c | 14 +++++++------- drivers/net/axgbe/axgbe_mdio.c | 14 +++++++------- 3 files changed, 15 insertions(+), 42 deletions(-)drivers/net/axgbe/axgbe_common.h +1
-0@@ -22,6 +22,7 @@#include <pthread.h> #include <rte_byteorder.h> +#include <rte_io_bitops.h> #include <rte_memory.h> #include <rte_malloc.h> #include <rte_hexdump.h> @@ -1674,34 +1675,6 @@ do { \#define time_after_eq (a, b) ((long)((a) - (b)) >= 0)#define time_before_eq (a, b) time_after_eq(b, a)
drivers/net/axgbe/axgbe_common.h do { · line 1686
Quoted 10 lines
drivers/net/axgbe/axgbe_common.h +0
-9-/*---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; -}
This function uses rte_mb before and after the load. Where as the new API uses just 'acquire', please ensure 'acquire' is enough.
Quoted 121 lines
drivers/net/axgbe/axgbe_common.h +0
-17- -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); diff --git
a/drivers/net/axgbe/axgbe_ethdev.cb/drivers/net/axgbe/axgbe_ethdev.cindex d1f160e..8c8e5ff 100644drivers/net/axgbe/axgbe_ethdev.c +5
-5@@ -201,8 +201,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_io_clear_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_io_clear_bit (AXGBE_DOWN , &pdata->dev_state);return 0 ; }@@ -216,17 +216,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_io_test_bit (AXGBE_STOPPED , &pdata->dev_state))return ; -axgbe_set_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_io_set_bit (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_io_set_bit (AXGBE_DOWN , &pdata->dev_state); } /* Clear all resources like TX/RX queues. */ @@ -598,8 +598,8 @@
eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)drivers/net/axgbe/axgbe_ethdev.c +2
-2pdata = eth_dev->data->dev_private;/* initial state */ -axgbe_set_bit (AXGBE_DOWN , &pdata->dev_state); -axgbe_set_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_io_set_bit (AXGBE_DOWN , &pdata->dev_state); +rte_io_set_bit (AXGBE_STOPPED , &pdata->dev_state); pdata->eth_dev = eth_dev; pci_dev = RTE_DEV_TO_PCI(eth_dev->device); diff --git
a/drivers/net/axgbe/axgbe_mdio.cb/drivers/net/axgbe/axgbe_mdio.cindex 2721e5c..4164564 100644drivers/net/axgbe/axgbe_mdio.c +4
-4@@ -743,7 +743,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) {int ret; -axgbe_set_bit (AXGBE_LINK_INIT , &pdata->dev_state); +rte_io_set_bit (AXGBE_LINK_INIT , &pdata->dev_state); pdata->link_check =rte_get_timer_cycles (); ret = pdata->phy_if.phy_impl.an_config (pdata);@@ -807,9 +807,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_io_set_bit (AXGBE_LINK_ERR , &pdata->dev_state);else -axgbe_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state); +rte_io_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state);pthread_mutex_unlock (&pdata->an_mutex);@@ -880,7 +880,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)unsigned int link_aneg;int an_restart; -if (axgbe_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { +if (rte_io_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { pdata->phy.link =0 ; goto adjust_link;drivers/net/axgbe/axgbe_mdio.c +3
-3}@@ -900,10 +900,10 @@ static void axgbe_phy_status(struct axgbe_port *pdata)return ; }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_io_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) +rte_io_clear_bit (AXGBE_LINK_INIT , &pdata- >dev_state); }else { -if (axgbe_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) { +if (rte_io_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) {drivers/net/axgbe/axgbe_mdio.c +0
-1axgbe_check_link_timeout (pdata);if (link_aneg) --2.7.4
PATCH v2 4/6 net/bnx2x: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/bnx2x/bnx2x.c | 209 +++++++++++++++++++------------------------ drivers/net/bnx2x/bnx2x.h | 4 - drivers/net/bnx2x/ecore_sp.h | 9 +- 3 files changed, 98 insertions(+), 124 deletions(-)
drivers/net/bnx2x/bnx2x.c +93 -116
@@ -26,6 +26,7 @@#include <fcntl.h> #include <zlib.h> #include <rte_string_fns.h> +#include <rte_io_bitops.h> #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"#define BNX2X_PMD_VERSION_MAJOR 1
@@ -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);
@@ -1427,11 +1402,11 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,/* wait for completion of requested */ if (wait_for_comp) { -bnx2x_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); +rte_io_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); }/* Set the mac type of addresses we want to clear */ -bnx2x_set_bit (mac_type, &vlan_mac_flags); +rte_io_set_bit (mac_type, &vlan_mac_flags); rc = mac_obj->delete_all (sc, mac_obj, &vlan_mac_flags, &ramrod_flags);if (rc <0 )
@@ -1458,26 +1433,26 @@ 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_io_set_bit (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_io_set_bit (ECORE_ACCEPT_MULTICAST , rx_accept_flags); +rte_io_set_bit (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_io_set_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_io_set_bit (ECORE_ACCEPT_MULTICAST , tx_accept_flags); +rte_io_set_bit (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_io_set_bit (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_io_set_bit (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_io_set_bit (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_io_set_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_io_set_bit (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_io_set_bit (ECORE_ACCEPT_BROADCAST , tx_accept_flags);break ;
@@ -1488,19 +1463,20 @@ 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_io_set_bit (ECORE_ACCEPT_UNMATCHED , rx_accept_flags); +rte_io_set_bit (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_io_set_bit (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_io_set_bit (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_io_set_bit (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_io_set_bit (ECORE_ACCEPT_BROADCAST , tx_accept_flags);if (IS_MF_SI (sc)) { -bnx2x_set_bit (ECORE_ACCEPT_ALL_UNICAST , tx_accept_flags); +rte_io_set_bit (ECORE_ACCEPT_ALL_UNICAST , + tx_accept_flags); }else { -bnx2x_set_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_io_set_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); }break ;
@@ -1512,8 +1488,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_io_set_bit(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags; +rte_io_set_bit (ECORE_ACCEPT_ANY_VLAN , tx_accept_flags); }return 0 ;
@@ -1542,7 +1518,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_io_set_bit (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); ramrod_param.ramrod_flags = ramrod_flags; ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1571,9 +1547,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_io_set_bit (RAMROD_RX , &ramrod_flags); +rte_io_set_bit (RAMROD_TX , &ramrod_flags); +rte_io_set_bit (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,
@@ -1698,7 +1674,7 @@ 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_io_set_bit (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);/* STARTED-->TX_STOPPED */ func_params.cmd =ECORE_F_CMD_TX_STOP ;
@@ -1722,7 +1698,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_io_set_bit (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* Stop the primary connection: */
@@ -1783,7 +1759,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_io_set_bit (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_STOP ;
@@ -1797,7 +1773,7 @@ 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_io_set_bit (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);return ecore_func_state_change (sc, &func_params); }
@@ -1809,7 +1785,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_io_set_bit (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_RESET ;
@@ -1866,11 +1842,10 @@ 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_io_test_bit (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state)) +rte_io_set_bit (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;
@@ -1960,12 +1935,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_io_set_bit (RAMROD_COMP_WAIT , &ramrod_flags);/* Perform a dry cleanup */ -bnx2x_set_bit (RAMROD_DRV_CLR_ONLY , &ramrod_flags); +rte_io_set_bit (RAMROD_DRV_CLR_ONLY , &ramrod_flags);/* Clean ETH primary MAC */ -bnx2x_set_bit (ECORE_ETH_MAC , &vlan_mac_flags); +rte_io_set_bit (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 ) {
@@ -1974,7 +1949,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_io_set_bit (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,
@@ -1984,7 +1959,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_io_set_bit (RAMROD_DRV_CLR_ONLY , &rparam.ramrod_flags);/* Add a DEL command... */ rc =ecore_config_mcast (sc, &rparam,ECORE_MCAST_CMD_DEL );
@@ -4288,7 +4263,7 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estruct ecore_vlan_mac_obj *vlan_mac_obj;/* always push next commands out, don't wait here */ -bnx2x_set_bit (RAMROD_CONT , &ramrod_flags); +rte_io_set_bit (RAMROD_CONT , &ramrod_flags);switch (le32toh (elem->message.data.eth_event.echo) >>BNX2X_SWCID_SHIFT ) {case ECORE_FILTER_MAC_PENDING :
@@ -4319,12 +4294,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estatic void bnx2x_handle_rx_mode_eqe (struct bnx2x_softc *sc) { -bnx2x_clear_bit (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); +rte_io_clear_bit (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_io_test_and_clear_bit (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)
@@ -4693,7 +4668,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_io_set_bit (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_INIT ;
@@ -4988,8 +4963,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_io_set_bit (ECORE_Q_TYPE_HAS_RX , &q_type); +rte_io_set_bit (ECORE_Q_TYPE_HAS_TX , &q_type); ecore_init_queue_obj(sc, &sc->sp_objs[idx].q_obj,
@@ -5803,7 +5778,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_io_set_bit (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_START ;
@@ -6379,11 +6354,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_io_set_bit (ECORE_Q_FLG_HC , &init_params->rx.flags); +rte_io_set_bit (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_io_set_bit (ECORE_Q_FLG_HC_EN , &init_params->rx.flags); +rte_io_set_bit (ECORE_Q_FLG_HC_EN , &init_params->tx.flags);/* HC rate */ init_params->rx.hc_rate =
@@ -6417,7 +6392,7 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)unsigned long flags =0 ;/* PF driver will always initialize the Queue to an ACTIVE state */ -bnx2x_set_bit (ECORE_Q_FLG_ACTIVE , &flags); +rte_io_set_bit (ECORE_Q_FLG_ACTIVE , &flags);/* * tx only connections collect statistics (on the same index as the
@@ -6425,9 +6400,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_io_set_bit (ECORE_Q_FLG_STATS , &flags);if (zero_stats) { -bnx2x_set_bit (ECORE_Q_FLG_ZERO_STATS , &flags); +rte_io_set_bit (ECORE_Q_FLG_ZERO_STATS , &flags); }/*
@@ -6435,10 +6410,10 @@ 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_io_set_bit (ECORE_Q_FLG_TX_SWITCH , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_PCSUM_ON_PKT , &flags); +rte_io_set_bit (ECORE_Q_FLG_PCSUM_ON_PKT , &flags);return flags; }
@@ -6448,15 +6423,15 @@ static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)unsigned long flags =0 ;if (IS_MF_SD (sc)) { -bnx2x_set_bit (ECORE_Q_FLG_OV , &flags); +rte_io_set_bit (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_io_set_bit (ECORE_Q_FLG_LEADING_RSS , &flags); +rte_io_set_bit (ECORE_Q_FLG_MCAST , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_VLAN , &flags); +rte_io_set_bit (ECORE_Q_FLG_VLAN , &flags);/* merge with common flags */ return flags |bnx2x_get_common_flags (sc, TRUE);
@@ -6577,7 +6552,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_io_set_bit (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* prepare the INIT parameters */ bnx2x_pf_q_prep_init (sc, fp, &q_params.params.init);
@@ -6645,20 +6620,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 , ¶ms.ramrod_flags); +rte_io_set_bit (RAMROD_COMP_WAIT , ¶ms.ramrod_flags); -bnx2x_set_bit (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags); +rte_io_set_bit (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags);/* RSS configuration */ -bnx2x_set_bit (ECORE_RSS_IPV4 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags); +rte_io_set_bit (ECORE_RSS_IPV4 , ¶ms.rss_flags); +rte_io_set_bit (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); +rte_io_set_bit (ECORE_RSS_IPV6 , ¶ms.rss_flags); +rte_io_set_bit (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags);if (rss_obj->udp_rss_v4) { -bnx2x_set_bit (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); +rte_io_set_bit (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); }if (rss_obj->udp_rss_v6) { -bnx2x_set_bit (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); +rte_io_set_bit (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); }/* Hash bits */
@@ -6673,7 +6648,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 , ¶ms.rss_flags); +rte_io_set_bit (ECORE_RSS_SET_SRCH , ¶ms.rss_flags); }if (IS_PF (sc))
@@ -6730,11 +6705,11 @@ 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_io_test_bit (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_io_set_bit (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 :
@@ -6761,7 +6736,7 @@ static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)PMD_DRV_LOG (DEBUG , sc,"Adding Ethernet MAC" ); -bnx2x_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); +rte_io_set_bit (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,
@@ -6893,24 +6868,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_io_set_bit (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_io_set_bit (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_io_set_bit (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_io_set_bit (BNX2X_LINK_REPORT_TX_FC_ON , + &data->link_report_flags); } }
@@ -6929,9 +6906,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_io_test_bit (BNX2X_LINK_REPORT_LINK_DOWN , &sc->last_reported_link.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_LINK_DOWN , +rte_io_test_bit (BNX2X_LINK_REPORT_LINK_DOWN , &cur_data.link_report_flags))) {return ; }
@@ -6946,14 +6923,14 @@ 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_io_test_bit (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 , +if (rte_io_test_and_clear_bit (BNX2X_LINK_REPORT_FULL_DUPLEX , &cur_data.link_report_flags)) { duplex ="full" ;ELINK_DEBUG_P0 (sc,"link set to full duplex" );
@@ -6968,19 +6945,19 @@ 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_io_test_bit (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_io_test_bit (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 , + }else if (rte_io_test_bit (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && - !bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , + !rte_io_test_bit (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_io_test_bit (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_io_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , &cur_data.link_report_flags)) { flow ="ON - transmit" ; }else {
drivers/net/bnx2x/bnx2x.h +0 -4
@@ -1809,10 +1809,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 +5 -4
@@ -15,6 +15,7 @@#define ECORE_SP_H #include <rte_byteorder.h> +#include <rte_io_bitops.h> #if RTE_BYTE_ORDER ==RTE_LITTLE_ENDIAN #ifndef __LITTLE_ENDIAN
@@ -73,10 +74,10 @@ 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_io_test_bit(bit, var) +#define ECORE_SET_BIT (bit, var) rte_io_set_bit(bit, var) +#define ECORE_CLEAR_BIT (bit, var) rte_io_clear_bit(bit, var) +#define ECORE_TEST_AND_CLEAR_BIT (bit, var) rte_io_test_and_clear_bit(bit, var)#define atomic_load_acq_int (int)*#define atomic_store_rel_int (a, v) (*a = v)
Signature · 1 line
2.7.4
PATCH v2 5/6 net/hinic: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/hinic/base/hinic_compat.h | 35 +---------------------------------- drivers/net/hinic/hinic_pmd_ethdev.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 42 deletions(-)
drivers/net/hinic/base/hinic_compat.h +1 -34
@@ -11,6 +11,7 @@#include <pthread.h> #include <rte_common.h> #include <rte_byteorder.h> +#include <rte_io_bitops.h> #include <rte_memzone.h> #include <rte_memcpy.h> #include <rte_malloc.h>
@@ -117,40 +118,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; - -rte_mb (); - res = ((*addr) & (1UL << nr)) !=0 ; -rte_mb (); -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 +8 -8
@@ -227,7 +227,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_io_test_bit (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 ;
@@ -907,7 +907,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_io_set_bit (HINIC_DEV_START , &nic_dev->dev_status);return 0 ;
@@ -1030,7 +1030,7 @@ 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_io_test_and_clear_bit (HINIC_DEV_START , &nic_dev->dev_status)) {PMD_DRV_LOG (INFO ,"Device %s already stopped" , name);return ; }
@@ -1073,7 +1073,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_io_clear_bit (HINIC_DEV_INTR_EN , &nic_dev->dev_status);/* disable msix interrupt in hardware */ hinic_set_msix_state (nic_dev->hwdev,0 ,HINIC_MSIX_DISABLE );
@@ -2197,9 +2197,9 @@ 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_io_set_bit (HINIC_DEV_INTR_EN , &nic_dev->dev_status); -hinic_set_bit (HINIC_DEV_INIT , &nic_dev->dev_status); +rte_io_set_bit (HINIC_DEV_INIT , &nic_dev->dev_status);PMD_DRV_LOG (INFO ,"Initialize %s in primary successfully" , eth_dev->data->name);
@@ -2236,7 +2236,7 @@ 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_io_test_and_set_bit (HINIC_DEV_CLOSE , &nic_dev->dev_status)) {PMD_DRV_LOG (WARNING ,"Device %s already closed" , dev->data->name);return ;
@@ -2316,7 +2316,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_io_clear_bit (HINIC_DEV_INIT , &nic_dev->dev_status);if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ;
Signature · 1 line
2.7.4
PATCH v2 6/6 net/qede: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/qede/base/bcm_osal.c | 20 -------------------- drivers/net/qede/base/bcm_osal.h | 10 ++++------ 2 files changed, 4 insertions(+), 26 deletions(-)
drivers/net/qede/base/bcm_osal.c +0 -20
@@ -45,26 +45,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;
drivers/net/qede/base/bcm_osal.h +4 -6
@@ -8,6 +8,7 @@#define __BCM_OSAL_H#include <rte_byteorder.h> +#include <rte_io_bitops.h> #include <rte_spinlock.h> #include <rte_malloc.h> #include <rte_atomic.h>
@@ -311,17 +312,14 @@ 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_io_set_bit(bit, bitmap) -void qede_clr_bit (u32 ,unsigned long *);#define OSAL_CLEAR_BIT (bit, bitmap) \ - qede_clr_bit(bit, bitmap) + rte_io_clear_bit(bit, bitmap) -bool qede_test_bit (u32 ,unsigned long *);#define OSAL_TEST_BIT (bit, bitmap) \ - qede_test_bit(bit, bitmap) + rte_io_test_bit(bit, bitmap)u32 qede_find_first_bit (unsigned long *,u32 );#define OSAL_FIND_FIRST_BIT (bitmap, length) \
Signature · 1 line
2.7.4
Quoted 5 lines · Joyce Kong
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
Quoted 7 lines
v2:
1. Add doxygen comments for the rte bit operation API(suggested by Stephen Hemminger).
2. Add test cases for common rte bit operation API(suggested by Stephen Hemminger).
3. Change the header file torte_io_bitops.hand the operation to rte_io_set_bit()etc., as the API uses barriers inside and the barriers are only needed for IO operations (suggested by Jerin Jacob).
4. Use an well defineduint_NN_ttype(suggested by Morten Brørup).
Thanks for working on this.
This series is a cleanup and worth looking at, yet it came rather late.
Discussion and enhancement can still continue, but it will be deferred to 20.02.
--
David Marchand
23/10/2019 04:54, Joyce Kong:
Quoted 3 lines
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
Please, could you look at what Adrien did in the Mellanox PMD?
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5_utils.h#L28
Hi Thomas,
Quoted 14 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 30, 2019 12:43 AM
To: Joyce Kong (Arm Technology China) <[email protected]>
Cc: [email protected]; nd <[email protected]>; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 0/6] implement common rte bit operation APIs in PMDs
Quoted 8 lines
23/10/2019 04:54, Joyce Kong:
Quoted 3 lines
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
Please, could you look at what Adrien did in the Mellanox PMD?
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5_utils.h#L28
The code has less duplication, but it requires a less natural declaration of variables
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5.h#L607
Should we take this way?
/Gavin
Quoted 2 lines
30/10/2019 10:55, Gavin Hu (Arm Technology China):
Quoted 8 lines
Hi Thomas,
From: Thomas Monjalon <[email protected]>
Quoted 5 lines
23/10/2019 04:54, Joyce Kong:
Quoted 3 lines
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
Quoted 6 lines
Quoted 3 lines
Please, could you look at what Adrien did in the Mellanox PMD?
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5_utils.h#L28
The code has less duplication, but it requires a less natural declaration of variables
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5.h#L607
Should we take this way?
I don't know which way is best.
I suggested to read this code for 2 reasons:
1. we can be inspired
2. it may be replaced by the new common API as you did for other drivers
Quoted 22 lines · Gavin Hu (Arm Technology China)
Hi Thomas,
Quoted 19 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 30, 2019 12:43 AM
To: Joyce Kong (Arm Technology China) <[email protected]>
Cc: [email protected]; nd <[email protected]>; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 0/6] implement common rte bit operation APIs in PMDs23/10/2019 04:54, Joyce Kong:
Quoted 3 lines
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
Quoted 6 lines
Quoted 3 lines
Please, could you look at what Adrien did in the Mellanox PMD?
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5_utils.h#L28
The code has less duplication, but it requires a less natural declaration of variables
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5.h#L607
Should we take this way?
IMO, We need to consider the MACRO based scheme only as of the last resort.
Quoted 4 lines
/Gavin
Quoted 2 lines
Quoted 21 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jerin Jacob
Sent: Wednesday, October 30, 2019 1:33 PMQuoted 15 lines · Gavin Hu (Arm Technology China)
Hi Thomas,
Quoted 12 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 30, 2019 12:43 AM23/10/2019 04:54, Joyce Kong:
Quoted 3 lines
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
Please, could you look at what Adrien did in the Mellanox PMD?
Quoted 9 lines
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5_utils.h#L28
Quoted 1 line
The code has less duplication, but it requires a less natural declaration
of variables
Quoted 2 lines
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5.h#L607
Should we take this way?IMO, We need to consider the MACRO based scheme only as of the last resort.
I agree.
The EAL library already has an I/O device memory access API, i.e. with functionality closely related to the proposed I/O device bit operation API:
http://code.dpdk.org/dpdk/latest/source/lib/librte_eal/common/include/generic/rte_io.h
I would prefer a similar approach, and API familiarity would be my strongest argument.
Quoted 48 lines
-----Original Message-----
From: Morten Brørup <[email protected]>
Sent: Wednesday, October 30, 2019 9:02 PM
To: Jerin Jacob <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>
Cc: [email protected]; Joyce Kong (Arm Technology China) <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [dpdk-dev] [PATCH v2 0/6] implement common rte bit operation APIs in PMDsQuoted 21 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jerin Jacob
Sent: Wednesday, October 30, 2019 1:33 PMQuoted 15 lines · Gavin Hu (Arm Technology China)
Hi Thomas,
Quoted 12 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 30, 2019 12:43 AM23/10/2019 04:54, Joyce Kong:
Quoted 3 lines
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
Please, could you look at what Adrien did in the Mellanox PMD?
Quoted 9 lines
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5_utils.h#L28
Quoted 1 line
The code has less duplication, but it requires a less natural declaration
of variables
Quoted 2 lines
http://code.dpdk.org/dpdk/latest/source/drivers/net/mlx5/mlx5.h#L607
Should we take this way?IMO, We need to consider the MACRO based scheme only as of the last resort.
I agree.
Quoted 7 lines
The EAL library already has an I/O device memory access API, i.e. with functionality closely related to the proposed I/O device bit operation API:
http://code.dpdk.org/dpdk/latest/source/lib/librte_eal/common/include/generic/rte_io.hI would prefer a similar approach, and API familiarity would be my strongest argument.
Yes, this is a more natural way, and engineers are more familiar with the APIs.
We will take this way as more people vote for this.
Thanks Thomas also for your comment, we are inspired by this code, we will add assert() also to guarantee the 'bit' argument is in the valid range. We used this common API for some PMDs, but not extensively, the reason is we want to finalize the API firstly(with your comments coming) and then propagate later. /Gavin
v3 cover implement common rte bit operation APIs in PMDs
In reply to Joyce KongThere are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
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(suggested by Stephen Hemminger).
2. Add test cases for common rte bit operation API(suggested by Stephen Hemminger).
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 (suggested by Jerin Jacob).
4. Use an well defined uint_NN_t type(suggested by Morten Brørup).
Joyce Kong (6):
lib/eal: implement the family of rte 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
app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/meson.build | 2 + app/test/test_bitops.c | 303 +++++++++++++ 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_mdio.c | 14 +- drivers/net/bnx2x/bnx2x.c | 209 ++++----- drivers/net/bnx2x/bnx2x.h | 4 - drivers/net/bnx2x/ecore_sp.h | 9 +- drivers/net/hinic/Makefile | 1 + drivers/net/hinic/base/hinic_compat.h | 33 +- drivers/net/hinic/hinic_pmd_ethdev.c | 16 +- drivers/net/hinic/meson.build | 2 + drivers/net/qede/base/bcm_osal.c | 20 - drivers/net/qede/base/bcm_osal.h | 10 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 20 files changed, 919 insertions(+), 233 deletions(-) create mode 100644 app/test/test_bitops.c create mode 100644 lib/librte_eal/common/include/rte_bitops.h
Signature · 1 line
2.17.1
PATCH v3 1/6 lib/eal: implement the family of rte bit operation APIs
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, when the bit operation is applied to the IO devices, use __ATOMIC_ACQ_REL to ensure the ordering for io bit operation.
--- doc/api/doxy-api-index.md | 3 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + 4 files changed, 478 insertions(+), 1 deletion(-) create mode 100644 lib/librte_eal/common/include/rte_bitops.h
doc/api/doxy-api-index.md +2 -1
@@ -181,4 +181,5 @@ The public API headers are grouped by topics: [common] (@ref rte_common.h), [experimental APIs] (@ref rte_compat.h), [ABI versioning] (@ref rte_function_versioning.h), - [version] (@ref rte_version.h) + [version] (@ref rte_version.h), + [bitops] (@ref rte_bitops.h)
lib/librte_eal/common/Makefile +1 -0
@@ -19,6 +19,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h +INC += rte_bitops.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.h
lib/librte_eal/common/include/rte_bitops.h new file +474 -0
474 lines not on this page · raw message
lib/librte_eal/common/meson.build +1 -0
@@ -52,6 +52,7 @@ common_headers = files( 'include/rte_alarm.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', + 'include/rte_bitops.h', 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h',
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 1/6] lib/eal: implement the family of rte bitoperation APIs
Quoted 4 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong
Sent: Monday, November 18, 2019 11:07 AM
[snip]
Quoted 38 lines
+++
b/lib/librte_eal/common/include/rte_bitops.hlib/librte_eal/common/include/rte_bitops.h new file +12
-0@@ -0,0 +1,474 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a API for bit operations without/with memory ordering.
+ */lib/librte_eal/common/include/rte_bitops.h new file +10
-1+ +#include <stdint.h> +#include <assert.h> +#include <rte_compat.h> + +/*---------------------------- 32 bit operations --------------------- -------*/ + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the target bit from a 32-bit value without memory ordering.
+ *
+ * @param nr
+ * The target bit to get.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The target bit.
+ */
lib/librte_eal/common/include/rte_bitops.h line 42
Quoted 9 lines
lib/librte_eal/common/include/rte_bitops.h new file +9
-0+__rte_experimental +static inline uint32_t +rte_get_bit32_relaxed (unsigned int nr,unsigned long *addr) +{ +assert (nr <32 ); + +uint32_t mask =1UL << nr; +return __atomic_load_n (addr, __ATOMIC_RELAXED) & mask; +}
Address pointer should be: uint32_t *addr.
Likewise in the other 32 bit functions.
Use RTE_ASSERT() instead of assert().
Likewise in all other functions.
When setting the mask, consider using UINT32_C(1) from <stdint.h> instead of 1UL.
[snip]
Quoted 18 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-1+ +/*---------------------------- 64 bit operations --------------------- -------*/ + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the target bit from a 64-bit value without memory ordering.
+ *
+ * @param nr
+ * The target bit to get.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The target bit.
+ */
lib/librte_eal/common/include/rte_bitops.h line 270
Quoted 9 lines
lib/librte_eal/common/include/rte_bitops.h new file +9
-0+__rte_experimental +static inline uint64_t +rte_get_bit64_relaxed (unsigned int nr,unsigned long *addr) +{ +assert (nr <64 ); + +uint64_t mask =1UL << nr; +return __atomic_load_n (addr, __ATOMIC_RELAXED) & mask; +}
Address pointer should be: uint64_t *addr.
Likewise in the other 64 bit functions.
Mask should be 1ULL, not 1UL. Or use UINT64_C(1) from <stdint.h> instead. Likewise in the other 64 bit functions.
[snip]
Med venlig hilsen / kind regards
- Morten Brørup
Re: [dpdk-dev] [PATCH v3 1/6] lib/eal: implement the family of rte bitoperation APIs
Hi Morten,
Quoted 109 lines
-----Original Message-----
From: Morten Brørup <[email protected]>
Sent: Monday, November 18, 2019 6:52 PM
To: Joyce Kong (Arm Technology China) <[email protected]>; [email protected]
Cc: nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [dpdk-dev] [PATCH v3 1/6] lib/eal: implement the family of rte bitoperation APIsQuoted 4 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong
Sent: Monday, November 18, 2019 11:07 AM[snip]
Quoted 39 lines
+++
b/lib/librte_eal/common/include/rte_bitops.hlib/librte_eal/common/include/rte_bitops.h new file +12
-0@@ -0,0 +1,474 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a API for bit operations without/with memory ordering.
+ */lib/librte_eal/common/include/rte_bitops.h new file +11
-1+ +#include <stdint.h> +#include <assert.h> +#include <rte_compat.h> + +/*---------------------------- 32 bit operations +--------------------- -------*/ + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the target bit from a 32-bit value without memory ordering.
+ *
+ * @param nr
+ * The target bit to get.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The target bit.
+ */lib/librte_eal/common/include/rte_bitops.h
Quoted 7 lines
lib/librte_eal/common/include/rte_bitops.h new file +7
-0+__rte_experimental +static inline uint32_t +rte_get_bit32_relaxed (unsigned int nr,unsigned long *addr) { +assert (nr <32 ); + +uint32_t mask =1UL << nr; +return __atomic_load_n (addr, __ATOMIC_RELAXED) & mask; }Address pointer should be:
uint32_t*addr.
Likewise in the other 32 bit functions.Use
RTE_ASSERT()instead ofassert().
Likewise in all other functions.When setting the mask, consider using
UINT32_C(1)from <stdint.h> instead of 1UL.[snip]
Quoted 19 lines
lib/librte_eal/common/include/rte_bitops.h new file +7
-1+ +/*---------------------------- 64 bit operations +--------------------- -------*/ + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the target bit from a 64-bit value without memory ordering.
+ *
+ * @param nr
+ * The target bit to get.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The target bit.
+ */lib/librte_eal/common/include/rte_bitops.h
Quoted 7 lines
lib/librte_eal/common/include/rte_bitops.h new file +7
-0+__rte_experimental +static inline uint64_t +rte_get_bit64_relaxed (unsigned int nr,unsigned long *addr) { +assert (nr <64 ); + +uint64_t mask =1UL << nr; +return __atomic_load_n (addr, __ATOMIC_RELAXED) & mask; }Address pointer should be:
uint64_t*addr.
Likewise in the other 64 bit functions.
Quoted 10 lines
Mask should be 1ULL, not 1UL. Or use
UINT64_C(1)from <stdint.h> instead. Likewise in the other 64 bit functions.[snip]
Med venlig hilsen / kind regards
- Morten Brørup
Thanks! I shall address above comments in Patch v4 for both 32-bit and 64-bit functions.
PATCH v3 2/6 test/bitops: add bit operation test case
In reply to Joyce KongAdd test cases for set bit, clear bit, test and set bit, test and clear bit operations.
--- app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/meson.build | 2 + app/test/test_bitops.c | 303 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 312 insertions(+) create mode 100644 app/test/test_bitops.c
app/test/Makefile +1 -0
@@ -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
@@ -404,6 +404,12 @@ "Func": default_autotest, "Report": None, }, + { + "Name": "Bitops autotest", + "Command": "bitops_autotest", + "Func": default_autotest, + "Report": None, + }, { "Name": "Hash multiwriter autotest", "Command": "hash_multiwriter_autotest",
app/test/meson.build +2 -0
@@ -14,6 +14,7 @@ test_sources = files('commands.c', 'test_atomic.c', 'test_barrier.c', 'test_bitratestats.c', + 'test_bitops.c', 'test_bpf.c', 'test_byteorder.c', 'test_cmdline.c',
@@ -167,6 +168,7 @@ fast_test_names = [ 'alarm_autotest', 'atomic_autotest', 'byteorder_autotest', + 'bitops_autotest', 'cmdline_autotest', 'common_autotest', 'cpuflags_autotest',
app/test/test_bitops.c new file +303 -0
303 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 3/6 net/axgbe: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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_mdio.c | 14 +++++++------- 3 files changed, 15 insertions(+), 42 deletions(-)
drivers/net/axgbe/axgbe_common.h +1 -28
@@ -22,6 +22,7 @@#include <pthread.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memory.h> #include <rte_malloc.h> #include <rte_hexdump.h>
@@ -1674,34 +1675,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
@@ -201,8 +201,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 (AXGBE_STOPPED , &pdata->dev_state); +rte_clear_bit32 (AXGBE_DOWN , &pdata->dev_state);return 0 ; }
@@ -216,17 +216,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 (AXGBE_STOPPED , &pdata->dev_state))return ; -axgbe_set_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_set_bit32 (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 (AXGBE_DOWN , &pdata->dev_state); }/* Clear all resources like TX/RX queues. */
@@ -598,8 +598,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 (AXGBE_DOWN , &pdata->dev_state); +rte_set_bit32 (AXGBE_STOPPED , &pdata->dev_state); pdata->eth_dev = eth_dev; pci_dev =RTE_DEV_TO_PCI (eth_dev->device);
drivers/net/axgbe/axgbe_mdio.c +7 -7
@@ -743,7 +743,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 (AXGBE_LINK_INIT , &pdata->dev_state); pdata->link_check =rte_get_timer_cycles (); ret = pdata->phy_if.phy_impl.an_config (pdata);
@@ -807,9 +807,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 (AXGBE_LINK_ERR , &pdata->dev_state);else -axgbe_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state); +rte_clear_bit32 (AXGBE_LINK_ERR , &pdata->dev_state);pthread_mutex_unlock (&pdata->an_mutex);
@@ -880,7 +880,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)unsigned int link_aneg;int an_restart; -if (axgbe_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { +if (rte_get_bit32 (AXGBE_LINK_ERR , &pdata->dev_state)) { pdata->phy.link =0 ; goto adjust_link; }
@@ -900,10 +900,10 @@ static void axgbe_phy_status(struct axgbe_port *pdata)return ; }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 (AXGBE_LINK_INIT , &pdata->dev_state)) +rte_clear_bit32 (AXGBE_LINK_INIT , &pdata->dev_state); }else { -if (axgbe_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) { +if (rte_get_bit32 (AXGBE_LINK_INIT , &pdata->dev_state)) {axgbe_check_link_timeout (pdata);if (link_aneg)
Signature · 1 line
2.17.1
PATCH v3 4/6 net/bnx2x: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/bnx2x/bnx2x.c | 209 ++++++++++++++++------------------- drivers/net/bnx2x/bnx2x.h | 4 - drivers/net/bnx2x/ecore_sp.h | 9 +- 3 files changed, 98 insertions(+), 124 deletions(-)
drivers/net/bnx2x/bnx2x.c +93 -116
@@ -26,6 +26,7 @@#include <fcntl.h> #include <zlib.h> #include <rte_string_fns.h> +#include <rte_bitops.h> #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"#define BNX2X_PMD_VERSION_MAJOR 1
@@ -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);
@@ -1427,11 +1402,11 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,/* wait for completion of requested */ if (wait_for_comp) { -bnx2x_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); +rte_set_bit32 (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 (mac_type, &vlan_mac_flags); rc = mac_obj->delete_all (sc, mac_obj, &vlan_mac_flags, &ramrod_flags);if (rc <0 )
@@ -1458,26 +1433,26 @@ 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 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_MULTICAST , rx_accept_flags); +rte_set_bit32 (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 (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_MULTICAST , tx_accept_flags); +rte_set_bit32 (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 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_set_bit32 (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 (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_BROADCAST , tx_accept_flags);break ;
@@ -1488,19 +1463,20 @@ 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 (ECORE_ACCEPT_UNMATCHED , rx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_set_bit32 (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 (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_BROADCAST , tx_accept_flags);if (IS_MF_SI (sc)) { -bnx2x_set_bit (ECORE_ACCEPT_ALL_UNICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_ALL_UNICAST , + tx_accept_flags); }else { -bnx2x_set_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_UNICAST , tx_accept_flags); }break ;
@@ -1512,8 +1488,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 (ECORE_ACCEPT_ANY_VLAN , rx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_ANY_VLAN , tx_accept_flags); }return 0 ;
@@ -1542,7 +1518,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 (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); ramrod_param.ramrod_flags = ramrod_flags; ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1571,9 +1547,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 (RAMROD_RX , &ramrod_flags); +rte_set_bit32 (RAMROD_TX , &ramrod_flags); +rte_set_bit32 (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,
@@ -1698,7 +1674,7 @@ 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 (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);/* STARTED-->TX_STOPPED */ func_params.cmd =ECORE_F_CMD_TX_STOP ;
@@ -1722,7 +1698,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 (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* Stop the primary connection: */
@@ -1783,7 +1759,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 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_STOP ;
@@ -1797,7 +1773,7 @@ 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 (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);return ecore_func_state_change (sc, &func_params); }
@@ -1809,7 +1785,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 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_RESET ;
@@ -1866,11 +1842,10 @@ 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 (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state)) +rte_set_bit32 (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;
@@ -1960,12 +1935,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 (RAMROD_COMP_WAIT , &ramrod_flags);/* Perform a dry cleanup */ -bnx2x_set_bit (RAMROD_DRV_CLR_ONLY , &ramrod_flags); +rte_set_bit32 (RAMROD_DRV_CLR_ONLY , &ramrod_flags);/* Clean ETH primary MAC */ -bnx2x_set_bit (ECORE_ETH_MAC , &vlan_mac_flags); +rte_set_bit32 (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 ) {
@@ -1974,7 +1949,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 (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,
@@ -1984,7 +1959,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 (RAMROD_DRV_CLR_ONLY , &rparam.ramrod_flags);/* Add a DEL command... */ rc =ecore_config_mcast (sc, &rparam,ECORE_MCAST_CMD_DEL );
@@ -4288,7 +4263,7 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estruct 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 (RAMROD_CONT , &ramrod_flags);switch (le32toh (elem->message.data.eth_event.echo) >>BNX2X_SWCID_SHIFT ) {case ECORE_FILTER_MAC_PENDING :
@@ -4319,12 +4294,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estatic void bnx2x_handle_rx_mode_eqe (struct bnx2x_softc *sc) { -bnx2x_clear_bit (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); +rte_clear_bit32 (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 (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)
@@ -4693,7 +4668,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 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_INIT ;
@@ -4988,8 +4963,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 (ECORE_Q_TYPE_HAS_RX , &q_type); +rte_set_bit32 (ECORE_Q_TYPE_HAS_TX , &q_type); ecore_init_queue_obj(sc, &sc->sp_objs[idx].q_obj,
@@ -5803,7 +5778,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 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_START ;
@@ -6379,11 +6354,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 (ECORE_Q_FLG_HC , &init_params->rx.flags); +rte_set_bit32 (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 (ECORE_Q_FLG_HC_EN , &init_params->rx.flags); +rte_set_bit32 (ECORE_Q_FLG_HC_EN , &init_params->tx.flags);/* HC rate */ init_params->rx.hc_rate =
@@ -6417,7 +6392,7 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)unsigned long flags =0 ;/* PF driver will always initialize the Queue to an ACTIVE state */ -bnx2x_set_bit (ECORE_Q_FLG_ACTIVE , &flags); +rte_set_bit32 (ECORE_Q_FLG_ACTIVE , &flags);/* * tx only connections collect statistics (on the same index as the
@@ -6425,9 +6400,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 (ECORE_Q_FLG_STATS , &flags);if (zero_stats) { -bnx2x_set_bit (ECORE_Q_FLG_ZERO_STATS , &flags); +rte_set_bit32 (ECORE_Q_FLG_ZERO_STATS , &flags); }/*
@@ -6435,10 +6410,10 @@ 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 (ECORE_Q_FLG_TX_SWITCH , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_PCSUM_ON_PKT , &flags); +rte_set_bit32 (ECORE_Q_FLG_PCSUM_ON_PKT , &flags);return flags; }
@@ -6448,15 +6423,15 @@ static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)unsigned long flags =0 ;if (IS_MF_SD (sc)) { -bnx2x_set_bit (ECORE_Q_FLG_OV , &flags); +rte_set_bit32 (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 (ECORE_Q_FLG_LEADING_RSS , &flags); +rte_set_bit32 (ECORE_Q_FLG_MCAST , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_VLAN , &flags); +rte_set_bit32 (ECORE_Q_FLG_VLAN , &flags);/* merge with common flags */ return flags |bnx2x_get_common_flags (sc, TRUE);
@@ -6577,7 +6552,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 (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* prepare the INIT parameters */ bnx2x_pf_q_prep_init (sc, fp, &q_params.params.init);
@@ -6645,20 +6620,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 , ¶ms.ramrod_flags); +rte_set_bit32 (RAMROD_COMP_WAIT , ¶ms.ramrod_flags); -bnx2x_set_bit (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags);/* RSS configuration */ -bnx2x_set_bit (ECORE_RSS_IPV4 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV4 , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV6 , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags);if (rss_obj->udp_rss_v4) { -bnx2x_set_bit (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); }if (rss_obj->udp_rss_v6) { -bnx2x_set_bit (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); }/* Hash bits */
@@ -6673,7 +6648,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 , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_SET_SRCH , ¶ms.rss_flags); }if (IS_PF (sc))
@@ -6730,11 +6705,11 @@ 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 (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 (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 :
@@ -6761,7 +6736,7 @@ static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)PMD_DRV_LOG (DEBUG , sc,"Adding Ethernet MAC" ); -bnx2x_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); +rte_set_bit32 (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,
@@ -6893,24 +6868,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 (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 (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 (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 (BNX2X_LINK_REPORT_TX_FC_ON , + &data->link_report_flags); } }
@@ -6929,9 +6906,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 (BNX2X_LINK_REPORT_LINK_DOWN , &sc->last_reported_link.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_LINK_DOWN , +rte_get_bit32 (BNX2X_LINK_REPORT_LINK_DOWN , &cur_data.link_report_flags))) {return ; }
@@ -6946,14 +6923,14 @@ 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 (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 , +if (rte_test_and_clear_bit32 (BNX2X_LINK_REPORT_FULL_DUPLEX , &cur_data.link_report_flags)) { duplex ="full" ;ELINK_DEBUG_P0 (sc,"link set to full duplex" );
@@ -6968,19 +6945,19 @@ 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 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_get_bit32 (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 , + }else if (rte_get_bit32 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && - !bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , + !rte_get_bit32 (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 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_get_bit32 (BNX2X_LINK_REPORT_TX_FC_ON , &cur_data.link_report_flags)) { flow ="ON - transmit" ; }else {
drivers/net/bnx2x/bnx2x.h +0 -4
@@ -1809,10 +1809,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 +5 -4
@@ -15,6 +15,7 @@#define ECORE_SP_H #include <rte_byteorder.h> +#include <rte_bitops.h> #if RTE_BYTE_ORDER ==RTE_LITTLE_ENDIAN #ifndef __LITTLE_ENDIAN
@@ -73,10 +74,10 @@ 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_get_bit32(bit, var) +#define ECORE_SET_BIT (bit, var) rte_set_bit32(bit, var) +#define ECORE_CLEAR_BIT (bit, var) rte_clear_bit32(bit, var) +#define ECORE_TEST_AND_CLEAR_BIT (bit, var) rte_test_and_clear_bit32(bit, var)#define atomic_load_acq_int (int)*#define atomic_store_rel_int (a, v) (*a = v)
Signature · 1 line
2.17.1
PATCH v3 5/6 net/qede: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/qede/base/bcm_osal.c | 20 -------------------- drivers/net/qede/base/bcm_osal.h | 10 ++++------ 2 files changed, 4 insertions(+), 26 deletions(-)
drivers/net/qede/base/bcm_osal.c +0 -20
@@ -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;
drivers/net/qede/base/bcm_osal.h +4 -6
@@ -8,6 +8,7 @@#define __BCM_OSAL_H#include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_spinlock.h> #include <rte_malloc.h> #include <rte_atomic.h>
@@ -311,17 +312,14 @@ 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(bit, bitmap) -void qede_clr_bit (u32 ,unsigned long *);#define OSAL_CLEAR_BIT (bit, bitmap) \ - qede_clr_bit(bit, bitmap) + rte_clear_bit32(bit, bitmap) -bool qede_test_bit (u32 ,unsigned long *);#define OSAL_TEST_BIT (bit, bitmap) \ - qede_test_bit(bit, bitmap) + rte_get_bit32(bit, bitmap)u32 qede_find_first_bit (unsigned long *,u32 );#define OSAL_FIND_FIRST_BIT (bitmap, length) \
Signature · 1 line
2.17.1
PATCH v3 6/6 net/hinic: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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 | 16 ++++++------- drivers/net/hinic/meson.build | 2 ++ 4 files changed, 12 insertions(+), 40 deletions(-)
drivers/net/hinic/Makefile +1 -0
@@ -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
@@ -11,6 +11,7 @@#include <pthread.h> #include <rte_common.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memzone.h> #include <rte_memcpy.h> #include <rte_malloc.h>
@@ -117,38 +118,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 +8 -8
@@ -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 (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 ;
@@ -1075,7 +1075,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 (HINIC_DEV_START , &nic_dev->dev_status);return 0 ;
@@ -1200,7 +1200,7 @@ 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 (HINIC_DEV_START , &nic_dev->dev_status)) {PMD_DRV_LOG (INFO ,"Device %s already stopped" , name);return ; }
@@ -1245,7 +1245,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 (HINIC_DEV_INTR_EN , &nic_dev->dev_status);/* disable msix interrupt in hardware */ hinic_set_msix_state (nic_dev->hwdev,0 ,HINIC_MSIX_DISABLE );
@@ -2844,7 +2844,7 @@ 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 (HINIC_DEV_CLOSE , &nic_dev->dev_status)) {PMD_DRV_LOG (WARNING ,"Device %s already closed" , dev->data->name);return ;
@@ -3045,7 +3045,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 (HINIC_DEV_INTR_EN , &nic_dev->dev_status);/* initialize filter info */ filter_info = &nic_dev->filter;
@@ -3057,7 +3057,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 (HINIC_DEV_INIT , &nic_dev->dev_status);PMD_DRV_LOG (INFO ,"Initialize %s in primary successfully" , eth_dev->data->name);
@@ -3113,7 +3113,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 (HINIC_DEV_INIT , &nic_dev->dev_status);if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ;
drivers/net/hinic/meson.build +2 -0
@@ -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
v4 cover implement common rte bit operation APIs in PMDs
In reply to Joyce KongThere are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
v4:
Introduce uint32_t/uint64_t *addr when definiting bit operation APIs(suggested by Morten Brørup).
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(suggested by Stephen Hemminger).
2. Add test cases for common rte bit operation API(suggested by Stephen Hemminger).
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 (suggested by Jerin Jacob).
4. Use an well defined uint_NN_t type(suggested by Morten Brørup).
Joyce Kong (6):
lib/eal: implement the family of rte 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 | 305 +++++++++++++++++++ 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_mdio.c | 14 +- drivers/net/bnx2x/bnx2x.c | 209 ++++++------- drivers/net/bnx2x/bnx2x.h | 4 - drivers/net/bnx2x/ecore_sp.h | 9 +- drivers/net/hinic/Makefile | 1 + drivers/net/hinic/base/hinic_compat.h | 33 +- drivers/net/hinic/hinic_pmd_ethdev.c | 16 +- drivers/net/hinic/meson.build | 2 + drivers/net/qede/base/bcm_osal.c | 20 -- drivers/net/qede/base/bcm_osal.h | 10 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 21 files changed, 928 insertions(+), 235 deletions(-) create mode 100644 app/test/test_bitops.c create mode 100644 lib/librte_eal/common/include/rte_bitops.h
Signature · 1 line
2.7.4
PATCH v4 1/6 lib/eal: implement the family of rte bit operation APIs
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, when the bit operation is applied to the IO devices, use __ATOMIC_ACQ_REL to ensure the ordering for io bit operation.
--- MAINTAINERS | 5 + doc/api/doxy-api-index.md | 5 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 5 files changed, 485 insertions(+), 3 deletions(-) create mode 100644 lib/librte_eal/common/include/rte_bitops.h
MAINTAINERS +5 -0
@@ -233,6 +233,11 @@ M: Cristian Dumitrescu <[email protected]> F: lib/librte_eal/common/include/rte_bitmap.h F: app/test/test_bitmap.c +Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_bitops.h +F: app/test/test_bitops.c + MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.h
doc/api/doxy-api-index.md +3 -2
@@ -133,12 +133,13 @@ The public API headers are grouped by topics: [BPF] (@ref rte_bpf.h) - **containers**: + [bitmap] (@ref rte_bitmap.h), + [bitops] (@ref rte_bitops.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/common/Makefile +1 -0
@@ -19,6 +19,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h +INC += rte_bitops.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.h
lib/librte_eal/common/include/rte_bitops.h new file +474 -0
474 lines not on this page · raw message
lib/librte_eal/common/meson.build +2 -1
@@ -50,9 +50,10 @@ common_objs += eal_common_arch_objs common_headers = files( 'include/rte_alarm.h', + 'include/rte_bitmap.h', + 'include/rte_bitops.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', - 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', 'include/rte_compat.h',
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v4 1/6] lib/eal: implement the family of rte bitoperation APIs
Quoted 594 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Joyce Kong
Sent: Wednesday, November 20, 2019 11:12 AMThere are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, when the bit operation is applied to the IO devices, use
__ATOMIC_ACQ_RELto ensure the ordering for io bit operation.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Gavin Hu <[email protected]>Reviewed-by Phil Yang <[email protected]>--- MAINTAINERS | 5 + doc/api/doxy-api-index.md | 5 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 5 files changed, 485 insertions(+), 3 deletions(-) create mode 100644 lib/librte_eal/common/include/rte_bitops.hMAINTAINERS +5
-0@@ -233,6 +233,11 @@ M: Cristian Dumitrescu <[email protected]> F: lib/librte_eal/common/include/rte_bitmap.h F: app/test/test_bitmap.c +Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_bitops.h +F: app/test/test_bitops.c + MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.hdoc/api/doxy-api-index.md +3
-2@@ -133,12 +133,13 @@ The public API headers are grouped by topics: [BPF] (@ref rte_bpf.h) - **containers**: + [bitmap] (@ref rte_bitmap.h), + [bitops] (@ref rte_bitops.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/common/Makefile +1
-0@@ -19,6 +19,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h +INC += rte_bitops.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.hlib/librte_eal/common/include/rte_bitops.h new file +12
-0@@ -0,0 +1,474 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a API for bit operations without/with memory ordering.
+ */lib/librte_eal/common/include/rte_bitops.h new file +10
-1+ +#include <stdint.h> +#include <rte_debug.h> +#include <rte_compat.h> + +/*---------------------------- 32 bit operations ------------------------- ---*/ + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the target bit from a 32-bit value without memory ordering.
+ *
+ * @param nr
+ * The target bit to get.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The target bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline uint32_t +rte_get_bit32_relaxed (unsigned int nr,uint32_t *addr) +{ +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +return __atomic_load_n (addr, __ATOMIC_RELAXED) & mask; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Set the target bit in a 32-bit value to 1 without memory ordering.
+ *
+ * @param nr
+ * The target bit to set.
+ * @param addr
+ * The address holding the bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline void +rte_set_bit32_relaxed (unsigned int nr,uint32_t *addr) +{ +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +__atomic_fetch_or (addr, mask, __ATOMIC_RELAXED); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Clear the target bit in a 32-bit value to 0 without memory ordering.
+ *
+ * @param nr
+ * The target bit to clear.
+ * @param addr
+ * The address holding the bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline void +rte_clear_bit32_relaxed (unsigned int nr,uint32_t *addr) +{ +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +__atomic_fetch_and (addr, ~mask, __ATOMIC_RELAXED); +} + +/** +* @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/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline uint32_t +rte_test_and_set_bit32_relaxed (unsigned int nr,uint32_t *addr) +{ +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +return __atomic_fetch_or (addr, mask, __ATOMIC_RELAXED) & 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/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline uint32_t +rte_test_and_clear_bit32_relaxed (unsigned int nr,uint32_t *addr) +{ +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +return __atomic_fetch_and (addr, ~mask, __ATOMIC_RELAXED) & mask; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the target bit from a 32-bit value with memory ordering.
+ *
+ * @param nr
+ * The target bit to get.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The target bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline uint32_t +rte_get_bit32 (unsigned int nr,uint32_t *addr) +{ +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +return __atomic_load_n (addr, __ATOMIC_ACQUIRE) & mask; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Set the target bit in a 32-bit value to 1 with memory ordering.
+ *
+ * @param nr
+ * The target bit to set.
+ * @param addr
+ * The address holding the bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline void +rte_set_bit32 (unsigned int nr,uint32_t *addr) +{ +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +__atomic_fetch_or (addr, mask, __ATOMIC_ACQ_REL); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Clear the target bit in a 32-bit value to 0 with memory ordering.
+ *
+ * @param nr
+ * The target bit to clear.
+ * @param addr
+ * The address holding the bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline void +rte_clear_bit32 (unsigned int nr,uint32_t *addr) +{ +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +__atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL); +} + +/** +* @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 with
+ * 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/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline uint32_t +rte_test_and_set_bit32 (unsigned int nr,uint32_t *addr) +{ +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +return __atomic_fetch_or (addr, mask, __ATOMIC_ACQ_REL) & 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 with
+ * 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/common/include/rte_bitops.h new file +15
-1+__rte_experimental +static inline uint32_t +rte_test_and_clear_bit32 (unsigned int nr,uint32_t *addr) +{ +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +return __atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL) & mask; +} + +/*---------------------------- 64 bit operations ------------------------- ---*/ + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the target bit from a 64-bit value without memory ordering.
+ *
+ * @param nr
+ * The target bit to get.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The target bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline uint64_t +rte_get_bit64_relaxed (unsigned int nr,uint64_t *addr) +{ +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +return __atomic_load_n (addr, __ATOMIC_RELAXED) & mask; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Set the target bit in a 64-bit value to 1 without memory ordering.
+ *
+ * @param nr
+ * The target bit to set.
+ * @param addr
+ * The address holding the bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline void +rte_set_bit64_relaxed (unsigned int nr,uint64_t *addr) +{ +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +__atomic_fetch_or (addr, mask, __ATOMIC_RELAXED); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Clear the target bit in a 64-bit value to 0 without memory ordering.
+ *
+ * @param nr
+ * The target bit to clear.
+ * @param addr
+ * The address holding the bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline void +rte_clear_bit64_relaxed (unsigned int nr,uint64_t *addr) +{ +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +__atomic_fetch_and (addr, ~mask, __ATOMIC_RELAXED); +} + +/** +* @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/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline uint64_t +rte_test_and_set_bit64_relaxed (unsigned int nr,uint64_t *addr) +{ +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +return __atomic_fetch_or (addr, mask, __ATOMIC_RELAXED) & mask; +} + +/** +* @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/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline uint64_t +rte_test_and_clear_bit64_relaxed (unsigned int nr,uint64_t *addr) +{ +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +return __atomic_fetch_and (addr, ~mask, __ATOMIC_RELAXED) & mask; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the target bit from a 64-bit value with memory ordering.
+ *
+ * @param nr
+ * The target bit to get.
+ * @param addr
+ * The address holding the bit.
+ * @return
+ * The target bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline uint64_t +rte_get_bit64 (unsigned int nr,uint64_t *addr) +{ +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +return __atomic_load_n (addr, __ATOMIC_ACQUIRE) & mask; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Set the target bit in a 64-bit value to 1 with memory ordering.
+ *
+ * @param nr
+ * The target bit to set.
+ * @param addr
+ * The address holding the bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline void +rte_set_bit64 (unsigned int nr,uint64_t *addr) +{ +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +__atomic_fetch_or (addr, mask, __ATOMIC_ACQ_REL); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Clear the target bit in a 64-bit value to 0 with memory ordering.
+ *
+ * @param nr
+ * The target bit to clear.
+ * @param addr
+ * The address holding the bit.
+ */lib/librte_eal/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline void +rte_clear_bit64 (unsigned int nr,uint64_t *addr) +{ +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +__atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL); +} + +/** +* @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 with
+ * 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/common/include/rte_bitops.h new file +13
-0+__rte_experimental +static inline uint64_t +rte_test_and_set_bit64 (unsigned int nr,uint64_t *addr) +{ +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +return __atomic_fetch_or (addr, mask, __ATOMIC_ACQ_REL) & mask; +} + +/** +* @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 with
+ * 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/common/include/rte_bitops.h new file +10
-0+__rte_experimental +static inline uint64_t +rte_test_and_clear_bit64 (unsigned int nr,uint64_t *addr) +{ +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +return __atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL) & mask; +} +#endif /* _RTE_BITOPS_H_ */ lib/librte_eal/common/meson.build +2
-2@@ -50,9 +50,10 @@ common_objs += eal_common_arch_objs common_headers = files( 'include/rte_alarm.h', + 'include/rte_bitmap.h', + 'include/rte_bitops.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', - 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', 'include/rte_compat.h', --
Quoted 2 lines
2.7.4
PATCH v4 2/6 test/bitops: add bit operation test case
In reply to Joyce KongAdd test cases for set bit, clear bit, test and set bit, test and clear bit operations.
--- app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/meson.build | 2 + app/test/test_bitops.c | 305 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100644 app/test/test_bitops.c
app/test/Makefile +1 -0
@@ -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
@@ -405,6 +405,12 @@ "Report": None, }, { + "Name": "Bitops test", + "Command": "bitops_autotest", + "Func": default_autotest, + "Report": None, + }, + { "Name": "Hash multiwriter autotest", "Command": "hash_multiwriter_autotest", "Func": default_autotest,
app/test/meson.build +2 -0
@@ -14,6 +14,7 @@ test_sources = files('commands.c', 'test_atomic.c', 'test_barrier.c', 'test_bitratestats.c', + 'test_bitops.c', 'test_bpf.c', 'test_byteorder.c', 'test_cmdline.c',
@@ -167,6 +168,7 @@ fast_test_names = [ 'alarm_autotest', 'atomic_autotest', 'byteorder_autotest', + 'bitops_autotest', 'cmdline_autotest', 'common_autotest', 'cpuflags_autotest',
app/test/test_bitops.c new file +305 -0
305 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 3/6 net/axgbe: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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_mdio.c | 14 +++++++------- 3 files changed, 15 insertions(+), 42 deletions(-)
drivers/net/axgbe/axgbe_common.h +1 -28
@@ -22,6 +22,7 @@#include <pthread.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memory.h> #include <rte_malloc.h> #include <rte_hexdump.h>
@@ -1674,34 +1675,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
@@ -201,8 +201,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_bit64 (AXGBE_STOPPED , &pdata->dev_state); +rte_clear_bit64 (AXGBE_DOWN , &pdata->dev_state);return 0 ; }
@@ -216,17 +216,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_bit64 (AXGBE_STOPPED , &pdata->dev_state))return ; -axgbe_set_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_set_bit64 (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_bit64 (AXGBE_DOWN , &pdata->dev_state); }/* Clear all resources like TX/RX queues. */
@@ -598,8 +598,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_bit64 (AXGBE_DOWN , &pdata->dev_state); +rte_set_bit64 (AXGBE_STOPPED , &pdata->dev_state); pdata->eth_dev = eth_dev; pci_dev =RTE_DEV_TO_PCI (eth_dev->device);
drivers/net/axgbe/axgbe_mdio.c +7 -7
@@ -743,7 +743,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) {int ret; -axgbe_set_bit (AXGBE_LINK_INIT , &pdata->dev_state); +rte_set_bit64 (AXGBE_LINK_INIT , &pdata->dev_state); pdata->link_check =rte_get_timer_cycles (); ret = pdata->phy_if.phy_impl.an_config (pdata);
@@ -807,9 +807,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_bit64 (AXGBE_LINK_ERR , &pdata->dev_state);else -axgbe_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state); +rte_clear_bit64 (AXGBE_LINK_ERR , &pdata->dev_state);pthread_mutex_unlock (&pdata->an_mutex);
@@ -880,7 +880,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)unsigned int link_aneg;int an_restart; -if (axgbe_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { +if (rte_get_bit64 (AXGBE_LINK_ERR , &pdata->dev_state)) { pdata->phy.link =0 ; goto adjust_link; }
@@ -900,10 +900,10 @@ static void axgbe_phy_status(struct axgbe_port *pdata)return ; }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_bit64 (AXGBE_LINK_INIT , &pdata->dev_state)) +rte_clear_bit64 (AXGBE_LINK_INIT , &pdata->dev_state); }else { -if (axgbe_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) { +if (rte_get_bit64 (AXGBE_LINK_INIT , &pdata->dev_state)) {axgbe_check_link_timeout (pdata);if (link_aneg)
Signature · 1 line
2.7.4
PATCH v4 4/6 net/bnx2x: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/bnx2x/bnx2x.c | 209 +++++++++++++++++++------------------------ drivers/net/bnx2x/bnx2x.h | 4 - drivers/net/bnx2x/ecore_sp.h | 9 +- 3 files changed, 98 insertions(+), 124 deletions(-)
drivers/net/bnx2x/bnx2x.c +93 -116
@@ -26,6 +26,7 @@#include <fcntl.h> #include <zlib.h> #include <rte_string_fns.h> +#include <rte_bitops.h> #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"#define BNX2X_PMD_VERSION_MAJOR 1
@@ -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);
@@ -1427,11 +1402,11 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,/* wait for completion of requested */ if (wait_for_comp) { -bnx2x_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); +rte_set_bit64 (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_bit64 (mac_type, &vlan_mac_flags); rc = mac_obj->delete_all (sc, mac_obj, &vlan_mac_flags, &ramrod_flags);if (rc <0 )
@@ -1458,26 +1433,26 @@ 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_bit64 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_MULTICAST , rx_accept_flags); +rte_set_bit64 (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_bit64 (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_MULTICAST , tx_accept_flags); +rte_set_bit64 (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_bit64 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_set_bit64 (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_bit64 (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_BROADCAST , tx_accept_flags);break ;
@@ -1488,19 +1463,20 @@ 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_bit64 (ECORE_ACCEPT_UNMATCHED , rx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_set_bit64 (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_bit64 (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_BROADCAST , tx_accept_flags);if (IS_MF_SI (sc)) { -bnx2x_set_bit (ECORE_ACCEPT_ALL_UNICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_ALL_UNICAST , + tx_accept_flags); }else { -bnx2x_set_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_UNICAST , tx_accept_flags); }break ;
@@ -1512,8 +1488,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_bit64 (ECORE_ACCEPT_ANY_VLAN , rx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_ANY_VLAN , tx_accept_flags); }return 0 ;
@@ -1542,7 +1518,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_bit64 (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); ramrod_param.ramrod_flags = ramrod_flags; ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1571,9 +1547,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_bit64 (RAMROD_RX , &ramrod_flags); +rte_set_bit64 (RAMROD_TX , &ramrod_flags); +rte_set_bit64 (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,
@@ -1698,7 +1674,7 @@ 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_bit64 (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);/* STARTED-->TX_STOPPED */ func_params.cmd =ECORE_F_CMD_TX_STOP ;
@@ -1722,7 +1698,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_bit64 (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* Stop the primary connection: */
@@ -1783,7 +1759,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_bit64 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_STOP ;
@@ -1797,7 +1773,7 @@ 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_bit64 (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);return ecore_func_state_change (sc, &func_params); }
@@ -1809,7 +1785,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_bit64 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_RESET ;
@@ -1866,11 +1842,10 @@ 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_bit64 (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state)) +rte_set_bit64 (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;
@@ -1960,12 +1935,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_bit64 (RAMROD_COMP_WAIT , &ramrod_flags);/* Perform a dry cleanup */ -bnx2x_set_bit (RAMROD_DRV_CLR_ONLY , &ramrod_flags); +rte_set_bit64 (RAMROD_DRV_CLR_ONLY , &ramrod_flags);/* Clean ETH primary MAC */ -bnx2x_set_bit (ECORE_ETH_MAC , &vlan_mac_flags); +rte_set_bit64 (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 ) {
@@ -1974,7 +1949,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_bit64 (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,
@@ -1984,7 +1959,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_bit64 (RAMROD_DRV_CLR_ONLY , &rparam.ramrod_flags);/* Add a DEL command... */ rc =ecore_config_mcast (sc, &rparam,ECORE_MCAST_CMD_DEL );
@@ -4288,7 +4263,7 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estruct 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_bit64 (RAMROD_CONT , &ramrod_flags);switch (le32toh (elem->message.data.eth_event.echo) >>BNX2X_SWCID_SHIFT ) {case ECORE_FILTER_MAC_PENDING :
@@ -4319,12 +4294,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estatic void bnx2x_handle_rx_mode_eqe (struct bnx2x_softc *sc) { -bnx2x_clear_bit (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); +rte_clear_bit64 (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_bit64 (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)
@@ -4693,7 +4668,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_bit64 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_INIT ;
@@ -4988,8 +4963,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_bit64 (ECORE_Q_TYPE_HAS_RX , &q_type); +rte_set_bit64 (ECORE_Q_TYPE_HAS_TX , &q_type); ecore_init_queue_obj(sc, &sc->sp_objs[idx].q_obj,
@@ -5803,7 +5778,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_bit64 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_START ;
@@ -6379,11 +6354,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_bit64 (ECORE_Q_FLG_HC , &init_params->rx.flags); +rte_set_bit64 (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_bit64 (ECORE_Q_FLG_HC_EN , &init_params->rx.flags); +rte_set_bit64 (ECORE_Q_FLG_HC_EN , &init_params->tx.flags);/* HC rate */ init_params->rx.hc_rate =
@@ -6417,7 +6392,7 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)unsigned long flags =0 ;/* PF driver will always initialize the Queue to an ACTIVE state */ -bnx2x_set_bit (ECORE_Q_FLG_ACTIVE , &flags); +rte_set_bit64 (ECORE_Q_FLG_ACTIVE , &flags);/* * tx only connections collect statistics (on the same index as the
@@ -6425,9 +6400,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_bit64 (ECORE_Q_FLG_STATS , &flags);if (zero_stats) { -bnx2x_set_bit (ECORE_Q_FLG_ZERO_STATS , &flags); +rte_set_bit64 (ECORE_Q_FLG_ZERO_STATS , &flags); }/*
@@ -6435,10 +6410,10 @@ 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_bit64 (ECORE_Q_FLG_TX_SWITCH , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_PCSUM_ON_PKT , &flags); +rte_set_bit64 (ECORE_Q_FLG_PCSUM_ON_PKT , &flags);return flags; }
@@ -6448,15 +6423,15 @@ static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)unsigned long flags =0 ;if (IS_MF_SD (sc)) { -bnx2x_set_bit (ECORE_Q_FLG_OV , &flags); +rte_set_bit64 (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_bit64 (ECORE_Q_FLG_LEADING_RSS , &flags); +rte_set_bit64 (ECORE_Q_FLG_MCAST , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_VLAN , &flags); +rte_set_bit64 (ECORE_Q_FLG_VLAN , &flags);/* merge with common flags */ return flags |bnx2x_get_common_flags (sc, TRUE);
@@ -6577,7 +6552,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_bit64 (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* prepare the INIT parameters */ bnx2x_pf_q_prep_init (sc, fp, &q_params.params.init);
@@ -6645,20 +6620,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 , ¶ms.ramrod_flags); +rte_set_bit64 (RAMROD_COMP_WAIT , ¶ms.ramrod_flags); -bnx2x_set_bit (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags);/* RSS configuration */ -bnx2x_set_bit (ECORE_RSS_IPV4 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV4 , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV6 , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags);if (rss_obj->udp_rss_v4) { -bnx2x_set_bit (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); }if (rss_obj->udp_rss_v6) { -bnx2x_set_bit (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); }/* Hash bits */
@@ -6673,7 +6648,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 , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_SET_SRCH , ¶ms.rss_flags); }if (IS_PF (sc))
@@ -6730,11 +6705,11 @@ 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_bit64 (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_bit64 (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 :
@@ -6761,7 +6736,7 @@ static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)PMD_DRV_LOG (DEBUG , sc,"Adding Ethernet MAC" ); -bnx2x_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); +rte_set_bit64 (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,
@@ -6893,24 +6868,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_bit64 (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_bit64 (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_bit64 (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_bit64 (BNX2X_LINK_REPORT_TX_FC_ON , + &data->link_report_flags); } }
@@ -6929,9 +6906,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_bit64 (BNX2X_LINK_REPORT_LINK_DOWN , &sc->last_reported_link.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_LINK_DOWN , +rte_get_bit64 (BNX2X_LINK_REPORT_LINK_DOWN , &cur_data.link_report_flags))) {return ; }
@@ -6946,14 +6923,14 @@ 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_bit64 (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 , +if (rte_test_and_clear_bit64 (BNX2X_LINK_REPORT_FULL_DUPLEX , &cur_data.link_report_flags)) { duplex ="full" ;ELINK_DEBUG_P0 (sc,"link set to full duplex" );
@@ -6968,19 +6945,19 @@ 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_bit64 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_get_bit64 (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 , + }else if (rte_get_bit64 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && - !bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , + !rte_get_bit64 (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_bit64 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_get_bit64 (BNX2X_LINK_REPORT_TX_FC_ON , &cur_data.link_report_flags)) { flow ="ON - transmit" ; }else {
drivers/net/bnx2x/bnx2x.h +0 -4
@@ -1809,10 +1809,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 +5 -4
@@ -15,6 +15,7 @@#define ECORE_SP_H #include <rte_byteorder.h> +#include <rte_bitops.h> #if RTE_BYTE_ORDER ==RTE_LITTLE_ENDIAN #ifndef __LITTLE_ENDIAN
@@ -73,10 +74,10 @@ 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_get_bit64(bit, var) +#define ECORE_SET_BIT (bit, var) rte_set_bit64(bit, var) +#define ECORE_CLEAR_BIT (bit, var) rte_clear_bit64(bit, var) +#define ECORE_TEST_AND_CLEAR_BIT (bit, var) rte_test_and_clear_bit64(bit, var)#define atomic_load_acq_int (int)*#define atomic_store_rel_int (a, v) (*a = v)
Signature · 1 line
2.7.4
PATCH v4 5/6 net/qede: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/qede/base/bcm_osal.c | 20 -------------------- drivers/net/qede/base/bcm_osal.h | 10 ++++------ 2 files changed, 4 insertions(+), 26 deletions(-)
drivers/net/qede/base/bcm_osal.c +0 -20
@@ -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;
drivers/net/qede/base/bcm_osal.h +4 -6
@@ -8,6 +8,7 @@#define __BCM_OSAL_H#include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_spinlock.h> #include <rte_malloc.h> #include <rte_atomic.h>
@@ -311,17 +312,14 @@ 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_bit64(bit, bitmap) -void qede_clr_bit (u32 ,unsigned long *);#define OSAL_CLEAR_BIT (bit, bitmap) \ - qede_clr_bit(bit, bitmap) + rte_clear_bit64(bit, bitmap) -bool qede_test_bit (u32 ,unsigned long *);#define OSAL_TEST_BIT (bit, bitmap) \ - qede_test_bit(bit, bitmap) + rte_get_bit64(bit, bitmap)u32 qede_find_first_bit (unsigned long *,u32 );#define OSAL_FIND_FIRST_BIT (bitmap, length) \
Signature · 1 line
2.7.4
PATCH v4 6/6 net/hinic: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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 | 16 ++++++++-------- drivers/net/hinic/meson.build | 2 ++ 4 files changed, 12 insertions(+), 40 deletions(-)
drivers/net/hinic/Makefile +1 -0
@@ -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
@@ -11,6 +11,7 @@#include <pthread.h> #include <rte_common.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memzone.h> #include <rte_memcpy.h> #include <rte_malloc.h>
@@ -117,38 +118,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 +8 -8
@@ -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_bit64 (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 ;
@@ -1075,7 +1075,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_bit64 (HINIC_DEV_START , &nic_dev->dev_status);return 0 ;
@@ -1200,7 +1200,7 @@ 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_bit64 (HINIC_DEV_START , &nic_dev->dev_status)) {PMD_DRV_LOG (INFO ,"Device %s already stopped" , name);return ; }
@@ -1245,7 +1245,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_bit64 (HINIC_DEV_INTR_EN , &nic_dev->dev_status);/* disable msix interrupt in hardware */ hinic_set_msix_state (nic_dev->hwdev,0 ,HINIC_MSIX_DISABLE );
@@ -2844,7 +2844,7 @@ 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_bit64 (HINIC_DEV_CLOSE , &nic_dev->dev_status)) {PMD_DRV_LOG (WARNING ,"Device %s already closed" , dev->data->name);return ;
@@ -3045,7 +3045,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_bit64 (HINIC_DEV_INTR_EN , &nic_dev->dev_status);/* initialize filter info */ filter_info = &nic_dev->filter;
@@ -3057,7 +3057,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_bit64 (HINIC_DEV_INIT , &nic_dev->dev_status);PMD_DRV_LOG (INFO ,"Initialize %s in primary successfully" , eth_dev->data->name);
@@ -3113,7 +3113,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_bit64 (HINIC_DEV_INIT , &nic_dev->dev_status);if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ;
drivers/net/hinic/meson.build +2 -0
@@ -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.7.4
v5 cover implement common rte bit operation APIs in PMDs
In reply to Joyce KongThere are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
v5:
Correct the spelling mistake in test_bitops.c
v4:
Introduce uint32_t/uint64_t *addr when definiting bit operation APIs(suggested by Morten Brørup).
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(suggested by Stephen Hemminger).
2. Add test cases for common rte bit operation API(suggested by Stephen Hemminger).
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 (suggested by Jerin Jacob).
4. Use an well defined uint_NN_t type(suggested by Morten Brørup).
Joyce Kong (6):
lib/eal: implement the family of rte 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 | 305 +++++++++++++++++++ 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_mdio.c | 14 +- drivers/net/bnx2x/bnx2x.c | 209 ++++++------- drivers/net/bnx2x/bnx2x.h | 4 - drivers/net/bnx2x/ecore_sp.h | 9 +- drivers/net/hinic/Makefile | 1 + drivers/net/hinic/base/hinic_compat.h | 33 +- drivers/net/hinic/hinic_pmd_ethdev.c | 16 +- drivers/net/hinic/meson.build | 2 + drivers/net/qede/base/bcm_osal.c | 20 -- drivers/net/qede/base/bcm_osal.h | 10 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 21 files changed, 928 insertions(+), 235 deletions(-) create mode 100644 app/test/test_bitops.c create mode 100644 lib/librte_eal/common/include/rte_bitops.h
Signature · 1 line
2.7.4
PATCH v5 1/6 lib/eal: implement the family of rte bit operation APIs
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, when the bit operation is applied to the IO devices, use __ATOMIC_ACQ_REL to ensure the ordering for io bit operation.
--- MAINTAINERS | 5 + doc/api/doxy-api-index.md | 5 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 5 files changed, 485 insertions(+), 3 deletions(-) create mode 100644 lib/librte_eal/common/include/rte_bitops.h
MAINTAINERS +5 -0
@@ -236,6 +236,11 @@ M: Cristian Dumitrescu <[email protected]> F: lib/librte_eal/common/include/rte_bitmap.h F: app/test/test_bitmap.c +Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_bitops.h +F: app/test/test_bitops.c + MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.h
doc/api/doxy-api-index.md +3 -2
@@ -133,12 +133,13 @@ The public API headers are grouped by topics: [BPF] (@ref rte_bpf.h) - **containers**: + [bitmap] (@ref rte_bitmap.h), + [bitops] (@ref rte_bitops.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/common/Makefile +1 -0
@@ -19,6 +19,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h +INC += rte_bitops.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.h
lib/librte_eal/common/include/rte_bitops.h new file +474 -0
474 lines not on this page · raw message
lib/librte_eal/common/meson.build +2 -1
@@ -50,9 +50,10 @@ common_objs += eal_common_arch_objs common_headers = files( 'include/rte_alarm.h', + 'include/rte_bitmap.h', + 'include/rte_bitops.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', - 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', 'include/rte_compat.h',
Signature · 1 line
2.7.4
PATCH v5 2/6 test/bitops: add bit operation test case
In reply to Joyce KongAdd test cases for set bit, clear bit, test and set bit, test and clear bit operations.
--- app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/meson.build | 2 + app/test/test_bitops.c | 305 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100644 app/test/test_bitops.c
app/test/Makefile +1 -0
@@ -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
@@ -405,6 +405,12 @@ "Report": None, }, { + "Name": "Bitops test", + "Command": "bitops_autotest", + "Func": default_autotest, + "Report": None, + }, + { "Name": "Hash multiwriter autotest", "Command": "hash_multiwriter_autotest", "Func": default_autotest,
app/test/meson.build +2 -0
@@ -14,6 +14,7 @@ test_sources = files('commands.c', 'test_atomic.c', 'test_barrier.c', 'test_bitratestats.c', + 'test_bitops.c', 'test_bpf.c', 'test_byteorder.c', 'test_cmdline.c',
@@ -167,6 +168,7 @@ fast_test_names = [ 'alarm_autotest', 'atomic_autotest', 'byteorder_autotest', + 'bitops_autotest', 'cmdline_autotest', 'common_autotest', 'cpuflags_autotest',
app/test/test_bitops.c new file +305 -0
305 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v5 3/6 net/axgbe: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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_mdio.c | 14 +++++++------- 3 files changed, 15 insertions(+), 42 deletions(-)
drivers/net/axgbe/axgbe_common.h +1 -28
@@ -22,6 +22,7 @@#include <pthread.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memory.h> #include <rte_malloc.h> #include <rte_hexdump.h>
@@ -1674,34 +1675,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
@@ -201,8 +201,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_bit64 (AXGBE_STOPPED , &pdata->dev_state); +rte_clear_bit64 (AXGBE_DOWN , &pdata->dev_state);return 0 ; }
@@ -216,17 +216,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_bit64 (AXGBE_STOPPED , &pdata->dev_state))return ; -axgbe_set_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_set_bit64 (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_bit64 (AXGBE_DOWN , &pdata->dev_state); }/* Clear all resources like TX/RX queues. */
@@ -598,8 +598,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_bit64 (AXGBE_DOWN , &pdata->dev_state); +rte_set_bit64 (AXGBE_STOPPED , &pdata->dev_state); pdata->eth_dev = eth_dev; pci_dev =RTE_DEV_TO_PCI (eth_dev->device);
drivers/net/axgbe/axgbe_mdio.c +7 -7
@@ -743,7 +743,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) {int ret; -axgbe_set_bit (AXGBE_LINK_INIT , &pdata->dev_state); +rte_set_bit64 (AXGBE_LINK_INIT , &pdata->dev_state); pdata->link_check =rte_get_timer_cycles (); ret = pdata->phy_if.phy_impl.an_config (pdata);
@@ -807,9 +807,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_bit64 (AXGBE_LINK_ERR , &pdata->dev_state);else -axgbe_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state); +rte_clear_bit64 (AXGBE_LINK_ERR , &pdata->dev_state);pthread_mutex_unlock (&pdata->an_mutex);
@@ -880,7 +880,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)unsigned int link_aneg;int an_restart; -if (axgbe_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { +if (rte_get_bit64 (AXGBE_LINK_ERR , &pdata->dev_state)) { pdata->phy.link =0 ; goto adjust_link; }
@@ -900,10 +900,10 @@ static void axgbe_phy_status(struct axgbe_port *pdata)return ; }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_bit64 (AXGBE_LINK_INIT , &pdata->dev_state)) +rte_clear_bit64 (AXGBE_LINK_INIT , &pdata->dev_state); }else { -if (axgbe_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) { +if (rte_get_bit64 (AXGBE_LINK_INIT , &pdata->dev_state)) {axgbe_check_link_timeout (pdata);if (link_aneg)
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v5 3/6] net/axgbe: use common rte bit operation APIs instead
Hi Bruce, Thomas,
This series of patches was reported a compilation issue[1] on 32bit Ubuntu.
On mainstream 64-bit OS, "unsigned long" is 64-bit in size and we uses the 64-bit variant of APIs. But the 32-bit OS expect 32-bit 'unsigned long' arguments. This is where the error happens.
My question is how 32-bit OSes shall we support, put another way, can we ignore this compilation issue? If we still need to care, how about making 'obsolete' of 'unsigned long' and use 'uint32' instead to be multi-OS friendly?
*Meson Build Failed #1:
OS: UB1604-32
Target:build-gcc-static
[1] http://mails.dpdk.org/archives/test-report/2019-November/109515.html
Quoted 180 lines
-----Original Message-----
From: Joyce Kong <[email protected]>
Sent: Thursday, November 28, 2019 2:44 PM
To: [email protected]
Cc: nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v5 3/6] net/axgbe: use common rte bit operation APIs insteadRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
Signed-off-by Joyce Kong <[email protected]>Reviewed-by Gavin Hu <[email protected]>--- drivers/net/axgbe/axgbe_common.h | 29 +---------------------------- drivers/net/axgbe/axgbe_ethdev.c | 14 +++++++------- drivers/net/axgbe/axgbe_mdio.c | 14 +++++++------- 3 files changed, 15 insertions(+), 42 deletions(-)drivers/net/axgbe/axgbe_common.h +1
-28@@ -22,6 +22,7 @@#include <pthread.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memory.h> #include <rte_malloc.h> #include <rte_hexdump.h> @@ -1674,34 +1675,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){
drivers/net/axgbe/axgbe_common.h +0
-0return rte_get_timer_hz () * (m /1000 );drivers/net/axgbe/axgbe_ethdev.c +7
-7@@ -201,8 +201,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_bit64 (AXGBE_STOPPED , &pdata->dev_state); +rte_clear_bit64 (AXGBE_DOWN , &pdata->dev_state);return 0 ; }@@ -216,17 +216,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_bit64 (AXGBE_STOPPED , &pdata->dev_state))return ; -axgbe_set_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_set_bit64 (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_bit64 (AXGBE_DOWN , &pdata->dev_state); }/* Clear all resources like TX/RX queues. */ @@ -598,8 +598,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_bit64 (AXGBE_DOWN , &pdata->dev_state); +rte_set_bit64 (AXGBE_STOPPED , &pdata->dev_state); pdata->eth_dev = eth_dev; pci_dev =RTE_DEV_TO_PCI (eth_dev->device);drivers/net/axgbe/axgbe_mdio.c +1
-1@@ -743,7 +743,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) {int ret; -axgbe_set_bit (AXGBE_LINK_INIT , &pdata->dev_state); +rte_set_bit64 (AXGBE_LINK_INIT , &pdata->dev_state); pdata->link_check =rte_get_timer_cycles ();drivers/net/axgbe/axgbe_mdio.c +3
-3ret = pdata->phy_if.phy_impl.an_config (pdata);@@ -807,9 +807,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_bit64 (AXGBE_LINK_ERR , &pdata->dev_state);else -axgbe_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state); +rte_clear_bit64 (AXGBE_LINK_ERR , &pdata->dev_state);pthread_mutex_unlock (&pdata->an_mutex);@@ -880,7 +880,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)unsigned int link_aneg;int an_restart; -if (axgbe_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { +if (rte_get_bit64 (AXGBE_LINK_ERR , &pdata->dev_state)) { pdata->phy.link =0 ; goto adjust_link;drivers/net/axgbe/axgbe_mdio.c +3
-3}@@ -900,10 +900,10 @@ static void axgbe_phy_status(struct axgbe_port *pdata)return ; }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_bit64 (AXGBE_LINK_INIT , &pdata->dev_state)) +rte_clear_bit64 (AXGBE_LINK_INIT , &pdata- >dev_state); }else { -if (axgbe_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) { +if (rte_get_bit64 (AXGBE_LINK_INIT , &pdata->dev_state)) {drivers/net/axgbe/axgbe_mdio.c +0
-1axgbe_check_link_timeout (pdata);if (link_aneg) --2.7.4
Re: [dpdk-dev] [PATCH v5 3/6] net/axgbe: use common rte bit operation APIs instead
02/12/2019 07:09, Gavin Hu (Arm Technology China):
Quoted 5 lines
Hi Bruce, Thomas,
This series of patches was reported a compilation issue[1] on 32bit Ubuntu.
On mainstream 64-bit OS, "unsigned long" is 64-bit in size and we uses the 64-bit variant of APIs. But the 32-bit OS expect 32-bit 'unsigned long' arguments. This is where the error happens.
Please could you be more specific? What is the exact error?
Quoted 2 lines
My question is how 32-bit OSes shall we support, put another way, can we ignore this compilation issue? If we still need to care, how about making 'obsolete' of 'unsigned long' and use 'uint32' instead to be multi-OS friendly?
Which unsigned long?
If it is in the (not merged) bit API, it can still be changed no?
Re: [dpdk-dev] [PATCH v5 3/6] net/axgbe: use common rte bitoperation APIs instead
Thomas,
Quoted 7 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, December 2, 2019 10:12 AM02/12/2019 07:09, Gavin Hu (Arm Technology China):
Quoted 2 lines
Hi Bruce, Thomas,
Quoted 8 lines
Quoted 1 line
This series of patches was reported a compilation issue[1] on 32bit
Ubuntu.
Quoted 1 line
On mainstream 64-bit OS, "unsigned long" is 64-bit in size and we
uses the 64-bit variant of APIs. But the 32-bit OS expect 32-bit 'unsigned long' arguments.
Quoted 1 line
This is where the error happens.
Please could you be more specific? What is the exact error?
The PMD has a private structure with an unsigned long field.
The patch for the PMD uses the 64 bit operations on this field. The patch fails to compile for a 32 bit target, because the struct field is only 32 bit there.
Quoted 9 lines
Quoted 2 lines
My question is how 32-bit OSes shall we support, put another way, can
we ignore this compilation issue?
Quoted 1 line
If we still need to care, how about making 'obsolete' of 'unsigned
long' and use 'uint32' instead to be multi-OS friendly?
Which unsigned long?
If it is in the (not merged) bit API, it can still be changed no?
The patch for the PMD can be changed to use the 64 or 32 bit operations depending on whether it is being compiled for a 64 or 32 bit target.
However, the question seems to be if we want to either 1) do something like that, or 2) drop support for 32 bit targets, or 3) make these target dependent fields obsolete (i.e. ban the use of unsigned long) and require explicit sizes, e.g. uint32_t.
Re: [dpdk-dev] [PATCH v5 3/6] net/axgbe: use common rte bitoperation APIs instead
02/12/2019 10:24, Morten Brørup:
Quoted 28 lines
Thomas,
Quoted 7 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, December 2, 2019 10:12 AM02/12/2019 07:09, Gavin Hu (Arm Technology China):
Quoted 2 lines
Hi Bruce, Thomas,
Quoted 8 lines
Quoted 1 line
This series of patches was reported a compilation issue[1] on 32bit
Ubuntu.
Quoted 1 line
On mainstream 64-bit OS, "unsigned long" is 64-bit in size and we
uses the 64-bit variant of APIs. But the 32-bit OS expect 32-bit 'unsigned long' arguments.
Quoted 1 line
This is where the error happens.
Please could you be more specific? What is the exact error?
The PMD has a private structure with an unsigned long field.
The patch for the PMD uses the 64 bit operations on this field. The patch fails to compile for a 32 bit target, because the struct field is only 32 bit there.
Quoted 6 lines
Quoted 2 lines
My question is how 32-bit OSes shall we support, put another way, can
we ignore this compilation issue?
Quoted 1 line
If we still need to care, how about making 'obsolete' of 'unsigned
long' and use 'uint32' instead to be multi-OS friendly?
Quoted 7 lines
Quoted 3 lines
Which unsigned long?
If it is in the (not merged) bit API, it can still be changed no?The patch for the PMD can be changed to use the 64 or 32 bit operations depending on whether it is being compiled for a 64 or 32 bit target.
However, the question seems to be if we want to either 1) do something like that, or 2) drop support for 32 bit targets, or 3) make these target dependent fields obsolete (i.e. ban the use of unsigned long) and require explicit sizes, e.g.
uint32_t.
We should support both,
and use the appropriate instruction.
But I wonder why this field has not a fixed size.
It would be probably better to change the field to uint32_t or uint64_t.
Re: [dpdk-dev] [PATCH v5 3/6] net/axgbe: use common rte bitoperation APIs instead
In reply to Morten BrørupQuoted 28 lines · On Mon, 2 Dec 2019 10:24:32 +0100 Morten Brørup <[email protected]>…
Thomas,
Quoted 7 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, December 2, 2019 10:12 AM02/12/2019 07:09, Gavin Hu (Arm Technology China):
Quoted 2 lines
Hi Bruce, Thomas,
Quoted 8 lines
Quoted 1 line
This series of patches was reported a compilation issue[1] on 32bit
Ubuntu.
Quoted 1 line
On mainstream 64-bit OS, "unsigned long" is 64-bit in size and we
uses the 64-bit variant of APIs. But the 32-bit OS expect 32-bit 'unsigned long' arguments.
Quoted 1 line
This is where the error happens.
Please could you be more specific? What is the exact error?
The PMD has a private structure with an unsigned long field.
The patch for the PMD uses the 64 bit operations on this field. The patch fails to compile for a 32 bit target, because the struct field is only 32 bit there.
Quoted 6 lines
Quoted 2 lines
My question is how 32-bit OSes shall we support, put another way, can
we ignore this compilation issue?
Quoted 1 line
If we still need to care, how about making 'obsolete' of 'unsigned
long' and use 'uint32' instead to be multi-OS friendly?
Quoted 7 lines
Quoted 3 lines
Which unsigned long?
If it is in the (not merged) bit API, it can still be changed no?The patch for the PMD can be changed to use the 64 or 32 bit operations depending on whether it is being compiled for a 64 or 32 bit target.
However, the question seems to be if we want to either 1) do something like that, or 2) drop support for 32 bit targets, or 3) make these target dependent fields obsolete (i.e. ban the use of unsigned long) and require explicit sizes, e.g.
uint32_t.
The bitop library should not assume sizeof(unsigned long) == 32 bit.
Re: [dpdk-dev] [PATCH v5 3/6] net/axgbe: use common rte bitoperation APIs instead
Quoted 55 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, December 3, 2019 12:53 AM
To: Morten Brørup <[email protected]>
Cc: [email protected]; Gavin Hu (Arm Technology China) <[email protected]>; Joyce Kong (Arm Technology China) <[email protected]>; [email protected]; [email protected]; Bruce Richardson <[email protected]>; nd <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v5 3/6] net/axgbe: use common rte bitoperation APIs insteadQuoted 4 lines · On Mon, 2 Dec 2019 10:24:32 +0100 Morten Brørup <[email protected]>…
Thomas,
Quoted 2 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of ThomasMonjalon
Quoted 10 lines
Quoted 10 lines
Sent: Monday, December 2, 2019 10:12 AM
02/12/2019 07:09, Gavin Hu (Arm Technology China):
Quoted 3 lines
Hi Bruce, Thomas,
This series of patches was reported a compilation issue[1] on 32bit
Ubuntu.
Quoted 1 line
On mainstream 64-bit OS, "unsigned long" is 64-bit in size and we
uses the 64-bit variant of APIs. But the 32-bit OS expect 32-bit 'unsigned long' arguments.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
This is where the error happens.
Please could you be more specific? What is the exact error?
The PMD has a private structure with an unsigned long field.
The patch for the PMD uses the 64 bit operations on this field. The patch
fails to compile for a 32 bit target, because the struct field is only 32 bit there.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
My question is how 32-bit OSes shall we support, put another way, can
we ignore this compilation issue?
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
If we still need to care, how about making 'obsolete' of 'unsigned
long' and use 'uint32' instead to be multi-OS friendly?
Which unsigned long?
If it is in the (not merged) bit API, it can still be changed no?The patch for the PMD can be changed to use the 64 or 32 bit operations
Quoted 8 lines
depending on whether it is being compiled for a 64 or 32 bit target.
Quoted 2 lines
However, the question seems to be if we want to either 1) do something like
that, or 2) drop support for 32 bit targets, or 3) make these target dependent fields obsolete (i.e. ban the use of unsigned long) and require explicit sizes, e.g.
uint32_t.The bitop library should not assume sizeof(unsigned long) == 32 bit.
As discussed, both 32-bit and 64-bit OSes should be supported, and their sizes of "unsigned long" are not fixed.
Taking all these into considerations, we will use "unsigned int" or uint32_t instead of "unsigned long" in the PMDs to be compatible across 32- or 64-bit OSes. /Gavin
PATCH v5 4/6 net/bnx2x: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/bnx2x/bnx2x.c | 209 +++++++++++++++++++------------------------ drivers/net/bnx2x/bnx2x.h | 4 - drivers/net/bnx2x/ecore_sp.h | 9 +- 3 files changed, 98 insertions(+), 124 deletions(-)
drivers/net/bnx2x/bnx2x.c +93 -116
@@ -26,6 +26,7 @@#include <fcntl.h> #include <zlib.h> #include <rte_string_fns.h> +#include <rte_bitops.h> #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"#define BNX2X_PMD_VERSION_MAJOR 1
@@ -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);
@@ -1427,11 +1402,11 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,/* wait for completion of requested */ if (wait_for_comp) { -bnx2x_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); +rte_set_bit64 (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_bit64 (mac_type, &vlan_mac_flags); rc = mac_obj->delete_all (sc, mac_obj, &vlan_mac_flags, &ramrod_flags);if (rc <0 )
@@ -1458,26 +1433,26 @@ 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_bit64 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_MULTICAST , rx_accept_flags); +rte_set_bit64 (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_bit64 (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_MULTICAST , tx_accept_flags); +rte_set_bit64 (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_bit64 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_set_bit64 (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_bit64 (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_BROADCAST , tx_accept_flags);break ;
@@ -1488,19 +1463,20 @@ 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_bit64 (ECORE_ACCEPT_UNMATCHED , rx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_set_bit64 (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_bit64 (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_BROADCAST , tx_accept_flags);if (IS_MF_SI (sc)) { -bnx2x_set_bit (ECORE_ACCEPT_ALL_UNICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_ALL_UNICAST , + tx_accept_flags); }else { -bnx2x_set_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_UNICAST , tx_accept_flags); }break ;
@@ -1512,8 +1488,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_bit64 (ECORE_ACCEPT_ANY_VLAN , rx_accept_flags); +rte_set_bit64 (ECORE_ACCEPT_ANY_VLAN , tx_accept_flags); }return 0 ;
@@ -1542,7 +1518,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_bit64 (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); ramrod_param.ramrod_flags = ramrod_flags; ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1571,9 +1547,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_bit64 (RAMROD_RX , &ramrod_flags); +rte_set_bit64 (RAMROD_TX , &ramrod_flags); +rte_set_bit64 (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,
@@ -1698,7 +1674,7 @@ 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_bit64 (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);/* STARTED-->TX_STOPPED */ func_params.cmd =ECORE_F_CMD_TX_STOP ;
@@ -1722,7 +1698,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_bit64 (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* Stop the primary connection: */
@@ -1783,7 +1759,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_bit64 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_STOP ;
@@ -1797,7 +1773,7 @@ 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_bit64 (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);return ecore_func_state_change (sc, &func_params); }
@@ -1809,7 +1785,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_bit64 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_RESET ;
@@ -1866,11 +1842,10 @@ 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_bit64 (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state)) +rte_set_bit64 (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;
@@ -1960,12 +1935,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_bit64 (RAMROD_COMP_WAIT , &ramrod_flags);/* Perform a dry cleanup */ -bnx2x_set_bit (RAMROD_DRV_CLR_ONLY , &ramrod_flags); +rte_set_bit64 (RAMROD_DRV_CLR_ONLY , &ramrod_flags);/* Clean ETH primary MAC */ -bnx2x_set_bit (ECORE_ETH_MAC , &vlan_mac_flags); +rte_set_bit64 (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 ) {
@@ -1974,7 +1949,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_bit64 (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,
@@ -1984,7 +1959,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_bit64 (RAMROD_DRV_CLR_ONLY , &rparam.ramrod_flags);/* Add a DEL command... */ rc =ecore_config_mcast (sc, &rparam,ECORE_MCAST_CMD_DEL );
@@ -4288,7 +4263,7 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estruct 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_bit64 (RAMROD_CONT , &ramrod_flags);switch (le32toh (elem->message.data.eth_event.echo) >>BNX2X_SWCID_SHIFT ) {case ECORE_FILTER_MAC_PENDING :
@@ -4319,12 +4294,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estatic void bnx2x_handle_rx_mode_eqe (struct bnx2x_softc *sc) { -bnx2x_clear_bit (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); +rte_clear_bit64 (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_bit64 (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)
@@ -4693,7 +4668,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_bit64 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_INIT ;
@@ -4988,8 +4963,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_bit64 (ECORE_Q_TYPE_HAS_RX , &q_type); +rte_set_bit64 (ECORE_Q_TYPE_HAS_TX , &q_type); ecore_init_queue_obj(sc, &sc->sp_objs[idx].q_obj,
@@ -5803,7 +5778,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_bit64 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_START ;
@@ -6379,11 +6354,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_bit64 (ECORE_Q_FLG_HC , &init_params->rx.flags); +rte_set_bit64 (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_bit64 (ECORE_Q_FLG_HC_EN , &init_params->rx.flags); +rte_set_bit64 (ECORE_Q_FLG_HC_EN , &init_params->tx.flags);/* HC rate */ init_params->rx.hc_rate =
@@ -6417,7 +6392,7 @@ bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)unsigned long flags =0 ;/* PF driver will always initialize the Queue to an ACTIVE state */ -bnx2x_set_bit (ECORE_Q_FLG_ACTIVE , &flags); +rte_set_bit64 (ECORE_Q_FLG_ACTIVE , &flags);/* * tx only connections collect statistics (on the same index as the
@@ -6425,9 +6400,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_bit64 (ECORE_Q_FLG_STATS , &flags);if (zero_stats) { -bnx2x_set_bit (ECORE_Q_FLG_ZERO_STATS , &flags); +rte_set_bit64 (ECORE_Q_FLG_ZERO_STATS , &flags); }/*
@@ -6435,10 +6410,10 @@ 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_bit64 (ECORE_Q_FLG_TX_SWITCH , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_PCSUM_ON_PKT , &flags); +rte_set_bit64 (ECORE_Q_FLG_PCSUM_ON_PKT , &flags);return flags; }
@@ -6448,15 +6423,15 @@ static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)unsigned long flags =0 ;if (IS_MF_SD (sc)) { -bnx2x_set_bit (ECORE_Q_FLG_OV , &flags); +rte_set_bit64 (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_bit64 (ECORE_Q_FLG_LEADING_RSS , &flags); +rte_set_bit64 (ECORE_Q_FLG_MCAST , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_VLAN , &flags); +rte_set_bit64 (ECORE_Q_FLG_VLAN , &flags);/* merge with common flags */ return flags |bnx2x_get_common_flags (sc, TRUE);
@@ -6577,7 +6552,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_bit64 (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* prepare the INIT parameters */ bnx2x_pf_q_prep_init (sc, fp, &q_params.params.init);
@@ -6645,20 +6620,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 , ¶ms.ramrod_flags); +rte_set_bit64 (RAMROD_COMP_WAIT , ¶ms.ramrod_flags); -bnx2x_set_bit (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags);/* RSS configuration */ -bnx2x_set_bit (ECORE_RSS_IPV4 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV4 , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV6 , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags);if (rss_obj->udp_rss_v4) { -bnx2x_set_bit (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); }if (rss_obj->udp_rss_v6) { -bnx2x_set_bit (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); }/* Hash bits */
@@ -6673,7 +6648,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 , ¶ms.rss_flags); +rte_set_bit64 (ECORE_RSS_SET_SRCH , ¶ms.rss_flags); }if (IS_PF (sc))
@@ -6730,11 +6705,11 @@ 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_bit64 (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_bit64 (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 :
@@ -6761,7 +6736,7 @@ static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)PMD_DRV_LOG (DEBUG , sc,"Adding Ethernet MAC" ); -bnx2x_set_bit (RAMROD_COMP_WAIT , &ramrod_flags); +rte_set_bit64 (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,
@@ -6893,24 +6868,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_bit64 (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_bit64 (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_bit64 (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_bit64 (BNX2X_LINK_REPORT_TX_FC_ON , + &data->link_report_flags); } }
@@ -6929,9 +6906,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_bit64 (BNX2X_LINK_REPORT_LINK_DOWN , &sc->last_reported_link.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_LINK_DOWN , +rte_get_bit64 (BNX2X_LINK_REPORT_LINK_DOWN , &cur_data.link_report_flags))) {return ; }
@@ -6946,14 +6923,14 @@ 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_bit64 (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 , +if (rte_test_and_clear_bit64 (BNX2X_LINK_REPORT_FULL_DUPLEX , &cur_data.link_report_flags)) { duplex ="full" ;ELINK_DEBUG_P0 (sc,"link set to full duplex" );
@@ -6968,19 +6945,19 @@ 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_bit64 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_get_bit64 (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 , + }else if (rte_get_bit64 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && - !bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , + !rte_get_bit64 (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_bit64 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_get_bit64 (BNX2X_LINK_REPORT_TX_FC_ON , &cur_data.link_report_flags)) { flow ="ON - transmit" ; }else {
drivers/net/bnx2x/bnx2x.h +0 -4
@@ -1809,10 +1809,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 +5 -4
@@ -15,6 +15,7 @@#define ECORE_SP_H #include <rte_byteorder.h> +#include <rte_bitops.h> #if RTE_BYTE_ORDER ==RTE_LITTLE_ENDIAN #ifndef __LITTLE_ENDIAN
@@ -73,10 +74,10 @@ 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_get_bit64(bit, var) +#define ECORE_SET_BIT (bit, var) rte_set_bit64(bit, var) +#define ECORE_CLEAR_BIT (bit, var) rte_clear_bit64(bit, var) +#define ECORE_TEST_AND_CLEAR_BIT (bit, var) rte_test_and_clear_bit64(bit, var)#define atomic_load_acq_int (int)*#define atomic_store_rel_int (a, v) (*a = v)
Signature · 1 line
2.7.4
PATCH v5 5/6 net/qede: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/qede/base/bcm_osal.c | 20 -------------------- drivers/net/qede/base/bcm_osal.h | 10 ++++------ 2 files changed, 4 insertions(+), 26 deletions(-)
drivers/net/qede/base/bcm_osal.c +0 -20
@@ -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;
drivers/net/qede/base/bcm_osal.h +4 -6
@@ -8,6 +8,7 @@#define __BCM_OSAL_H#include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_spinlock.h> #include <rte_malloc.h> #include <rte_atomic.h>
@@ -311,17 +312,14 @@ 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_bit64(bit, bitmap) -void qede_clr_bit (u32 ,unsigned long *);#define OSAL_CLEAR_BIT (bit, bitmap) \ - qede_clr_bit(bit, bitmap) + rte_clear_bit64(bit, bitmap) -bool qede_test_bit (u32 ,unsigned long *);#define OSAL_TEST_BIT (bit, bitmap) \ - qede_test_bit(bit, bitmap) + rte_get_bit64(bit, bitmap)u32 qede_find_first_bit (unsigned long *,u32 );#define OSAL_FIND_FIRST_BIT (bitmap, length) \
Signature · 1 line
2.7.4
PATCH v5 6/6 net/hinic: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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 | 16 ++++++++-------- drivers/net/hinic/meson.build | 2 ++ 4 files changed, 12 insertions(+), 40 deletions(-)
drivers/net/hinic/Makefile +1 -0
@@ -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
@@ -11,6 +11,7 @@#include <pthread.h> #include <rte_common.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memzone.h> #include <rte_memcpy.h> #include <rte_malloc.h>
@@ -117,38 +118,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 +8 -8
@@ -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_bit64 (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_bit64 (HINIC_DEV_START , &nic_dev->dev_status);return 0 ;
@@ -1201,7 +1201,7 @@ 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_bit64 (HINIC_DEV_START , &nic_dev->dev_status)) {PMD_DRV_LOG (INFO ,"Device %s already stopped" , name);return ; }
@@ -1246,7 +1246,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_bit64 (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 +2845,7 @@ 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_bit64 (HINIC_DEV_CLOSE , &nic_dev->dev_status)) {PMD_DRV_LOG (WARNING ,"Device %s already closed" , dev->data->name);return ;
@@ -3042,7 +3042,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_bit64 (HINIC_DEV_INTR_EN , &nic_dev->dev_status);/* initialize filter info */ filter_info = &nic_dev->filter;
@@ -3054,7 +3054,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_bit64 (HINIC_DEV_INIT , &nic_dev->dev_status);PMD_DRV_LOG (INFO ,"Initialize %s in primary successfully" , eth_dev->data->name);
@@ -3110,7 +3110,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_bit64 (HINIC_DEV_INIT , &nic_dev->dev_status);if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ;
drivers/net/hinic/meson.build +2 -0
@@ -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.7.4
v6 cover implement common rte bit operation APIs in PMDs
In reply to Joyce KongThere are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
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.
v5:
Correct the spelling mistake in test_bitops.c
v4:
Introduce uint32_t/uint64_t *addr when definiting bit operation APIs(suggested by Morten Brørup).
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(suggested by Stephen Hemminger).
2. Add test cases for common rte bit operation API(suggested by Stephen Hemminger).
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 (suggested by Jerin Jacob).
4. Use an well defined uint_NN_t type(suggested by Morten Brørup).
Joyce Kong (6):
lib/eal: implement the family of rte 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 | 305 +++++++++++++++++++ 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 | 14 +- drivers/net/bnx2x/bnx2x.c | 232 +++++++------- drivers/net/bnx2x/bnx2x.h | 10 +- drivers/net/bnx2x/ecore_sp.h | 47 +-- drivers/net/hinic/Makefile | 1 + drivers/net/hinic/base/hinic_compat.h | 33 +- drivers/net/hinic/hinic_pmd_ethdev.c | 16 +- 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/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 34 files changed, 1015 insertions(+), 323 deletions(-) create mode 100644 app/test/test_bitops.c create mode 100644 lib/librte_eal/common/include/rte_bitops.h
Signature · 1 line
2.7.4
PATCH v6 1/6 lib/eal: implement the family of rte bit operation APIs
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, when the bit operation is applied to the IO devices, use __ATOMIC_ACQ_REL to ensure the ordering for io bit operation.
--- MAINTAINERS | 5 + doc/api/doxy-api-index.md | 5 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 5 files changed, 485 insertions(+), 3 deletions(-) create mode 100644 lib/librte_eal/common/include/rte_bitops.h
MAINTAINERS +5 -0
@@ -236,6 +236,11 @@ M: Cristian Dumitrescu <[email protected]> F: lib/librte_eal/common/include/rte_bitmap.h F: app/test/test_bitmap.c +Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_bitops.h +F: app/test/test_bitops.c + MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.h
doc/api/doxy-api-index.md +3 -2
@@ -133,12 +133,13 @@ The public API headers are grouped by topics: [BPF] (@ref rte_bpf.h) - **containers**: + [bitmap] (@ref rte_bitmap.h), + [bitops] (@ref rte_bitops.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/common/Makefile +1 -0
@@ -19,6 +19,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h +INC += rte_bitops.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.h
lib/librte_eal/common/include/rte_bitops.h new file +474 -0
474 lines not on this page · raw message
lib/librte_eal/common/meson.build +2 -1
@@ -50,9 +50,10 @@ common_objs += eal_common_arch_objs common_headers = files( 'include/rte_alarm.h', + 'include/rte_bitmap.h', + 'include/rte_bitops.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', - 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', 'include/rte_compat.h',
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
Hi Joyce,
These APIs seem to be written considering the PMD requirements. Is there a need to expose these to applications (external to DPDK?).
Quoted 116 lines
-----Original Message-----
From: Joyce Kong <[email protected]>
Sent: Wednesday, December 18, 2019 12:00 AM
To: [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]>; Phil Yang <[email protected]>; Gavin Hu <[email protected]>
Cc: nd <[email protected]>; [email protected]
Subject: [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIsThere are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, when the bit operation is applied to the IO devices, use
__ATOMIC_ACQ_RELto ensure the ordering for io bit operation.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Gavin Hu <[email protected]>Reviewed-by Phil Yang <[email protected]>Acked-by Morten Brørup <[email protected]>--- MAINTAINERS | 5 + doc/api/doxy-api-index.md | 5 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 5 files changed, 485 insertions(+), 3 deletions(-) create mode 100644
lib/librte_eal/common/include/rte_bitops.hMAINTAINERS +0
-0@@ -236,6 +236,11 @@ M: Cristian Dumitrescu<[email protected]>
F:lib/librte_eal/common/include/rte_bitmap.h
F:app/test/test_bitmap.cMAINTAINERS +5
-0+Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_bitops.h +F: app/test/test_bitops.c + MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.hdoc/api/doxy-api-index.md index renamed from doc/api/doxy-api-index.md +0
-0dff496b..ade7c01 100644
doc/api/doxy-api-index.md +3
-2@@ -133,12 +133,13 @@ The public API headers are grouped by topics: [BPF] (@ref rte_bpf.h) - **containers**: + [bitmap] (@ref rte_bitmap.h), + [bitops] (@ref rte_bitops.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):(quoted diff) +0
-0b/lib/librte_eal/common/Makefile index c2c6d92..dd025c1 100644
lib/librte_eal/common/Makefile +0
-0@@ -19,6 +19,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC +=
rte_service.hrte_service_component.hINC +=rte_bitmap.hrte_vfio.hrte_hypervisor.hrte_test.hINC +=rte_reciprocal.hrte_fbarray.hrte_uuid.h+INC +=rte_bitops.h
GENERIC_INC:=rte_atomic.hrte_byteorder.hrte_cycles.hrte_prefetch.hGENERIC_INC+=rte_memcpy.hrte_cpuflags.hdiff --gita/lib/librte_eal/common/include/rte_bitops.hb/lib/librte_eal/common/include/rte_bitops.h
new file mode 100644
index 0000000..34158d1lib/librte_eal/common/include/rte_bitops.h new file +28
-0@@ -0,0 +1,474 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a API for bit operations without/with memory ordering. +*/ + +#include <stdint.h> +#include <rte_debug.h> +#include <rte_compat.h> + +/*---------------------------- 32 bit operations +----------------------------*/ + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Get the target bit from a 32-bit value without memory ordering. +*
lib/librte_eal/common/include/rte_bitops.h line 38
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h new file +10
-0+* @param nr +* The target bit to get. +* @param addr +* The address holding the bit. +* @return +* The target bit. +*/ +__rte_experimental +static inline uint32_t +rte_get_bit32_relaxed (unsigned int nr,uint32_t *addr) {
Why not pass the memory order as a parameter? It would reduce the number of API calls by half.
Quoted 101 lines
lib/librte_eal/common/include/rte_bitops.h new file +92
-0+RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +return __atomic_load_n (addr, __ATOMIC_RELAXED) & mask; } + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Set the target bit in a 32-bit value to 1 without memory ordering. +* +* @param nr +* The target bit to set. +* @param addr +* The address holding the bit. +*/ +__rte_experimental +static inline void +rte_set_bit32_relaxed (unsigned int nr,uint32_t *addr) { +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +__atomic_fetch_or (addr, mask, __ATOMIC_RELAXED); } + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Clear the target bit in a 32-bit value to 0 without memory ordering. +* +* @param nr +* The target bit to clear. +* @param addr +* The address holding the bit. +*/ +__rte_experimental +static inline void +rte_clear_bit32_relaxed (unsigned int nr,uint32_t *addr) { +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +__atomic_fetch_and (addr, ~mask, __ATOMIC_RELAXED); } + +/** +* @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. +*/ +__rte_experimental +static inline uint32_t +rte_test_and_set_bit32_relaxed (unsigned int nr,uint32_t *addr) { +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +return __atomic_fetch_or (addr, mask, __ATOMIC_RELAXED) & 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. +*/ +__rte_experimental +static inline uint32_t +rte_test_and_clear_bit32_relaxed (unsigned int nr,uint32_t *addr) { +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; + return __atomic_fetch_and(addr, ~mask, __ATOMIC_RELAXED) &mask; }
lib/librte_eal/common/include/rte_bitops.h new file +8
-0+ +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Get the target bit from a 32-bit value with memory ordering. +*
lib/librte_eal/common/include/rte_bitops.h
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h new file +10
-0+* @param nr +* The target bit to get. +* @param addr +* The address holding the bit. +* @return +* The target bit. +*/ +__rte_experimental +static inline uint32_t +rte_get_bit32 (unsigned int nr,uint32_t *addr) {
__atomic_load_n takes other memory orders along with relaxed and acquire. The API name needs to change to indicate acquire memory order here?
Quoted 14 lines
lib/librte_eal/common/include/rte_bitops.h new file +14
-0+RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +return __atomic_load_n (addr, __ATOMIC_ACQUIRE) & mask; } + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Set the target bit in a 32-bit value to 1 with memory ordering. +* +* @param nr +* The target bit to set.
lib/librte_eal/common/include/rte_bitops.h
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h new file +10
-0+* @param addr +* The address holding the bit. +*/ +__rte_experimental +static inline void +rte_set_bit32 (unsigned int nr,uint32_t *addr) { +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +__atomic_fetch_or (addr, mask, __ATOMIC_ACQ_REL); }
Why not use just '__ATOMIC_RELEASE' here? The full barrier might not be required in all use cases.
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h new file +10
-0+ +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Clear the target bit in a 32-bit value to 0 with memory ordering. +* +* @param nr +* The target bit to clear.
lib/librte_eal/common/include/rte_bitops.h
Quoted 10 lines
lib/librte_eal/common/include/rte_bitops.h new file +10
-0+* @param addr +* The address holding the bit. +*/ +__rte_experimental +static inline void +rte_clear_bit32 (unsigned int nr,uint32_t *addr) { +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; +__atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL); }
Why not use just '__ATOMIC_RELEASE' here? The full barrier might not be required in all use cases. I see similar issue in other APIs below.
Quoted 292 lines
lib/librte_eal/common/include/rte_bitops.h new file +23
-0+ +/** +* @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 with +* memory ordering. +* +* @param nr +* The target bit to get and set. +* @param addr +* The address holding the bit. +* @return +* The original bit. +*/ +__rte_experimental +static inline uint32_t +rte_test_and_set_bit32 (unsigned int nr,uint32_t *addr) { +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; + return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
lib/librte_eal/common/include/rte_bitops.h new file +23
-0+ +/** +* @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 with +* memory ordering. +* +* @param nr +* The target bit to get and clear. +* @param addr +* The address holding the bit. +* @return +* The original bit. +*/ +__rte_experimental +static inline uint32_t +rte_test_and_clear_bit32 (unsigned int nr,uint32_t *addr) { +RTE_ASSERT (nr <32 ); + +uint32_t mask =UINT32_C (1 ) << nr; + return __atomic_fetch_and(addr, ~mask, __ATOMIC_ACQ_REL) &mask; }
lib/librte_eal/common/include/rte_bitops.h new file +113
-0+ +/*---------------------------- 64 bit operations +----------------------------*/ + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Get the target bit from a 64-bit value without memory ordering. +* +* @param nr +* The target bit to get. +* @param addr +* The address holding the bit. +* @return +* The target bit. +*/ +__rte_experimental +static inline uint64_t +rte_get_bit64_relaxed (unsigned int nr,uint64_t *addr) { +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +return __atomic_load_n (addr, __ATOMIC_RELAXED) & mask; } + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Set the target bit in a 64-bit value to 1 without memory ordering. +* +* @param nr +* The target bit to set. +* @param addr +* The address holding the bit. +*/ +__rte_experimental +static inline void +rte_set_bit64_relaxed (unsigned int nr,uint64_t *addr) { +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +__atomic_fetch_or (addr, mask, __ATOMIC_RELAXED); } + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Clear the target bit in a 64-bit value to 0 without memory ordering. +* +* @param nr +* The target bit to clear. +* @param addr +* The address holding the bit. +*/ +__rte_experimental +static inline void +rte_clear_bit64_relaxed (unsigned int nr,uint64_t *addr) { +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +__atomic_fetch_and (addr, ~mask, __ATOMIC_RELAXED); } + +/** +* @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. +*/ +__rte_experimental +static inline uint64_t +rte_test_and_set_bit64_relaxed (unsigned int nr,uint64_t *addr) { +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +return __atomic_fetch_or (addr, mask, __ATOMIC_RELAXED) & mask; } + +/** +* @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. +*/ +__rte_experimental +static inline uint64_t +rte_test_and_clear_bit64_relaxed (unsigned int nr,uint64_t *addr) { +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; + return __atomic_fetch_and(addr, ~mask, __ATOMIC_RELAXED) &mask; }
lib/librte_eal/common/include/rte_bitops.h new file +85
-0+ +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Get the target bit from a 64-bit value with memory ordering. +* +* @param nr +* The target bit to get. +* @param addr +* The address holding the bit. +* @return +* The target bit. +*/ +__rte_experimental +static inline uint64_t +rte_get_bit64 (unsigned int nr,uint64_t *addr) { +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +return __atomic_load_n (addr, __ATOMIC_ACQUIRE) & mask; } + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Set the target bit in a 64-bit value to 1 with memory ordering. +* +* @param nr +* The target bit to set. +* @param addr +* The address holding the bit. +*/ +__rte_experimental +static inline void +rte_set_bit64 (unsigned int nr,uint64_t *addr) { +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +__atomic_fetch_or (addr, mask, __ATOMIC_ACQ_REL); } + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Clear the target bit in a 64-bit value to 0 with memory ordering. +* +* @param nr +* The target bit to clear. +* @param addr +* The address holding the bit. +*/ +__rte_experimental +static inline void +rte_clear_bit64 (unsigned int nr,uint64_t *addr) { +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; +__atomic_fetch_and (addr, ~mask, __ATOMIC_ACQ_REL); } + +/** +* @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 with +* memory ordering. +* +* @param nr +* The target bit to get and set. +* @param addr +* The address holding the bit. +* @return +* The original bit. +*/ +__rte_experimental +static inline uint64_t +rte_test_and_set_bit64 (unsigned int nr,uint64_t *addr) { +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; + return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) &mask; }
lib/librte_eal/common/include/rte_bitops.h new file +23
-0+ +/** +* @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 with +* memory ordering. +* +* @param nr +* The target bit to get and clear. +* @param addr +* The address holding the bit. +* @return +* The original bit. +*/ +__rte_experimental +static inline uint64_t +rte_test_and_clear_bit64 (unsigned int nr,uint64_t *addr) { +RTE_ASSERT (nr <64 ); + +uint64_t mask =UINT64_C (1 ) << nr; + return __atomic_fetch_and(addr, ~mask, __ATOMIC_ACQ_REL) &mask; }
lib/librte_eal/common/include/rte_bitops.h new file +1
-0+#endif /* _RTE_BITOPS_H_ */ lib/librte_eal/common/meson.build +2
-2@@ -50,9 +50,10 @@ common_objs += eal_common_arch_objs common_headers = files( 'include/rte_alarm.h', + 'include/rte_bitmap.h', + 'include/rte_bitops.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', - 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', 'include/rte_compat.h', --2.7.4
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
<snip>
Quoted 110 lines
Quoted 110 lines
Subject: [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
There are a lot functions of bit operations scattered and duplicated in PMDs, consolidating them into a common API family is necessary. Furthermore, when the bit operation is applied to the IO devices, use
__ATOMIC_ACQ_RELto ensure the ordering for io bit operation.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Gavin Hu <[email protected]>Reviewed-by Phil Yang <[email protected]>Acked-by Morten Brørup <[email protected]>--- MAINTAINERS | 5 + doc/api/doxy-api-index.md | 5 +- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 5 files changed, 485 insertions(+), 3 deletions(-) create mode100644
lib/librte_eal/common/include/rte_bitops.hMAINTAINERS +0
-0@@ -236,6 +236,11 @@ M: Cristian Dumitrescu<[email protected]>
F:lib/librte_eal/common/include/rte_bitmap.h
F:app/test/test_bitmap.cMAINTAINERS +5
-0+Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_bitops.h +F: app/test/test_bitops.c + MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.hdoc/api/doxy-api-index.md +0
-0index
dff496b..ade7c01 100644doc/api/doxy-api-index.md +3
-2@@ -133,12 +133,13 @@ The public API headers are grouped by topics: [BPF] (@ref rte_bpf.h) - **containers**: + [bitmap] (@ref rte_bitmap.h), + [bitops] (@ref rte_bitops.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):(quoted diff) +0
-0b/lib/librte_eal/common/Makefile index c2c6d92..dd025c1 100644
lib/librte_eal/common/Makefile +1
-0@@ -19,6 +19,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h
rte_vfio.hrte_hypervisor.hrte_test.hINC +=rte_reciprocal.hrte_fbarray.hrte_uuid.h
+INC +=rte_bitops.h
GENERIC_INC:=rte_atomic.hrte_byteorder.hrte_cycles.hrte_prefetch.hGENERIC_INC+=rte_memcpy.hrte_cpuflags.hdiff --gita/lib/librte_eal/common/include/rte_bitops.hb/lib/librte_eal/common/include/rte_bitops.h
new file mode 100644
index 0000000..34158d1lib/librte_eal/common/include/rte_bitops.h new file +32
-0@@ -0,0 +1,474 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef _RTE_BITOPS_H_ +#define _RTE_BITOPS_H_ + +/** +* @file +* Bit Operations +* +* This file defines a API for bit operations without/with memory ordering. +*/ + +#include <stdint.h> +#include <rte_debug.h> +#include <rte_compat.h> + +/*---------------------------- 32 bit operations +----------------------------*/ + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior +notice +* +* Get the target bit from a 32-bit value without memory ordering. +* +* @param nr +* The target bit to get. +* @param addr +* The address holding the bit.
Quoted 8 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 6 lines
lib/librte_eal/common/include/rte_bitops.h new file +6
-0+* @return +* The target bit. +*/ +__rte_experimental +static inline uint32_t +rte_get_bit32_relaxed (unsigned int nr,uint32_t *addr) {Why not pass the memory order as a parameter? It would reduce the number of API calls by half.
I think these APIs should be modelled according to C11 __atomic_xxx APIs. Otherwise, the programmers have to understand another interface. It will also help reduce the number of APIs. Converting these into macros will help remove the size based duplication of APIs. I came up with the following macro:
#define RTE_GET_BIT(nr, var, ret, memorder) \
({ \
if (sizeof(var) == sizeof(uint32_t)) { \
uint32_t mask1 = 1U << (nr)%32; \
ret = __atomic_load_n(&var, (memorder)) & mask1;\
} \
else {\
uint64_t mask2 = 1UL << (nr)%64;\
ret = __atomic_load_n(&var, (memorder)) & mask2;\
} \
})The '%' is required to avoid a compiler warning/error. But the '%' operation will get removed by the compiler since 'nr' is a constant. IMO, the macro itself is not complex and should not be a pain for debugging.
Currently, we have 20 APIs in this patch (possibly more coming in the future and creating an explosion with memory order/size combinations). The above macro will reduce this to 5 macros without further explosion in number of combinations.
Any thoughts? What do others think?
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
Quoted 13 lines · On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli…
Converting these into macros will help remove the size based duplication of APIs. I came up with the following macro:
#define
RTE_GET_BIT(nr, var, ret, memorder)\({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })
Macros are more error prone. Especially because this is in exposed header file
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
<snip>
Quoted 18 lines
Quoted 1 line · On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli…
Converting these into macros will help remove the size based duplication of
APIs. I came up with the following macro:
Quoted 11 lines
#define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })
Quoted 1 line
Macros are more error prone. Especially because this is in exposed header file
That's another question I have. Why do we need to have these APIs in a public header file? These will add to the ABI burden as well. These APIs should be in a common-but-not-public header file. I am also not sure how helpful these APIs are for applications as these APIs seem to have considered requirements only from the PMDs.
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
Quoted 20 lines · On Mon, 23 Dec 2019 05:04:12 +0000 Honnappa Nagarahalli…
<snip>
Quoted 18 lines
Quoted 1 line · On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli…
Converting these into macros will help remove the size based duplication of
APIs. I came up with the following macro:
Quoted 11 lines
#define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })
Quoted 2 lines
Quoted 1 line
Macros are more error prone. Especially because this is in exposed header file
That's another question I have. Why do we need to have these APIs in a public header file? These will add to the ABI burden as well. These APIs should be in a common-but-not-public header file. I am also not sure how helpful these APIs are for applications as these APIs seem to have considered requirements only from the PMDs.
Why do we have to wrap every C atomic builtin? What value is there in that?
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
Hi Stephen, Honnappa,
Quoted 39 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, December 24, 2019 12:37 AM
To: Honnappa Nagarahalli <[email protected]>
Cc: 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]; Phil Yang <[email protected]>; Gavin Hu <[email protected]>; nd <[email protected]>; [email protected]
Subject: Re: [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIsQuoted 7 lines · On Mon, 23 Dec 2019 05:04:12 +0000 Honnappa Nagarahalli…
<snip>
Quoted 5 lines
Quoted 1 line · On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli…
Converting these into macros will help remove the size based duplication
of
Quoted 13 lines
Quoted 13 lines
APIs. I came up with the following macro:
Quoted 11 lines
#define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })Quoted 1 line
Quoted 1 line
Macros are more error prone. Especially because this is in exposed header
Quoted 8 lines
file
Quoted 1 line
That's another question I have. Why do we need to have these APIs in a
public header file? These will add to the ABI burden as well. These APIs should be in a common-but-not-public header file. I am also not sure how helpful these APIs are for applications as these APIs seem to have considered requirements only from the PMDs.
Why do we have to wrap every C atomic builtin? What value is there in that?
The wrapping is aimed to reduce code duplication, on average 3 lines cut down to 1 line for a single core.
Overall I am thinking this bitops APIs are targeted for use by PMDs only, applications can use C11 freely.
The initial thought for the new APIs came from the idea of consolidating the scattered bit operations all over the PMDs. It is unwise to expanding to applications or libraries, as different memory orderings are required and complexity generate.
If the use cases are limited to PMDs, a 'volatile' or a compiler barrier is sufficient therefore the number of APIs can be saved by half.
http://inbox.dpdk.org/dev/VI1PR08MB53766C30B5CDA00FB9FCE9678F2E0@VI1PR08MB5376.eurprd08.prod.outlook.com/
Any thoughts and comments are welcome!
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
<snip>
Quoted 42 lines
Quoted 24 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines · On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli…
Converting these into macros will help remove the size based duplication
of
Quoted 13 lines
Quoted 13 lines
APIs. I came up with the following macro:
Quoted 11 lines
#define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })Quoted 2 lines
Quoted 2 lines
Macros are more error prone. Especially because this is in exposed header
file
Quoted 8 lines
Quoted 2 lines
That's another question I have. Why do we need to have these APIs in a
public header file? These will add to the ABI burden as well. These APIs should be in a common-but-not-public header file. I am also not sure how helpful these APIs are for applications as these APIs seem to have considered requirements only from the PMDs.
Why do we have to wrap every C atomic builtin? What value is there in that?
The wrapping is aimed to reduce code duplication, on average 3 lines cut down to 1 line for a single core.
Overall I am thinking this bitops APIs are targeted for use by PMDs only, applications can use C11 freely.
The initial thought for the new APIs came from the idea of consolidating the scattered bit operations all over the PMDs. It is unwise to expanding to applications or libraries, as different memory orderings are required and complexity generate.
Quoted 6 lines
If the use cases are limited to PMDs, a 'volatile' or a compiler barrier is sufficient therefore the number of APIs can be saved by half.
http://inbox.dpdk.org/dev/VI1PR08MB53766C30B5CDA00FB9FCE9678F2E0
@VI1PR08MB5376.eurprd08.prod.outlook.com/Any thoughts and comments are welcome!
I would prefer that the APIs/Macros just address PMD's requirements. These also should be kept private (through naming conventions?). Given that the current PMDs are not using C11, we can skip using C11 atomics in these APIs.
Quoted 1 line
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
Quoted 44 lines · On Tue, 7 Jan 2020 00:44:51 +0000 Honnappa Nagarahalli…
<snip>
Quoted 42 lines
Quoted 24 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines · On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli…
Converting these into macros will help remove the size based duplication
of
Quoted 13 lines
Quoted 13 lines
APIs. I came up with the following macro:
Quoted 11 lines
#define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })Quoted 2 lines
Quoted 2 lines
Macros are more error prone. Especially because this is in exposed header
file
Quoted 8 lines
Quoted 2 lines
That's another question I have. Why do we need to have these APIs in a
public header file? These will add to the ABI burden as well. These APIs should be in a common-but-not-public header file. I am also not sure how helpful these APIs are for applications as these APIs seem to have considered requirements only from the PMDs.
Why do we have to wrap every C atomic builtin? What value is there in that?
The wrapping is aimed to reduce code duplication, on average 3 lines cut down to 1 line for a single core.
Overall I am thinking this bitops APIs are targeted for use by PMDs only, applications can use C11 freely.
The initial thought for the new APIs came from the idea of consolidating the scattered bit operations all over the PMDs. It is unwise to expanding to applications or libraries, as different memory orderings are required and complexity generate.
Quoted 7 lines
Quoted 6 lines
If the use cases are limited to PMDs, a 'volatile' or a compiler barrier is sufficient therefore the number of APIs can be saved by half.
http://inbox.dpdk.org/dev/VI1PR08MB53766C30B5CDA00FB9FCE9678F2E0
@VI1PR08MB5376.eurprd08.prod.outlook.com/Any thoughts and comments are welcome!
I would prefer that the APIs/Macros just address PMD's requirements. These also should be kept private (through naming conventions?). Given that the current PMDs are not using C11, we can skip using C11 atomics in these APIs.
Not in favor, just use existing Gcc/clang/icc atomics instead of creating unnecessary bloat wrappers.
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
<snip>
Quoted 50 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines · On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli…
Converting these into macros will help remove the size based duplication
of
Quoted 13 lines
Quoted 13 lines
APIs. I came up with the following macro:
Quoted 11 lines
#define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })Quoted 2 lines
Quoted 2 lines
Macros are more error prone. Especially because this is in exposed header
file
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
That's another question I have. Why do we need to have these APIs in a
public header file? These will add to the ABI burden as well. These APIs should be in a common-but-not-public header file. I am also not sure how helpful these APIs are for applications as these APIs seem to have considered requirements only from the PMDs.
Why do we have to wrap every C atomic builtin? What value is there in
that?
Quoted 10 lines
Quoted 10 lines
The wrapping is aimed to reduce code duplication, on average 3 lines cut down to 1 line for a single core.
Overall I am thinking this bitops APIs are targeted for use by PMDs only, applications can use C11 freely.
The initial thought for the new APIs came from the idea of consolidating the scattered bit operations all over the PMDs. It is unwise to expanding to applications or libraries, as different memory orderings are required and complexity generate.Quoted 3 lines
Quoted 3 lines
If the use cases are limited to PMDs, a 'volatile' or a compiler barrier is sufficient therefore the number of APIs can be saved by half.
http://inbox.dpdk.org/dev/VI1PR08MB53766C30B5CDA00FB9FCE9678F2E0
Quoted 2 lines
Quoted 2 lines
@VI1PR08MB5376.eurprd08.prod.outlook.com/
Quoted 8 lines
Quoted 2 lines
Quoted 1 line
Any thoughts and comments are welcome!
I would prefer that the APIs/Macros just address PMD's requirements.
These also should be kept private (through naming conventions?). Given that the current PMDs are not using C11, we can skip using C11 atomics in these APIs.
Not in favor, just use existing Gcc/clang/icc atomics instead of creating unnecessary bloat wrappers.
I thought, you blessed this patch [1].
[1] http://mails.dpdk.org/archives/dev/2019-October/147297.html
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
In reply to Stephen Hemminger<snip>
Quoted 21 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line · On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli…
Converting these into macros will help remove the size based
duplication of
Quoted 13 lines
Quoted 13 lines
APIs. I came up with the following macro:
Quoted 11 lines
#define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })Quoted 1 line
Quoted 1 line
Macros are more error prone. Especially because this is in exposed header
Quoted 8 lines
file
Quoted 1 line
That's another question I have. Why do we need to have these APIs in a
public header file? These will add to the ABI burden as well. These APIs should be in a common-but-not-public header file. I am also not sure how helpful these APIs are for applications as these APIs seem to have considered requirements only from the PMDs.
Why do we have to wrap every C atomic builtin? What value is there in that?
As long as we stick to requirements from PMD we do not need to worry about every atomic builtin. We seem to be making these APIs public, which requires us to keep these APIs generic considering possible future requirements.
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
In reply to Honnappa NagarahalliQuoted 13 lines · On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli…
Converting these into macros will help remove the size based duplication of APIs. I came up with the following macro:
#define
RTE_GET_BIT(nr, var, ret, memorder)\({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })
Follow on if you want to do it as macros, then use typeof() to make the mask any size.
Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
Quoted 19 lines
Quoted 1 line · On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli…
Converting these into macros will help remove the size based duplication of
APIs. I came up with the following macro:
Quoted 11 lines
#define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })
Quoted 2 lines
Follow on if you want to do it as macros, then use
typeof()to make the mask any size.
Yes, that makes it much simple
#define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \
typeof(var) mask; \
if (sizeof(var) == sizeof(uint32_t)) { \
mask = 1U << (nr)%32; \
} else {\
mask = 1UL << (nr)%64;\
} \
ret = __atomic_load_n(&var, (memorder)) & mask;\
})Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
In reply to Honnappa NagarahalliQuoted 20 lines · Honnappa Nagarahalli
Quoted 5 lines
lib/librte_eal/common/include/rte_bitops.h
Quoted 3 lines
lib/librte_eal/common/include/rte_bitops.h new file +3
-0+__rte_experimental +static inline uint32_t +rte_get_bit32_relaxed (unsigned int nr,uint32_t *addr) {Why not pass the memory order as a parameter? It would reduce the number of API calls by half.
I think these APIs should be modelled according to C11
__atomic_xxxAPIs. Otherwise, the programmers have to understand another interface. It will also help reduce the number of APIs. Converting these into macros will help remove the size based duplication of APIs. I came up with the following macro:#define
RTE_GET_BIT(nr, var, ret, memorder)\({ \ if (sizeof(var) == sizeof(uint32_t)) { \ uint32_t mask1 = 1U << (nr)%32; \ ret = __atomic_load_n(&var, (memorder)) & mask1;\ } \ else {\ uint64_t mask2 = 1UL << (nr)%64;\ ret = __atomic_load_n(&var, (memorder)) & mask2;\ } \ })
Quoted 6 lines
The '%' is required to avoid a compiler warning/error. But the '%' operation will get removed by the compiler since 'nr' is a constant. IMO, the macro itself is not complex and should not be a pain for debugging.
Currently, we have 20 APIs in this patch (possibly more coming in the future and creating an explosion with memory order/size combinations). The above macro will reduce this to 5 macros without further explosion in number of combinations.
Any thoughts? What do others think?
# I think, the most common use case for register manipulation is getting/setting of "fields"(set of consecutive bits). IMO, Linux kernel bit manipulation APIs makes more sense.
At least have implementation similar to FIELD_GET() and FIELD_SET().
https://github.com/torvalds/linux/blob/master/include/linux/bitfield.h
# FIELD_GET will be superset API. A single bit can get through width = 1
# I think, it good to two versions of Macro/API. RTE_FIELD_GET(without atomics) and RTE_FIELD_GET_ATOMIC(with C11 atomics)
PATCH v6 2/6 test/bitops: add bit operation test case
In reply to Joyce KongAdd test cases for set bit, clear bit, test and set bit, test and clear bit operations.
--- app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/meson.build | 2 + app/test/test_bitops.c | 305 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100644 app/test/test_bitops.c
app/test/Makefile +1 -0
@@ -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
@@ -405,6 +405,12 @@ "Report": None, }, { + "Name": "Bitops test", + "Command": "bitops_autotest", + "Func": default_autotest, + "Report": None, + }, + { "Name": "Hash multiwriter autotest", "Command": "hash_multiwriter_autotest", "Func": default_autotest,
app/test/meson.build +2 -0
@@ -14,6 +14,7 @@ test_sources = files('commands.c', 'test_atomic.c', 'test_barrier.c', 'test_bitratestats.c', + 'test_bitops.c', 'test_bpf.c', 'test_byteorder.c', 'test_cmdline.c',
@@ -167,6 +168,7 @@ fast_test_names = [ 'alarm_autotest', 'atomic_autotest', 'byteorder_autotest', + 'bitops_autotest', 'cmdline_autotest', 'common_autotest', 'cpuflags_autotest',
app/test/test_bitops.c new file +305 -0
305 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 3/6 net/axgbe: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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 | 14 +++++++------- 4 files changed, 16 insertions(+), 43 deletions(-)
drivers/net/axgbe/axgbe_common.h +1 -28
@@ -22,6 +22,7 @@#include <pthread.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memory.h> #include <rte_malloc.h> #include <rte_hexdump.h>
@@ -1674,34 +1675,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
@@ -201,8 +201,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 (AXGBE_STOPPED , &pdata->dev_state); +rte_clear_bit32 (AXGBE_DOWN , &pdata->dev_state);return 0 ; }
@@ -216,17 +216,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 (AXGBE_STOPPED , &pdata->dev_state))return ; -axgbe_set_bit (AXGBE_STOPPED , &pdata->dev_state); +rte_set_bit32 (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 (AXGBE_DOWN , &pdata->dev_state); }/* Clear all resources like TX/RX queues. */
@@ -598,8 +598,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 (AXGBE_DOWN , &pdata->dev_state); +rte_set_bit32 (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
@@ -464,7 +464,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 +7 -7
@@ -743,7 +743,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 (AXGBE_LINK_INIT , &pdata->dev_state); pdata->link_check =rte_get_timer_cycles (); ret = pdata->phy_if.phy_impl.an_config (pdata);
@@ -807,9 +807,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 (AXGBE_LINK_ERR , &pdata->dev_state);else -axgbe_clear_bit (AXGBE_LINK_ERR , &pdata->dev_state); +rte_clear_bit32 (AXGBE_LINK_ERR , &pdata->dev_state);pthread_mutex_unlock (&pdata->an_mutex);
@@ -880,7 +880,7 @@ static void axgbe_phy_status(struct axgbe_port *pdata)unsigned int link_aneg;int an_restart; -if (axgbe_test_bit (AXGBE_LINK_ERR , &pdata->dev_state)) { +if (rte_get_bit32 (AXGBE_LINK_ERR , &pdata->dev_state)) { pdata->phy.link =0 ; goto adjust_link; }
@@ -900,10 +900,10 @@ static void axgbe_phy_status(struct axgbe_port *pdata)return ; }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 (AXGBE_LINK_INIT , &pdata->dev_state)) +rte_clear_bit32 (AXGBE_LINK_INIT , &pdata->dev_state); }else { -if (axgbe_test_bit (AXGBE_LINK_INIT , &pdata->dev_state)) { +if (rte_get_bit32 (AXGBE_LINK_INIT , &pdata->dev_state)) {axgbe_check_link_timeout (pdata);if (link_aneg)
Signature · 1 line
2.7.4
PATCH v6 4/6 net/bnx2x: use common rte bit operation APIs instead
In reply to Joyce KongRemove its own bit operation APIs and use the common one, this can reduce the code duplication largely.
--- drivers/net/bnx2x/bnx2x.c | 232 +++++++++++++++++++------------------------ drivers/net/bnx2x/bnx2x.h | 10 +- drivers/net/bnx2x/ecore_sp.h | 47 ++++----- 3 files changed, 131 insertions(+), 158 deletions(-)
drivers/net/bnx2x/bnx2x.c +104 -128
@@ -26,6 +26,7 @@#include <fcntl.h> #include <zlib.h> #include <rte_string_fns.h> +#include <rte_bitops.h> #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"#define BNX2X_PMD_VERSION_MAJOR 1
@@ -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);
@@ -1422,16 +1397,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 (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 (mac_type, &vlan_mac_flags); rc = mac_obj->delete_all (sc, mac_obj, &vlan_mac_flags, &ramrod_flags);if (rc <0 )
@@ -1442,8 +1417,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 ;
@@ -1458,26 +1432,26 @@ 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 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_MULTICAST , rx_accept_flags); +rte_set_bit32 (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 (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_MULTICAST , tx_accept_flags); +rte_set_bit32 (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 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_set_bit32 (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 (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_BROADCAST , tx_accept_flags);break ;
@@ -1488,19 +1462,20 @@ 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 (ECORE_ACCEPT_UNMATCHED , rx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_UNICAST , rx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_ALL_MULTICAST , rx_accept_flags); +rte_set_bit32 (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 (ECORE_ACCEPT_ALL_MULTICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_BROADCAST , tx_accept_flags);if (IS_MF_SI (sc)) { -bnx2x_set_bit (ECORE_ACCEPT_ALL_UNICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_ALL_UNICAST , + tx_accept_flags); }else { -bnx2x_set_bit (ECORE_ACCEPT_UNICAST , tx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_UNICAST , tx_accept_flags); }break ;
@@ -1512,8 +1487,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 (ECORE_ACCEPT_ANY_VLAN , rx_accept_flags); +rte_set_bit32 (ECORE_ACCEPT_ANY_VLAN , tx_accept_flags); }return 0 ;
@@ -1542,7 +1517,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 (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); ramrod_param.ramrod_flags = ramrod_flags; ramrod_param.rx_mode_flags = rx_mode_flags;
@@ -1561,8 +1536,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,
@@ -1571,9 +1546,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 (RAMROD_RX , &ramrod_flags); +rte_set_bit32 (RAMROD_TX , &ramrod_flags); +rte_set_bit32 (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,
@@ -1698,7 +1673,7 @@ 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 (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);/* STARTED-->TX_STOPPED */ func_params.cmd =ECORE_F_CMD_TX_STOP ;
@@ -1722,7 +1697,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 (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* Stop the primary connection: */
@@ -1783,7 +1758,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 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_STOP ;
@@ -1797,7 +1772,7 @@ 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 (RAMROD_DRV_CLR_ONLY , &func_params.ramrod_flags);return ecore_func_state_change (sc, &func_params); }
@@ -1809,7 +1784,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 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_RESET ;
@@ -1866,11 +1841,10 @@ 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 (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state)) +rte_set_bit32 (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;
@@ -1952,7 +1926,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;
@@ -1960,12 +1934,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 (RAMROD_COMP_WAIT , &ramrod_flags);/* Perform a dry cleanup */ -bnx2x_set_bit (RAMROD_DRV_CLR_ONLY , &ramrod_flags); +rte_set_bit32 (RAMROD_DRV_CLR_ONLY , &ramrod_flags);/* Clean ETH primary MAC */ -bnx2x_set_bit (ECORE_ETH_MAC , &vlan_mac_flags); +rte_set_bit32 (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 ) {
@@ -1974,7 +1948,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 (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,
@@ -1984,7 +1958,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 (RAMROD_DRV_CLR_ONLY , &rparam.ramrod_flags);/* Add a DEL command... */ rc =ecore_config_mcast (sc, &rparam,ECORE_MCAST_CMD_DEL );
@@ -4282,13 +4256,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 (RAMROD_CONT , &ramrod_flags);switch (le32toh (elem->message.data.eth_event.echo) >>BNX2X_SWCID_SHIFT ) {case ECORE_FILTER_MAC_PENDING :
@@ -4319,12 +4293,12 @@ bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *estatic void bnx2x_handle_rx_mode_eqe (struct bnx2x_softc *sc) { -bnx2x_clear_bit (ECORE_FILTER_RX_MODE_PENDING , &sc->sp_state); +rte_clear_bit32 (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 (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)
@@ -4693,7 +4667,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 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_HW_INIT ;
@@ -4941,7 +4915,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;
@@ -4988,8 +4962,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 (ECORE_Q_TYPE_HAS_RX , &q_type); +rte_set_bit32 (ECORE_Q_TYPE_HAS_TX , &q_type); ecore_init_queue_obj(sc, &sc->sp_objs[idx].q_obj,
@@ -5803,7 +5777,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 (RAMROD_COMP_WAIT , &func_params.ramrod_flags); func_params.f_obj = &sc->func_obj; func_params.cmd =ECORE_F_CMD_START ;
@@ -6379,11 +6353,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 (ECORE_Q_FLG_HC , &init_params->rx.flags); +rte_set_bit32 (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 (ECORE_Q_FLG_HC_EN , &init_params->rx.flags); +rte_set_bit32 (ECORE_Q_FLG_HC_EN , &init_params->tx.flags);/* HC rate */ init_params->rx.hc_rate =
@@ -6414,10 +6388,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 (ECORE_Q_FLG_ACTIVE , &flags);/* * tx only connections collect statistics (on the same index as the
@@ -6425,9 +6399,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 (ECORE_Q_FLG_STATS , &flags);if (zero_stats) { -bnx2x_set_bit (ECORE_Q_FLG_ZERO_STATS , &flags); +rte_set_bit32 (ECORE_Q_FLG_ZERO_STATS , &flags); }/*
@@ -6435,28 +6409,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 (ECORE_Q_FLG_TX_SWITCH , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_PCSUM_ON_PKT , &flags); +rte_set_bit32 (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 (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 (ECORE_Q_FLG_LEADING_RSS , &flags); +rte_set_bit32 (ECORE_Q_FLG_MCAST , &flags); } -bnx2x_set_bit (ECORE_Q_FLG_VLAN , &flags); +rte_set_bit32 (ECORE_Q_FLG_VLAN , &flags);/* merge with common flags */ return flags |bnx2x_get_common_flags (sc, TRUE);
@@ -6577,7 +6551,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 (RAMROD_COMP_WAIT , &q_params.ramrod_flags);/* prepare the INIT parameters */ bnx2x_pf_q_prep_init (sc, fp, &q_params.params.init);
@@ -6645,20 +6619,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 , ¶ms.ramrod_flags); +rte_set_bit32 (RAMROD_COMP_WAIT , ¶ms.ramrod_flags); -bnx2x_set_bit (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_MODE_REGULAR , ¶ms.rss_flags);/* RSS configuration */ -bnx2x_set_bit (ECORE_RSS_IPV4 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6 , ¶ms.rss_flags); -bnx2x_set_bit (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV4 , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV4_TCP , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV6 , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV6_TCP , ¶ms.rss_flags);if (rss_obj->udp_rss_v4) { -bnx2x_set_bit (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV4_UDP , ¶ms.rss_flags); }if (rss_obj->udp_rss_v6) { -bnx2x_set_bit (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_IPV6_UDP , ¶ms.rss_flags); }/* Hash bits */
@@ -6673,7 +6647,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 , ¶ms.rss_flags); +rte_set_bit32 (ECORE_RSS_SET_SRCH , ¶ms.rss_flags); }if (IS_PF (sc))
@@ -6718,7 +6692,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;
@@ -6730,11 +6704,11 @@ 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 (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 (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 :
@@ -6757,11 +6731,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 (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,
@@ -6893,24 +6867,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 (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 (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 (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 (BNX2X_LINK_REPORT_TX_FC_ON , + &data->link_report_flags); } }
@@ -6929,9 +6905,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 (BNX2X_LINK_REPORT_LINK_DOWN , &sc->last_reported_link.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_LINK_DOWN , +rte_get_bit32 (BNX2X_LINK_REPORT_LINK_DOWN , &cur_data.link_report_flags))) {return ; }
@@ -6946,14 +6922,14 @@ 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 (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 , +if (rte_test_and_clear_bit32 (BNX2X_LINK_REPORT_FULL_DUPLEX , &cur_data.link_report_flags)) { duplex ="full" ;ELINK_DEBUG_P0 (sc,"link set to full duplex" );
@@ -6968,19 +6944,19 @@ 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 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_get_bit32 (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 , + }else if (rte_get_bit32 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && - !bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , + !rte_get_bit32 (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 (BNX2X_LINK_REPORT_RX_FC_ON , &cur_data.link_report_flags) && -bnx2x_test_bit (BNX2X_LINK_REPORT_TX_FC_ON , +rte_get_bit32 (BNX2X_LINK_REPORT_TX_FC_ON , &cur_data.link_report_flags)) { flow ="ON - transmit" ; }else {
drivers/net/bnx2x/bnx2x.h +3 -7
@@ -997,8 +997,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 {
@@ -1229,7 +1229,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;
@@ -1809,10 +1809,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 +24 -23
114 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 5/6 net/qede: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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
@@ -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
@@ -8,6 +8,7 @@#define __BCM_OSAL_H#include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_spinlock.h> #include <rte_malloc.h> #include <rte_atomic.h>
@@ -311,23 +312,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(bit, bitmap) -void qede_clr_bit (u32 ,unsigned long *);#define OSAL_CLEAR_BIT (bit, bitmap) \ - qede_clr_bit(bit, bitmap) + rte_clear_bit32(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(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 *addr,u32 limit);#define OSAL_FIND_FIRST_ZERO_BIT (bitmap, length) \ qede_find_first_zero_bit(bitmap, length)
drivers/net/qede/base/ecore.h +3 -3
@@ -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
@@ -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
@@ -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
@@ -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))
@@ -6202,7 +6202,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);
@@ -6779,5 +6779,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -378,8 +378,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.7.4
PATCH v6 6/6 net/hinic: use common rte bit operation APIs instead
In reply to Joyce KongRemove 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 | 16 ++++++++-------- drivers/net/hinic/hinic_pmd_ethdev.h | 2 +- drivers/net/hinic/meson.build | 2 ++ 5 files changed, 13 insertions(+), 41 deletions(-)
drivers/net/hinic/Makefile +1 -0
@@ -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
@@ -11,6 +11,7 @@#include <pthread.h> #include <rte_common.h> #include <rte_byteorder.h> +#include <rte_bitops.h> #include <rte_memzone.h> #include <rte_memcpy.h> #include <rte_malloc.h>
@@ -117,38 +118,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 +8 -8
@@ -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 (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 (HINIC_DEV_START , &nic_dev->dev_status);return 0 ;
@@ -1201,7 +1201,7 @@ 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 (HINIC_DEV_START , &nic_dev->dev_status)) {PMD_DRV_LOG (INFO ,"Device %s already stopped" , name);return ; }
@@ -1246,7 +1246,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 (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 +2845,7 @@ 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 (HINIC_DEV_CLOSE , &nic_dev->dev_status)) {PMD_DRV_LOG (WARNING ,"Device %s already closed" , dev->data->name);return ;
@@ -3042,7 +3042,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 (HINIC_DEV_INTR_EN , &nic_dev->dev_status);/* initialize filter info */ filter_info = &nic_dev->filter;
@@ -3054,7 +3054,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 (HINIC_DEV_INIT , &nic_dev->dev_status);PMD_DRV_LOG (INFO ,"Initialize %s in primary successfully" , eth_dev->data->name);
@@ -3110,7 +3110,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 (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
@@ -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
@@ -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.7.4
Hi Maintainers,
This series of patches is to consolidate the rte bitops APIs(to reduce duplication) and aim for use by all PMDs. In this stage, a few of PMDs you maintained were piloted to stabilize the APIs.
Before expansion to all PMDs, could you please shout out your opinions?
The APIs have already evolved over community feedback, have a look to know more the background.
Best Regards,
Gavin
Quoted 100 lines
-----Original Message-----
From: Joyce Kong <[email protected]>
Sent: Wednesday, December 18, 2019 2:00 PM
To: [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]>; Phil Yang <[email protected]>; Gavin Hu <[email protected]>
Cc: nd <[email protected]>; [email protected]
Subject: [PATCH v6 0/6] implement common rte bit operation APIs in PMDsThere are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code
duplication.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.v5:
Correct the spelling mistake intest_bitops.cv4:
Introduce uint32_t/uint64_t *addr when definiting bit operation
APIs(suggested by
Morten Brørup).v3:
1. Change the API's head file back torte_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(suggested by
Stephen Hemminger).
2. Add test cases for common rte bit operation API(suggested by Stephen
Hemminger).
3. Change the header file torte_io_bitops.hand the operation to
rte_io_set_bit()etc.,
as the API uses barriers inside and the barriers are only needed for IO
operations
(suggested by Jerin Jacob).
4. Use an well defineduint_NN_ttype(suggested by Morten Brørup).Joyce Kong (6):
lib/eal: implement the family of rte 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 insteadMAINTAINERS | 5 + app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/meson.build | 2 + app/test/test_bitops.c | 305 +++++++++++++++++++ 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 | 14 +- drivers/net/bnx2x/bnx2x.c | 232 +++++++------- drivers/net/bnx2x/bnx2x.h | 10 +- drivers/net/bnx2x/ecore_sp.h | 47 +-- drivers/net/hinic/Makefile | 1 + drivers/net/hinic/base/hinic_compat.h | 33 +- drivers/net/hinic/hinic_pmd_ethdev.c | 16 +- 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/common/Makefile | 1 + lib/librte_eal/common/include/rte_bitops.h | 474 +++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 34 files changed, 1015 insertions(+), 323 deletions(-) create mode 100644 app/test/test_bitops.c create mode 100644 lib/librte_eal/common/include/rte_bitops.h--
2.7.4
Quoted 23 lines · Joyce Kong
There are a lot functions of bit operations scattered in PMDs, consolidate them into a common API family and applied in different PMDs to reduce code duplication.
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.v5:
Correct the spelling mistake intest_bitops.cv4:
Introduce uint32_t/uint64_t *addr when definiting bit operation APIs(suggested by Morten Brørup).v3:
1. Change the API's head file back torte_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.
Quoted 7 lines
v2:
1. Add doxygen comments for the rte bit operation API(suggested by Stephen Hemminger).
2. Add test cases for common rte bit operation API(suggested by Stephen Hemminger).
3. Change the header file torte_io_bitops.hand the operation to rte_io_set_bit()etc., as the API uses barriers inside and the barriers are only needed for IO operations (suggested by Jerin Jacob).
4. Use an well defineduint_NN_ttype(suggested by Morten Brørup).
I did not wait for travis to finish but afaics, this series only builds on 32bits and AARCH64.
https://travis-ci.com/david-marchand/dpdk/builds/144927372
Signature · 1 line
David Marchand
v7 cover implement common rte bit operation APIs in PMDs
In reply to Joyce KongBitwise 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).
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 PMD bit operation APIs test/pmdbitops: add PMD 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_pmd_bitops.c | 137 ++++++++++ doc/api/doxy-api-index.md | 5 +- drivers/net/Makefile | 1 + 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 | 253 +++++++++-------- drivers/net/bnx2x/bnx2x.h | 10 +- drivers/net/bnx2x/ecore_sp.h | 48 ++-- 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/common/Makefile | 1 + .../common/include/rte_pmd_bitops.h | 257 ++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 35 files changed, 653 insertions(+), 326 deletions(-) create mode 100644 app/test/test_pmd_bitops.c create mode 100644 lib/librte_eal/common/include/rte_pmd_bitops.h
Signature · 1 line
2.17.1
PATCH v7 1/6 lib/eal: implement the family of PMD 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 +- drivers/net/Makefile | 1 + lib/librte_eal/common/Makefile | 1 + .../common/include/rte_pmd_bitops.h | 257 ++++++++++++++++++ lib/librte_eal/common/meson.build | 3 +- 6 files changed, 268 insertions(+), 3 deletions(-) create mode 100644 lib/librte_eal/common/include/rte_pmd_bitops.h
MAINTAINERS +4 -0
@@ -244,6 +244,10 @@ M: Cristian Dumitrescu <[email protected]> F: lib/librte_eal/common/include/rte_bitmap.h F: app/test/test_bitmap.c +PMD Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_pmd_bitops.h + MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]> F: lib/librte_eal/common/include/generic/rte_mcslock.h
doc/api/doxy-api-index.md +3 -2
@@ -35,6 +35,7 @@ The public API headers are grouped by topics: [vfio] (@ref rte_vfio.h) - **device specific**: + [pmd_bitops] (@ref rte_pmd_bitops.h), [softnic] (@ref rte_eth_softnic.h), [bond] (@ref rte_eth_bond.h), [vhost] (@ref rte_vhost.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):
drivers/net/Makefile +1 -0
@@ -3,6 +3,7 @@ include $(RTE_SDK)/mk/rte.vars.mk +INC := rte_pmd_bitops.h # set in mk/toolchain/xxx/rte.toolchain-compat.mk ifeq ($(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD),d) $(warning thunderx pmd is not supported by old compilers)
lib/librte_eal/common/Makefile +1 -0
@@ -19,6 +19,7 @@ INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h +INC += rte_pmd_bitops.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_memcpy.h rte_cpuflags.h
lib/librte_eal/common/include/rte_pmd_bitops.h new file +257 -0
257 lines not on this page · raw message
lib/librte_eal/common/meson.build +2 -1
@@ -50,9 +50,9 @@ common_objs += eal_common_arch_objs common_headers = files( 'include/rte_alarm.h', + 'include/rte_bitmap.h', 'include/rte_branch_prediction.h', 'include/rte_bus.h', - 'include/rte_bitmap.h', 'include/rte_class.h', 'include/rte_common.h', 'include/rte_compat.h',
@@ -78,6 +78,7 @@ common_headers = files( 'include/rte_pci_dev_feature_defs.h', 'include/rte_pci_dev_features.h', 'include/rte_per_lcore.h', + 'include/rte_pmd_bitops.h', 'include/rte_random.h', 'include/rte_reciprocal.h', 'include/rte_service.h',
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs
Quoted 16 lines · On Mon, 9 Mar 2020 17:54:05 +0800 Joyce Kong <[email protected]> wrote:
/**
+ * @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/common/include/rte_pmd_bitops.h new file +2
-0+__rte_experimental +static inline uint64_t
lib/librte_eal/common/include/rte_pmd_bitops.h line 256
Quoted 10 lines
lib/librte_eal/common/include/rte_pmd_bitops.h new file +10
-0+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); +return val & mask; +} +
This is not thread safe. You should use the existing GCC builtins.
Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs
In reply to Joyce KongHi,
09/03/2020 10:54, Joyce Kong:
Quoted 2 lines
Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication.
Statistics of the series: 653 insertions(+), 326 deletions(-) I would not say it is a huge duplication.
Quoted 2 lines
To reduce duplication,
this patch consolidates them into a common API family.
[...]
MAINTAINERS M: Cristian Dumitrescu <[email protected]> · line 249
Quoted 3 lines
MAINTAINERS +3
-0+PMD Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_pmd_bitops.h
Why is it called PMD bitops and not simply bitops?
Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs
Hi Thomas,
Quoted 15 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, April 1, 2020 6:36 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]>; Phil Yang <[email protected]>; Gavin Hu <[email protected]>; nd <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs
Quoted 8 lines
Hi,
09/03/2020 10:54, Joyce Kong:
Quoted 2 lines
Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication.
Statistics of the series: 653 insertions(+), 326 deletions(-) I would not say it is a huge duplication.
We did not include all PMDs, just a few for piloting and seeking opinions. It is a huge duplication when counting all the PMDs.
Quoted 9 lines
Quoted 3 lines
To reduce duplication,
this patch consolidates them into a common API family.[...]
MAINTAINERS M: Cristian Dumitrescu <[email protected]> · line 249
Quoted 3 lines
MAINTAINERS +3
-0+PMD Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_pmd_bitops.hWhy is it called PMD bitops and not simply bitops?
The scope of these APIs are decreased to PMD use only, for libraries/applications, it is recommended to use C11 directly as there are complications of more ordering models involved.
Quoted 1 line
Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs
01/04/2020 10:27, Gavin Hu:
Quoted 17 lines
Hi Thomas,
From: Thomas Monjalon <[email protected]>
Quoted 9 lines
Hi,
09/03/2020 10:54, Joyce Kong:
Quoted 2 lines
Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication.
Statistics of the series: 653 insertions(+), 326 deletions(-) I would not say it is a huge duplication.
We did not include all PMDs, just a few for piloting and seeking opinions. It is a huge duplication when counting all the PMDs.
Quoted 3 lines
Quoted 3 lines
To reduce duplication,
this patch consolidates them into a common API family.
Quoted 8 lines
Quoted 6 lines
[...]
MAINTAINERS M: Cristian Dumitrescu <[email protected]> · line 249
Quoted 3 lines
MAINTAINERS +3
-0+PMD Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_pmd_bitops.hWhy is it called PMD bitops and not simply bitops?
The scope of these APIs are decreased to PMD use only, for libraries/applications, it is recommended to use C11 directly as there are complications of more ordering models involved.
OK, but PMD means nothing, except this is where it is used *now*. Please describe and name the API with memory ordering words.
Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs
Hi Thomas,
Quoted 40 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, April 1, 2020 5:45 PM
To: Joyce Kong <[email protected]>; Gavin Hu <[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]>; Phil Yang <[email protected]>; nd <[email protected]>; [email protected]; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs01/04/2020 10:27, Gavin Hu:
Quoted 24 lines
Hi Thomas,
From: Thomas Monjalon <[email protected]>
Quoted 9 lines
Hi,
09/03/2020 10:54, Joyce Kong:
Quoted 2 lines
Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication.
Statistics of the series: 653 insertions(+), 326 deletions(-) I would not say it is a huge duplication.
We did not include all PMDs, just a few for piloting and seeking opinions. It is a huge duplication when counting all the PMDs.
Quoted 9 lines
Quoted 3 lines
To reduce duplication,
this patch consolidates them into a common API family.[...]
MAINTAINERS M: Cristian Dumitrescu <[email protected]> · line 249
Quoted 3 lines
MAINTAINERS +3
-0+PMD Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_pmd_bitops.hWhy is it called PMD bitops and not simply bitops?
Quoted 6 lines
Quoted 1 line
The scope of these APIs are decreased to PMD use only, for
libraries/applications, it is recommended to use C11 directly as there are complications of more ordering models involved.
OK, but PMD means nothing, except this is where it is used *now*. Please describe and name the API with memory ordering words.
Will remove 'PMD' in v8.
The APIs were already named with a '_relaxed' suffix, for example 'rte_get_bit64_relaxed'.
According to Honnappa, this patch set just address PMD's requirement, and the current PMDs are not using C11, so only '_relaxed' version is offered.
http://inbox.dpdk.org/dev/VE1PR08MB514983C3200859B27F166EBB983F0@VE1PR08MB5149.eurprd08.prod.outlook.com/
Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs
02/04/2020 09:20, Gavin Hu:
Quoted 46 lines
Hi Thomas,
Quoted 44 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, April 1, 2020 5:45 PM
To: Joyce Kong <[email protected]>; Gavin Hu <[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]>; Phil Yang <[email protected]>; nd <[email protected]>; [email protected]; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs01/04/2020 10:27, Gavin Hu:
Quoted 17 lines
Hi Thomas,
From: Thomas Monjalon <[email protected]>
Quoted 9 lines
Hi,
09/03/2020 10:54, Joyce Kong:
Quoted 2 lines
Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication.
Statistics of the series: 653 insertions(+), 326 deletions(-) I would not say it is a huge duplication.
We did not include all PMDs, just a few for piloting and seeking opinions. It is a huge duplication when counting all the PMDs.
Quoted 3 lines
Quoted 3 lines
To reduce duplication,
this patch consolidates them into a common API family.Quoted 8 lines
Quoted 6 lines
[...]
MAINTAINERS M: Cristian Dumitrescu <[email protected]> · line 249
Quoted 3 lines
MAINTAINERS +3
-0+PMD Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_pmd_bitops.hWhy is it called PMD bitops and not simply bitops?
The scope of these APIs are decreased to PMD use only, for
libraries/applications, it is recommended to use C11 directly as there are complications of more ordering models involved.
Quoted 6 lines
Quoted 2 lines
OK, but PMD means nothing, except this is where it is used *now*. Please describe and name the API with memory ordering words.
Will remove 'PMD' in v8.
The APIs were already named with a '_relaxed' suffix, for example 'rte_get_bit64_relaxed'.
According to Honnappa, this patch set just address PMD's requirement, and the current PMDs are not using C11, so only '_relaxed' version is offered.
http://inbox.dpdk.org/dev/VE1PR08MB514983C3200859B27F166EBB983F0@VE1PR08MB5149.eurprd08.prod.outlook.com/
So why not calling this component "relaxed bitops"?
Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs
Quoted 35 lines · Thomas Monjalon
02/04/2020 09:20, Gavin Hu:
Quoted 33 lines
Hi Thomas,
Quoted 31 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, April 1, 2020 5:45 PM
To: Joyce Kong <[email protected]>; Gavin Hu <[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]>; Phil Yang <[email protected]>; nd <[email protected]>; [email protected]; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs01/04/2020 10:27, Gavin Hu:
Quoted 15 lines
Hi Thomas,
From: Thomas Monjalon <[email protected]>
Quoted 9 lines
Hi,
09/03/2020 10:54, Joyce Kong:
Quoted 2 lines
Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication.
Statistics of the series: 653 insertions(+), 326 deletions(-) I would not say it is a huge duplication.
We did not include all PMDs, just a few for piloting and seeking opinions. It is a huge duplication when counting all the PMDs.
Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
To reduce duplication,
this patch consolidates them into a common API family.[...]
MAINTAINERS M: Cristian Dumitrescu <[email protected]> · line 249
Quoted 3 lines
MAINTAINERS +3
-0+PMD Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_pmd_bitops.h
Change to lib/librte_eal/include/rte_pmd_bitops.h. Check top of tree.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Why is it called PMD bitops and not simply bitops?
The scope of these APIs are decreased to PMD use only, for
libraries/applications, it is recommended to use C11 directly as there are complications of more ordering models involved.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
OK, but PMD means nothing, except this is where it is used *now*. Please describe and name the API with memory ordering words.
Will remove 'PMD' in v8.
The APIs were already named with a '_relaxed' suffix, for example 'rte_get_bit64_relaxed'.
According to Honnappa, this patch set just address PMD's requirement, and the current PMDs are not using C11, so only '_relaxed' version is offered.
http://inbox.dpdk.org/dev/VE1PR08MB514983C3200859B27F166EBB983F0@VE1PR08MB5149.eurprd08.prod.outlook.com/So why not calling this component "relaxed bitops"?
In the future, we can extend to more memory orders as needed. IMO, Just changing to rte_bitops.h is enough.
Quoted 4 lines
Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIs
Quoted 59 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, April 2, 2020 4:12 PM
To: [email protected]
Cc: Joyce Kong <[email protected]>; Gavin Hu <[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]>; Phil Yang <[email protected]>; nd <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family of PMD bit operation APIsQuoted 8 lines · Thomas Monjalon
02/04/2020 09:20, Gavin Hu:
Quoted 6 lines
Hi Thomas,
Quoted 4 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, April 1, 2020 5:45 PM
To: Joyce Kong <[email protected]>; Gavin HuQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected];
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected]; [email protected]; [email protected]; [email protected];
Honnappa
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Nagarahalli <[email protected]>; Phil Yang <[email protected]>; nd <[email protected]>; [email protected]; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v7 1/6] lib/eal: implement the family ofPMD
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
bit operation APIs
01/04/2020 10:27, Gavin Hu:
Quoted 6 lines
Hi Thomas,
From: Thomas Monjalon <[email protected]>
Quoted 3 lines
Hi,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
09/03/2020 10:54, Joyce Kong:
Quoted 2 lines
Bitwise operation APIs are defined and used in a lot of PMDs, which caused a huge code duplication.
Statistics of the series: 653 insertions(+), 326 deletions(-) I would not say it is a huge duplication.
We did not include all PMDs, just a few for piloting and seeking
opinions.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
It is a huge duplication when counting all the PMDs.
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
To reduce duplication,
this patch consolidates them into a common API family.[...]
Review
Quoted 3 lines
(quoted diff) +3
-0+PMD Bitops +M: Joyce Kong <[email protected]> +F: lib/librte_eal/common/include/rte_pmd_bitops.hChange to
lib/librte_eal/include/rte_pmd_bitops.h. Check top of tree.
Yes, will rebase in v8.
Quoted 18 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Why is it called PMD bitops and not simply bitops?
The scope of these APIs are decreased to PMD use only, for
libraries/applications, it is recommended to use C11 directly as there
are
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
complications of more ordering models involved.
OK, but PMD means nothing, except this is where it is used *now*. Please describe and name the API with memory ordering words.
Will remove 'PMD' in v8.
The APIs were already named with a '_relaxed' suffix, for example'
rte_get_bit64_relaxed'.Quoted 1 line
Quoted 1 line
According to Honnappa, this patch set just address PMD's requirement,
and the current PMDs are not using C11, so only '
_relaxed' version is offered.Quoted 1 line
Quoted 1 line
Quoted 7 lines
http://inbox.dpdk.org/dev/VE1PR08MB514983C3200859B27F166EBB983F0
@VE1PR08MB5149.eurprd08.prod.outlook.com/Quoted 2 lines
So why not calling this component "relaxed bitops"?
In the future, we can extend to more memory orders as needed. IMO, Just changing to
rte_bitops.his enough.
Ok, will change to rte_bitops.h to leave room for future extension.
Quoted 5 lines
Quoted 5 lines
PATCH v7 2/6 test/pmdbitops: add PMD bit operation test case
In reply to Joyce KongAdd test cases of bit operations which used by PMDs.
--- MAINTAINERS | 1 + app/test/Makefile | 1 + app/test/autotest_data.py | 6 ++ app/test/meson.build | 2 + app/test/test_pmd_bitops.c | 137 +++++++++++++++++++++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 app/test/test_pmd_bitops.c
MAINTAINERS +1 -0
@@ -247,6 +247,7 @@ F: app/test/test_bitmap.c PMD Bitops M: Joyce Kong <[email protected]> F: lib/librte_eal/common/include/rte_pmd_bitops.h +F: app/test/test_pmd_bitops.c MCSlock - EXPERIMENTAL M: Phil Yang <[email protected]>
app/test/Makefile +1 -0
@@ -78,6 +78,7 @@ SRCS-y += test_rand_perf.c SRCS-y += test_ring.c SRCS-y += test_ring_perf.c +SRCS-y += test_pmd_bitops.c SRCS-y += test_pmd_perf.c ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y)
app/test/autotest_data.py +6 -0
@@ -284,6 +284,12 @@ "Func": default_autotest, "Report": None, }, + { + "Name": "PMD bitops autotest", + "Command": "pmd_bitops_autotest", + "Func": default_autotest, + "Report": None, + } { "Name": "PMD ring autotest", "Command": "ring_pmd_autotest",
app/test/meson.build +2 -0
@@ -84,6 +84,7 @@ test_sources = files('commands.c', 'test_mcslock.c', 'test_mp_secondary.c', 'test_per_lcore.c', + 'test_pmd_bitops.c', 'test_pmd_perf.c', 'test_power.c', 'test_power_cpufreq.c',
@@ -198,6 +199,7 @@ fast_test_names = [ 'meter_autotest', 'multiprocess_autotest', 'per_lcore_autotest', + 'pmd_bitops_autotest', 'prefetch_autotest', 'rcu_qsbr_autotest', 'red_autotest',
app/test/test_pmd_bitops.c new file +137 -0
137 lines not on this page · raw message
Signature · 1 line
2.17.1