Commit 95a212bb authored by Giovanni Cabiddu's avatar Giovanni Cabiddu Committed by Herbert Xu

crypto: qat - abstract build ring base

Abstract the implementation of BUILD_RING_BASE_ADDR.

This is in preparation for the introduction of the qat_4xxx driver since
the value of the ring base differs between QAT GEN2 and QAT GEN4
devices.
Signed-off-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: default avatarWojciech Ziemba <wojciech.ziemba@intel.com>
Reviewed-by: default avatarMaksim Lukoshkov <maksim.lukoshkov@intel.com>
Reviewed-by: default avatarFiona Trahe <fiona.trahe@intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 070a34c9
...@@ -110,6 +110,7 @@ struct admin_info { ...@@ -110,6 +110,7 @@ struct admin_info {
}; };
struct adf_hw_csr_ops { struct adf_hw_csr_ops {
u64 (*build_csr_ring_base_addr)(dma_addr_t addr, u32 size);
u32 (*read_csr_ring_head)(void __iomem *csr_base_addr, u32 bank, u32 (*read_csr_ring_head)(void __iomem *csr_base_addr, u32 bank,
u32 ring); u32 ring);
void (*write_csr_ring_head)(void __iomem *csr_base_addr, u32 bank, void (*write_csr_ring_head)(void __iomem *csr_base_addr, u32 bank,
......
...@@ -55,6 +55,11 @@ void adf_gen2_get_arb_info(struct arb_info *arb_info) ...@@ -55,6 +55,11 @@ void adf_gen2_get_arb_info(struct arb_info *arb_info)
} }
EXPORT_SYMBOL_GPL(adf_gen2_get_arb_info); EXPORT_SYMBOL_GPL(adf_gen2_get_arb_info);
static u64 build_csr_ring_base_addr(dma_addr_t addr, u32 size)
{
return BUILD_RING_BASE_ADDR(addr, size);
}
static u32 read_csr_ring_head(void __iomem *csr_base_addr, u32 bank, u32 ring) static u32 read_csr_ring_head(void __iomem *csr_base_addr, u32 bank, u32 ring)
{ {
return READ_CSR_RING_HEAD(csr_base_addr, bank, ring); return READ_CSR_RING_HEAD(csr_base_addr, bank, ring);
...@@ -124,6 +129,7 @@ static void write_csr_int_flag_and_col(void __iomem *csr_base_addr, u32 bank, ...@@ -124,6 +129,7 @@ static void write_csr_int_flag_and_col(void __iomem *csr_base_addr, u32 bank,
void adf_gen2_init_hw_csr_ops(struct adf_hw_csr_ops *csr_ops) void adf_gen2_init_hw_csr_ops(struct adf_hw_csr_ops *csr_ops)
{ {
csr_ops->build_csr_ring_base_addr = build_csr_ring_base_addr;
csr_ops->read_csr_ring_head = read_csr_ring_head; csr_ops->read_csr_ring_head = read_csr_ring_head;
csr_ops->write_csr_ring_head = write_csr_ring_head; csr_ops->write_csr_ring_head = write_csr_ring_head;
csr_ops->read_csr_ring_tail = read_csr_ring_tail; csr_ops->read_csr_ring_tail = read_csr_ring_tail;
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#define ADF_RING_CSR_INT_COL_CTL_ENABLE 0x80000000 #define ADF_RING_CSR_INT_COL_CTL_ENABLE 0x80000000
#define ADF_RING_BUNDLE_SIZE 0x1000 #define ADF_RING_BUNDLE_SIZE 0x1000
#define BUILD_RING_BASE_ADDR(addr, size) \
(((addr) >> 6) & (0xFFFFFFFFFFFFFFFFULL << (size)))
#define READ_CSR_RING_HEAD(csr_base_addr, bank, ring) \ #define READ_CSR_RING_HEAD(csr_base_addr, bank, ring) \
ADF_CSR_RD(csr_base_addr, (ADF_RING_BUNDLE_SIZE * (bank)) + \ ADF_CSR_RD(csr_base_addr, (ADF_RING_BUNDLE_SIZE * (bank)) + \
ADF_RING_CSR_RING_HEAD + ((ring) << 2)) ADF_RING_CSR_RING_HEAD + ((ring) << 2))
......
...@@ -180,7 +180,9 @@ static int adf_init_ring(struct adf_etr_ring_data *ring) ...@@ -180,7 +180,9 @@ static int adf_init_ring(struct adf_etr_ring_data *ring)
else else
adf_configure_rx_ring(ring); adf_configure_rx_ring(ring);
ring_base = BUILD_RING_BASE_ADDR(ring->dma_addr, ring->ring_size); ring_base = csr_ops->build_csr_ring_base_addr(ring->dma_addr,
ring->ring_size);
csr_ops->write_csr_ring_base(ring->bank->csr_addr, csr_ops->write_csr_ring_base(ring->bank->csr_addr,
ring->bank->bank_number, ring->ring_number, ring->bank->bank_number, ring->ring_number,
ring_base); ring_base);
......
...@@ -56,6 +56,4 @@ ...@@ -56,6 +56,4 @@
((watermark_nf << ADF_RING_CONFIG_NEAR_FULL_WM) \ ((watermark_nf << ADF_RING_CONFIG_NEAR_FULL_WM) \
| (watermark_ne << ADF_RING_CONFIG_NEAR_EMPTY_WM) \ | (watermark_ne << ADF_RING_CONFIG_NEAR_EMPTY_WM) \
| size) | size)
#define BUILD_RING_BASE_ADDR(addr, size) \
((addr >> 6) & (0xFFFFFFFFFFFFFFFFULL << size))
#endif #endif
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