Skip to content
Permalink
Browse files

net/sfc: unify power of 2 alignment check macro

[ upstream commit 0270853d94e298820f3361b43dfdbf95e6a05c88 ]

Substitute driver-defined IS_P2ALIGNED() with EFX_IS_P2ALIGNED()
defined in libefx.

Add type argument and cast value and alignment to one specified type.

Fixes: e1b9445 ("net/sfc: build libefx")

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
  • Loading branch information...
arybchenko authored and kevintraynor committed Jul 24, 2019
1 parent af2ccf0 commit fc3912e3ff0a47ae476fa41067724f804283aa0c
Showing with 30 additions and 21 deletions.
  1. +2 −2 drivers/net/sfc/base/ef10_rx.c
  2. +4 −0 drivers/net/sfc/base/efx.h
  3. +24 −19 drivers/net/sfc/efsys.h
@@ -1096,12 +1096,12 @@ ef10_rx_qcreate(
rc = ENOTSUP;
goto fail7;
}
if (!IS_P2ALIGNED(es_max_dma_len,
if (!EFX_IS_P2ALIGNED(uint32_t, es_max_dma_len,
EFX_RX_ES_SUPER_BUFFER_BUF_ALIGNMENT)) {
rc = EINVAL;
goto fail8;
}
if (!IS_P2ALIGNED(es_buf_stride,
if (!EFX_IS_P2ALIGNED(uint32_t, es_buf_stride,
EFX_RX_ES_SUPER_BUFFER_BUF_ALIGNMENT)) {
rc = EINVAL;
goto fail9;
@@ -36,6 +36,10 @@ extern "C" {
#define EFX_P2ALIGN(_type, _value, _align) \
((_type)(_value) & -(_type)(_align))

/* Test if value is power of 2 aligned. */
#define EFX_IS_P2ALIGNED(_type, _value, _align) \
((((_type)(_value)) & ((_type)(_align) - 1)) == 0)

/* Return codes */

typedef __success(return == 0) int efx_rc_t;
@@ -69,13 +69,6 @@ typedef bool boolean_t;
#define MIN(v1, v2) ((v1) < (v2) ? (v1) : (v2))
#endif

/* There are macros for alignment in DPDK, but we need to make a proper
* correspondence here, if we want to re-use them at all
*/
#ifndef IS_P2ALIGNED
#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0)
#endif

#ifndef ISP2
#define ISP2(x) rte_is_power_of_2(x)
#endif
@@ -227,7 +220,8 @@ typedef struct efsys_mem_s {
volatile uint32_t *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_dword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_dword_t))); \
\
_addr = (volatile uint32_t *)(_base + (_offset)); \
(_edp)->ed_u32[0] = _addr[0]; \
@@ -244,7 +238,8 @@ typedef struct efsys_mem_s {
volatile uint64_t *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_qword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_qword_t))); \
\
_addr = (volatile uint64_t *)(_base + (_offset)); \
(_eqp)->eq_u64[0] = _addr[0]; \
@@ -262,7 +257,8 @@ typedef struct efsys_mem_s {
volatile __m128i *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_oword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_oword_t))); \
\
_addr = (volatile __m128i *)(_base + (_offset)); \
(_eop)->eo_u128[0] = _addr[0]; \
@@ -283,7 +279,8 @@ typedef struct efsys_mem_s {
volatile uint32_t *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_dword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_dword_t))); \
\
EFSYS_PROBE2(mem_writed, unsigned int, (_offset), \
uint32_t, (_edp)->ed_u32[0]); \
@@ -300,7 +297,8 @@ typedef struct efsys_mem_s {
volatile uint64_t *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_qword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_qword_t))); \
\
EFSYS_PROBE3(mem_writeq, unsigned int, (_offset), \
uint32_t, (_eqp)->eq_u32[1], \
@@ -318,7 +316,8 @@ typedef struct efsys_mem_s {
volatile __m128i *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_oword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_oword_t))); \
\
\
EFSYS_PROBE5(mem_writeo, unsigned int, (_offset), \
@@ -383,7 +382,8 @@ typedef struct efsys_bar_s {
volatile uint32_t *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_dword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_dword_t))); \
_NOTE(CONSTANTCONDITION); \
if (_lock) \
SFC_BAR_LOCK(_esbp); \
@@ -407,7 +407,8 @@ typedef struct efsys_bar_s {
volatile uint64_t *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_qword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_qword_t))); \
\
SFC_BAR_LOCK(_esbp); \
\
@@ -429,7 +430,8 @@ typedef struct efsys_bar_s {
volatile __m128i *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_oword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_oword_t))); \
\
_NOTE(CONSTANTCONDITION); \
if (_lock) \
@@ -459,7 +461,8 @@ typedef struct efsys_bar_s {
volatile uint32_t *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_dword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_dword_t))); \
\
_NOTE(CONSTANTCONDITION); \
if (_lock) \
@@ -484,7 +487,8 @@ typedef struct efsys_bar_s {
volatile uint64_t *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_qword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_qword_t))); \
\
SFC_BAR_LOCK(_esbp); \
\
@@ -518,7 +522,8 @@ typedef struct efsys_bar_s {
volatile __m128i *_addr; \
\
_NOTE(CONSTANTCONDITION); \
SFC_ASSERT(IS_P2ALIGNED(_offset, sizeof(efx_oword_t))); \
SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \
sizeof(efx_oword_t))); \
\
_NOTE(CONSTANTCONDITION); \
if (_lock) \

0 comments on commit fc3912e

Please sign in to comment.
You can’t perform that action at this time.