[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200722221045.5436-12-alobakin@marvell.com>
Date: Thu, 23 Jul 2020 01:10:41 +0300
From: Alexander Lobakin <alobakin@...vell.com>
To: "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>
CC: Alexander Lobakin <alobakin@...vell.com>,
Igor Russkikh <irusskikh@...vell.com>,
Michal Kalderon <michal.kalderon@...vell.com>,
"Ariel Elior" <aelior@...vell.com>,
Denis Bolotin <denis.bolotin@...vell.com>,
"Doug Ledford" <dledford@...hat.com>,
Jason Gunthorpe <jgg@...pe.ca>,
"Alexei Starovoitov" <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
"Jesper Dangaard Brouer" <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, "Yonghong Song" <yhs@...com>,
Andrii Nakryiko <andriin@...com>,
KP Singh <kpsingh@...omium.org>,
<GR-everest-linux-l2@...vell.com>, <netdev@...r.kernel.org>,
<bpf@...r.kernel.org>, <linux-rdma@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH v2 net-next 11/15] qed: introduce qed_chain_get_elem_used{,u32}()
Add reverse-variants of qed_chain_get_elem_left{,u32}() to be able to
know current chain occupation. They will be used in the upcoming qede
XDP_REDIRECT code.
They share most of the logics with the mentioned ones, so were reused
to collapse the latters.
Signed-off-by: Alexander Lobakin <alobakin@...vell.com>
Signed-off-by: Igor Russkikh <irusskikh@...vell.com>
Signed-off-by: Michal Kalderon <michal.kalderon@...vell.com>
---
include/linux/qed/qed_chain.h | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/include/linux/qed/qed_chain.h b/include/linux/qed/qed_chain.h
index 434479e2ab65..4d58dc8943f0 100644
--- a/include/linux/qed/qed_chain.h
+++ b/include/linux/qed/qed_chain.h
@@ -203,7 +203,7 @@ static inline u32 qed_chain_get_cons_idx_u32(const struct qed_chain *chain)
return chain->u.chain32.cons_idx;
}
-static inline u16 qed_chain_get_elem_left(const struct qed_chain *chain)
+static inline u16 qed_chain_get_elem_used(const struct qed_chain *chain)
{
u32 prod = qed_chain_get_prod_idx(chain);
u32 cons = qed_chain_get_cons_idx(chain);
@@ -217,10 +217,15 @@ static inline u16 qed_chain_get_elem_left(const struct qed_chain *chain)
if (chain->mode == QED_CHAIN_MODE_NEXT_PTR)
used -= (u16)(prod / elem_per_page - cons / elem_per_page);
- return (u16)(chain->capacity - used);
+ return used;
}
-static inline u32 qed_chain_get_elem_left_u32(const struct qed_chain *chain)
+static inline u16 qed_chain_get_elem_left(const struct qed_chain *chain)
+{
+ return (u16)(chain->capacity - qed_chain_get_elem_used(chain));
+}
+
+static inline u32 qed_chain_get_elem_used_u32(const struct qed_chain *chain)
{
u64 prod = qed_chain_get_prod_idx_u32(chain);
u64 cons = qed_chain_get_cons_idx_u32(chain);
@@ -234,7 +239,12 @@ static inline u32 qed_chain_get_elem_left_u32(const struct qed_chain *chain)
if (chain->mode == QED_CHAIN_MODE_NEXT_PTR)
used -= (u32)(prod / elem_per_page - cons / elem_per_page);
- return chain->capacity - used;
+ return used;
+}
+
+static inline u32 qed_chain_get_elem_left_u32(const struct qed_chain *chain)
+{
+ return chain->capacity - qed_chain_get_elem_used_u32(chain);
}
static inline u16 qed_chain_get_usable_per_page(const struct qed_chain *chain)
--
2.25.1
Powered by blists - more mailing lists