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

qed: reformat "qed_chain.h" a bit

Reformat structs and macros definitions a bit prior to making functional
changes.
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 f1fa27f5
...@@ -26,9 +26,9 @@ enum qed_chain_mode { ...@@ -26,9 +26,9 @@ enum qed_chain_mode {
}; };
enum qed_chain_use_mode { enum qed_chain_use_mode {
QED_CHAIN_USE_TO_PRODUCE, /* Chain starts empty */ QED_CHAIN_USE_TO_PRODUCE, /* Chain starts empty */
QED_CHAIN_USE_TO_CONSUME, /* Chain starts full */ QED_CHAIN_USE_TO_CONSUME, /* Chain starts full */
QED_CHAIN_USE_TO_CONSUME_PRODUCE, /* Chain starts empty */ QED_CHAIN_USE_TO_CONSUME_PRODUCE, /* Chain starts empty */
}; };
enum qed_chain_cnt_type { enum qed_chain_cnt_type {
...@@ -40,84 +40,86 @@ enum qed_chain_cnt_type { ...@@ -40,84 +40,86 @@ enum qed_chain_cnt_type {
}; };
struct qed_chain_next { struct qed_chain_next {
struct regpair next_phys; struct regpair next_phys;
void *next_virt; void *next_virt;
}; };
struct qed_chain_pbl_u16 { struct qed_chain_pbl_u16 {
u16 prod_page_idx; u16 prod_page_idx;
u16 cons_page_idx; u16 cons_page_idx;
}; };
struct qed_chain_pbl_u32 { struct qed_chain_pbl_u32 {
u32 prod_page_idx; u32 prod_page_idx;
u32 cons_page_idx; u32 cons_page_idx;
}; };
struct qed_chain_ext_pbl { struct qed_chain_ext_pbl {
dma_addr_t p_pbl_phys; dma_addr_t p_pbl_phys;
void *p_pbl_virt; void *p_pbl_virt;
}; };
struct qed_chain_u16 { struct qed_chain_u16 {
/* Cyclic index of next element to produce/consme */ /* Cyclic index of next element to produce/consme */
u16 prod_idx; u16 prod_idx;
u16 cons_idx; u16 cons_idx;
}; };
struct qed_chain_u32 { struct qed_chain_u32 {
/* Cyclic index of next element to produce/consme */ /* Cyclic index of next element to produce/consme */
u32 prod_idx; u32 prod_idx;
u32 cons_idx; u32 cons_idx;
}; };
struct addr_tbl_entry { struct addr_tbl_entry {
void *virt_addr; void *virt_addr;
dma_addr_t dma_map; dma_addr_t dma_map;
}; };
struct qed_chain { struct qed_chain {
/* fastpath portion of the chain - required for commands such /* Fastpath portion of the chain - required for commands such
* as produce / consume. * as produce / consume.
*/ */
/* Point to next element to produce/consume */ /* Point to next element to produce/consume */
void *p_prod_elem; void *p_prod_elem;
void *p_cons_elem; void *p_cons_elem;
/* Fastpath portions of the PBL [if exists] */ /* Fastpath portions of the PBL [if exists] */
struct { struct {
/* Table for keeping the virtual and physical addresses of the /* Table for keeping the virtual and physical addresses of the
* chain pages, respectively to the physical addresses * chain pages, respectively to the physical addresses
* in the pbl table. * in the pbl table.
*/ */
struct addr_tbl_entry *pp_addr_tbl; struct addr_tbl_entry *pp_addr_tbl;
union { union {
struct qed_chain_pbl_u16 u16; struct qed_chain_pbl_u16 u16;
struct qed_chain_pbl_u32 u32; struct qed_chain_pbl_u32 u32;
} c; } c;
} pbl; } pbl;
union { union {
struct qed_chain_u16 chain16; struct qed_chain_u16 chain16;
struct qed_chain_u32 chain32; struct qed_chain_u32 chain32;
} u; } u;
/* Capacity counts only usable elements */ /* Capacity counts only usable elements */
u32 capacity; u32 capacity;
u32 page_cnt; u32 page_cnt;
enum qed_chain_mode mode; enum qed_chain_mode mode;
/* Elements information for fast calculations */ /* Elements information for fast calculations */
u16 elem_per_page; u16 elem_per_page;
u16 elem_per_page_mask; u16 elem_per_page_mask;
u16 elem_size; u16 elem_size;
u16 next_page_mask; u16 next_page_mask;
u16 usable_per_page; u16 usable_per_page;
u8 elem_unusable; u8 elem_unusable;
u8 cnt_type; u8 cnt_type;
/* Slowpath of the chain - required for initialization and destruction, /* Slowpath of the chain - required for initialization and destruction,
* but isn't involved in regular functionality. * but isn't involved in regular functionality.
...@@ -125,43 +127,47 @@ struct qed_chain { ...@@ -125,43 +127,47 @@ struct qed_chain {
/* Base address of a pre-allocated buffer for pbl */ /* Base address of a pre-allocated buffer for pbl */
struct { struct {
dma_addr_t p_phys_table; dma_addr_t p_phys_table;
void *p_virt_table; void *p_virt_table;
} pbl_sp; } pbl_sp;
/* Address of first page of the chain - the address is required /* Address of first page of the chain - the address is required
* for fastpath operation [consume/produce] but only for the SINGLE * for fastpath operation [consume/produce] but only for the SINGLE
* flavour which isn't considered fastpath [== SPQ]. * flavour which isn't considered fastpath [== SPQ].
*/ */
void *p_virt_addr; void *p_virt_addr;
dma_addr_t p_phys_addr; dma_addr_t p_phys_addr;
/* Total number of elements [for entire chain] */ /* Total number of elements [for entire chain] */
u32 size; u32 size;
u8 intended_use; u8 intended_use;
bool b_external_pbl; bool b_external_pbl;
}; };
#define QED_CHAIN_PBL_ENTRY_SIZE (8) #define QED_CHAIN_PBL_ENTRY_SIZE 8
#define QED_CHAIN_PAGE_SIZE (0x1000) #define QED_CHAIN_PAGE_SIZE 0x1000
#define ELEMS_PER_PAGE(elem_size) (QED_CHAIN_PAGE_SIZE / (elem_size))
#define ELEMS_PER_PAGE(elem_size) \
(QED_CHAIN_PAGE_SIZE / (elem_size))
#define UNUSABLE_ELEMS_PER_PAGE(elem_size, mode) \ #define UNUSABLE_ELEMS_PER_PAGE(elem_size, mode) \
(((mode) == QED_CHAIN_MODE_NEXT_PTR) ? \ (((mode) == QED_CHAIN_MODE_NEXT_PTR) ? \
(u8)(1 + ((sizeof(struct qed_chain_next) - 1) / \ (u8)(1 + ((sizeof(struct qed_chain_next) - 1) / (elem_size))) : \
(elem_size))) : 0) 0)
#define USABLE_ELEMS_PER_PAGE(elem_size, mode) \ #define USABLE_ELEMS_PER_PAGE(elem_size, mode) \
((u32)(ELEMS_PER_PAGE(elem_size) - \ ((u32)(ELEMS_PER_PAGE(elem_size) - \
UNUSABLE_ELEMS_PER_PAGE(elem_size, mode))) UNUSABLE_ELEMS_PER_PAGE((elem_size), (mode))))
#define QED_CHAIN_PAGE_CNT(elem_cnt, elem_size, mode) \ #define QED_CHAIN_PAGE_CNT(elem_cnt, elem_size, mode) \
DIV_ROUND_UP(elem_cnt, USABLE_ELEMS_PER_PAGE(elem_size, mode)) DIV_ROUND_UP((elem_cnt), USABLE_ELEMS_PER_PAGE((elem_size), (mode)))
#define is_chain_u16(p) ((p)->cnt_type == QED_CHAIN_CNT_TYPE_U16) #define is_chain_u16(p) \
#define is_chain_u32(p) ((p)->cnt_type == QED_CHAIN_CNT_TYPE_U32) ((p)->cnt_type == QED_CHAIN_CNT_TYPE_U16)
#define is_chain_u32(p) \
((p)->cnt_type == QED_CHAIN_CNT_TYPE_U32)
/* Accessors */ /* Accessors */
static inline u16 qed_chain_get_prod_idx(struct qed_chain *p_chain) static inline u16 qed_chain_get_prod_idx(struct qed_chain *p_chain)
......
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