From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 6A079A0588;
	Thu, 16 Apr 2020 07:39:29 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 5D0711DA78;
	Thu, 16 Apr 2020 07:39:28 +0200 (CEST)
Received: from foss.arm.com (foss.arm.com [217.140.110.172])
 by dpdk.org (Postfix) with ESMTP id 9454D1DA75
 for <dev@dpdk.org>; Thu, 16 Apr 2020 07:39:26 +0200 (CEST)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CE7D81FB;
 Wed, 15 Apr 2020 22:39:25 -0700 (PDT)
Received: from net-arm-thunderx2-03.shanghai.arm.com
 (net-arm-thunderx2-03.shanghai.arm.com [10.169.41.185])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8B6FD3F6C4;
 Wed, 15 Apr 2020 22:43:37 -0700 (PDT)
From: Joyce Kong <joyce.kong@arm.com>
To: thomas@monjalon.net, stephen@networkplumber.org, david.marchand@redhat.com,
 mb@smartsharesystems.com, jerinj@marvell.com, bruce.richardson@intel.com,
 ravi1.kumar@amd.com, rmody@marvell.com, shshaikh@marvell.com,
 xuanziyang2@huawei.com, cloud.wangxiaoyun@huawei.com,
 zhouguoyang@huawei.com, honnappa.nagarahalli@arm.com, gavin.hu@arm.com,
 phil.yang@arm.com
Cc: nd@arm.com,
	dev@dpdk.org
Date: Thu, 16 Apr 2020 13:38:47 +0800
Message-Id: <20200416053853.440-1-joyce.kong@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <1571125801-45773-1-git-send-email-joyce.kong@arm.com>
References: <1571125801-45773-1-git-send-email-joyce.kong@arm.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v8 0/6] implement common bit operation APIs
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

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

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

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

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

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

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

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

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

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

-- 
2.17.1