Commit f2aefd20 authored by Alexander Lobakin's avatar Alexander Lobakin Committed by David S. Miller

qed: optimize common chain accessors

Constify chain pointers and refactor qed_chain_get_elem_left{,u32}() a bit.
Signed-off-by: default avatarAlexander Lobakin <alobakin@marvell.com>
Signed-off-by: default avatarIgor Russkikh <irusskikh@marvell.com>
Signed-off-by: default avatarMichal Kalderon <michal.kalderon@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 15506586
......@@ -182,73 +182,79 @@ struct qed_chain_init_params {
((p)->cnt_type == QED_CHAIN_CNT_TYPE_U32)
/* Accessors */
static inline u16 qed_chain_get_prod_idx(struct qed_chain *p_chain)
static inline u16 qed_chain_get_prod_idx(const struct qed_chain *chain)
{
return chain->u.chain16.prod_idx;
}
static inline u16 qed_chain_get_cons_idx(const struct qed_chain *chain)
{
return p_chain->u.chain16.prod_idx;
return chain->u.chain16.cons_idx;
}
static inline u16 qed_chain_get_cons_idx(struct qed_chain *p_chain)
static inline u32 qed_chain_get_prod_idx_u32(const struct qed_chain *chain)
{
return p_chain->u.chain16.cons_idx;
return chain->u.chain32.prod_idx;
}
static inline u32 qed_chain_get_cons_idx_u32(struct qed_chain *p_chain)
static inline u32 qed_chain_get_cons_idx_u32(const struct qed_chain *chain)
{
return p_chain->u.chain32.cons_idx;
return chain->u.chain32.cons_idx;
}
static inline u16 qed_chain_get_elem_left(struct qed_chain *p_chain)
static inline u16 qed_chain_get_elem_left(const struct qed_chain *chain)
{
u16 elem_per_page = p_chain->elem_per_page;
u32 prod = p_chain->u.chain16.prod_idx;
u32 cons = p_chain->u.chain16.cons_idx;
u32 prod = qed_chain_get_prod_idx(chain);
u32 cons = qed_chain_get_cons_idx(chain);
u16 elem_per_page = chain->elem_per_page;
u16 used;
if (prod < cons)
prod += (u32)U16_MAX + 1;
used = (u16)(prod - cons);
if (p_chain->mode == QED_CHAIN_MODE_NEXT_PTR)
used -= prod / elem_per_page - cons / elem_per_page;
if (chain->mode == QED_CHAIN_MODE_NEXT_PTR)
used -= (u16)(prod / elem_per_page - cons / elem_per_page);
return (u16)(p_chain->capacity - used);
return (u16)(chain->capacity - used);
}
static inline u32 qed_chain_get_elem_left_u32(struct qed_chain *p_chain)
static inline u32 qed_chain_get_elem_left_u32(const struct qed_chain *chain)
{
u16 elem_per_page = p_chain->elem_per_page;
u64 prod = p_chain->u.chain32.prod_idx;
u64 cons = p_chain->u.chain32.cons_idx;
u64 prod = qed_chain_get_prod_idx_u32(chain);
u64 cons = qed_chain_get_cons_idx_u32(chain);
u16 elem_per_page = chain->elem_per_page;
u32 used;
if (prod < cons)
prod += (u64)U32_MAX + 1;
used = (u32)(prod - cons);
if (p_chain->mode == QED_CHAIN_MODE_NEXT_PTR)
if (chain->mode == QED_CHAIN_MODE_NEXT_PTR)
used -= (u32)(prod / elem_per_page - cons / elem_per_page);
return p_chain->capacity - used;
return chain->capacity - used;
}
static inline u16 qed_chain_get_usable_per_page(struct qed_chain *p_chain)
static inline u16 qed_chain_get_usable_per_page(const struct qed_chain *chain)
{
return p_chain->usable_per_page;
return chain->usable_per_page;
}
static inline u8 qed_chain_get_unusable_per_page(struct qed_chain *p_chain)
static inline u8 qed_chain_get_unusable_per_page(const struct qed_chain *chain)
{
return p_chain->elem_unusable;
return chain->elem_unusable;
}
static inline u32 qed_chain_get_page_cnt(struct qed_chain *p_chain)
static inline u32 qed_chain_get_page_cnt(const struct qed_chain *chain)
{
return p_chain->page_cnt;
return chain->page_cnt;
}
static inline dma_addr_t qed_chain_get_pbl_phys(struct qed_chain *p_chain)
static inline dma_addr_t qed_chain_get_pbl_phys(const struct qed_chain *chain)
{
return p_chain->pbl_sp.table_phys;
return chain->pbl_sp.table_phys;
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment