DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] Small fixes in rte_common.h
       [not found] ` <EDD8E64855FBDA45ACDFE02112E795B70DC84A59B9@HQ1-EXCH03.corp.brocade.com>
@ 2014-12-09 21:05   ` r k
  0 siblings, 0 replies; 4+ messages in thread
From: r k @ 2014-12-09 21:05 UTC (permalink / raw)
  To: dev

Subject: [PATCH] Small fixes in rte_common.h

Fix a bug in power_of_2 since zero is not.
Avoid branching in RTE_MIN and RTE_MAX macros.

Ravi Kerur (1):
  Fix power_of_2 macro.
  Avoid branching when calculating RTE_MIN and RTE_MAX.

 lib/librte_eal/common/include/rte_common.h | 6 +++---
 lib/librte_pmd_e1000/igb_pf.c              | 4 ++--
 lib/librte_pmd_ixgbe/ixgbe_pf.c            | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

--
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH] Fix power_of_2 macro. Avoid branching when calculating RTE_MIN and RTE_MAX.
       [not found]   ` <EDD8E64855FBDA45ACDFE02112E795B70DC84A59B7@HQ1-EXCH03.corp.brocade.com>
@ 2014-12-09 21:05     ` r k
  2014-12-10 12:58       ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: r k @ 2014-12-09 21:05 UTC (permalink / raw)
  To: dev

Subject: [PATCH] Fix power_of_2 macro. Avoid branching when
calculating RTE_MIN and RTE_MAX.

---
 lib/librte_eal/common/include/rte_common.h | 6 +++---
 lib/librte_pmd_e1000/igb_pf.c              | 4 ++--
 lib/librte_pmd_ixgbe/ixgbe_pf.c            | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_common.h
b/lib/librte_eal/common/include/rte_common.h
index 921b91f..21b17ad 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -203,7 +203,7 @@ extern int RTE_BUILD_BUG_ON_detected_error;
static inline int  rte_is_power_of_2(uint32_t n)  {
-       return ((n-1) & n) == 0;
+       return n && !(n & (n - 1));
 }

 /**
@@ -259,7 +259,7 @@ rte_align64pow2(uint64_t v)  #define RTE_MIN(a, b) ({ \
                typeof (a) _a = (a); \
                typeof (b) _b = (b); \
-               _a < _b ? _a : _b; \
+                _b ^ ((_a ^ _b) & -(_a < _b)); \
        })

 /**
@@ -268,7 +268,7 @@ rte_align64pow2(uint64_t v)  #define RTE_MAX(a, b) ({ \
                typeof (a) _a = (a); \
                typeof (b) _b = (b); \
-               _a > _b ? _a : _b; \
+                _a ^ ((_a ^ _b) & -(_a < _b)); \
        })

 /*********** Other general functions / macros ********/ diff --git
a/lib/librte_pmd_e1000/igb_pf.c b/lib/librte_pmd_e1000/igb_pf.c index
bc3816a..546499c 100644
--- a/lib/librte_pmd_e1000/igb_pf.c
+++ b/lib/librte_pmd_e1000/igb_pf.c
@@ -321,11 +321,11 @@ igb_vf_set_mac_addr(struct rte_eth_dev *dev,
uint32_t vf, uint32_t *msgbuf)  static int
igb_vf_set_multicast(struct rte_eth_dev *dev, __rte_unused uint32_t
vf, uint32_t *msgbuf)  {
-       int i;
+       int16_t i;
        uint32_t vector_bit;
        uint32_t vector_reg;
        uint32_t mta_reg;
-       int entries = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >>
+       int32_t entries = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >>
                E1000_VT_MSGINFO_SHIFT;
        uint16_t *hash_list = (uint16_t *)&msgbuf[1];
        struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/lib/librte_pmd_ixgbe/ixgbe_pf.c
b/lib/librte_pmd_ixgbe/ixgbe_pf.c index 51da1fd..426caf9 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_pf.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_pf.c
@@ -390,7 +390,7 @@ ixgbe_vf_set_multicast(struct rte_eth_dev *dev,
__rte_unused uint32_t vf, uint32
        struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct ixgbe_vf_info *vfinfo =
                *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
-       int nb_entries = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >>
+       int32_t nb_entries = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >>
                IXGBE_VT_MSGINFO_SHIFT;
        uint16_t *hash_list = (uint16_t *)&msgbuf[1];
        uint32_t mta_idx;
@@ -399,7 +399,7 @@ ixgbe_vf_set_multicast(struct rte_eth_dev *dev,
__rte_unused uint32_t vf, uint32
        const uint32_t IXGBE_MTA_BIT_SHIFT = 5;
        const uint32_t IXGBE_MTA_BIT_MASK = (0x1 << IXGBE_MTA_BIT_SHIFT) - 1;
        uint32_t reg_val;
-       int i;
+       int16_t i;

        /* only so many hash values supported */
        nb_entries = RTE_MIN(nb_entries, IXGBE_MAX_VF_MC_ENTRIES);
--
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] Fix power_of_2 macro. Avoid branching when calculating RTE_MIN and RTE_MAX.
  2014-12-09 21:05     ` [dpdk-dev] [PATCH] Fix power_of_2 macro. Avoid branching when calculating RTE_MIN and RTE_MAX r k
@ 2014-12-10 12:58       ` Thomas Monjalon
  2014-12-10 16:48         ` r k
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2014-12-10 12:58 UTC (permalink / raw)
  To: r k; +Cc: dev

2014-12-09 13:05, r k:
> Subject: [PATCH] Fix power_of_2 macro. Avoid branching when
> calculating RTE_MIN and RTE_MAX.

Please could you add more explanations about the problem you are solving?

You should also add a Signed-off like explained in this page:
	http://dpdk.org/dev#send

Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] Fix power_of_2 macro. Avoid branching when calculating RTE_MIN and RTE_MAX.
  2014-12-10 12:58       ` Thomas Monjalon
@ 2014-12-10 16:48         ` r k
  0 siblings, 0 replies; 4+ messages in thread
From: r k @ 2014-12-10 16:48 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

Just sent another patch explaining the fix and signed-off.

Thanks,
Ravi

On Wed, Dec 10, 2014 at 4:58 AM, Thomas Monjalon
<thomas.monjalon@6wind.com> wrote:
> 2014-12-09 13:05, r k:
>> Subject: [PATCH] Fix power_of_2 macro. Avoid branching when
>> calculating RTE_MIN and RTE_MAX.
>
> Please could you add more explanations about the problem you are solving?
>
> You should also add a Signed-off like explained in this page:
>         http://dpdk.org/dev#send
>
> Thanks
> --
> Thomas

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-10 16:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1418157854-7642-1-git-send-email-rkerur@gmail.com>
     [not found] ` <EDD8E64855FBDA45ACDFE02112E795B70DC84A59B9@HQ1-EXCH03.corp.brocade.com>
2014-12-09 21:05   ` [dpdk-dev] [PATCH] Small fixes in rte_common.h r k
     [not found] ` <1418157854-7642-2-git-send-email-rkerur@gmail.com>
     [not found]   ` <EDD8E64855FBDA45ACDFE02112E795B70DC84A59B7@HQ1-EXCH03.corp.brocade.com>
2014-12-09 21:05     ` [dpdk-dev] [PATCH] Fix power_of_2 macro. Avoid branching when calculating RTE_MIN and RTE_MAX r k
2014-12-10 12:58       ` Thomas Monjalon
2014-12-10 16:48         ` r k

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git