mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
ionic: add tx/rx-push support with device Component Memory Buffers
The ionic device has on-board memory (CMB) that can be used for descriptors as a way to speed descriptor access for faster packet processing. It is rumored to improve latency and/or packets-per-second for some profiles of small packet traffic, although your mileage may vary. Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
5b4e9a7a71
commit
40bc471dc7
@@ -92,6 +92,7 @@ int ionic_dev_setup(struct ionic *ionic)
|
||||
unsigned int num_bars = ionic->num_bars;
|
||||
struct ionic_dev *idev = &ionic->idev;
|
||||
struct device *dev = ionic->dev;
|
||||
int size;
|
||||
u32 sig;
|
||||
|
||||
/* BAR0: dev_cmd and interrupts */
|
||||
@@ -133,9 +134,36 @@ int ionic_dev_setup(struct ionic *ionic)
|
||||
idev->db_pages = bar->vaddr;
|
||||
idev->phy_db_pages = bar->bus_addr;
|
||||
|
||||
/* BAR2: optional controller memory mapping */
|
||||
bar++;
|
||||
mutex_init(&idev->cmb_inuse_lock);
|
||||
if (num_bars < 3 || !ionic->bars[IONIC_PCI_BAR_CMB].len) {
|
||||
idev->cmb_inuse = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
idev->phy_cmb_pages = bar->bus_addr;
|
||||
idev->cmb_npages = bar->len / PAGE_SIZE;
|
||||
size = BITS_TO_LONGS(idev->cmb_npages) * sizeof(long);
|
||||
idev->cmb_inuse = kzalloc(size, GFP_KERNEL);
|
||||
if (!idev->cmb_inuse)
|
||||
dev_warn(dev, "No memory for CMB, disabling\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ionic_dev_teardown(struct ionic *ionic)
|
||||
{
|
||||
struct ionic_dev *idev = &ionic->idev;
|
||||
|
||||
kfree(idev->cmb_inuse);
|
||||
idev->cmb_inuse = NULL;
|
||||
idev->phy_cmb_pages = 0;
|
||||
idev->cmb_npages = 0;
|
||||
|
||||
mutex_destroy(&idev->cmb_inuse_lock);
|
||||
}
|
||||
|
||||
/* Devcmd Interface */
|
||||
bool ionic_is_fw_running(struct ionic_dev *idev)
|
||||
{
|
||||
@@ -571,6 +599,33 @@ int ionic_db_page_num(struct ionic_lif *lif, int pid)
|
||||
return (lif->hw_index * lif->dbid_count) + pid;
|
||||
}
|
||||
|
||||
int ionic_get_cmb(struct ionic_lif *lif, u32 *pgid, phys_addr_t *pgaddr, int order)
|
||||
{
|
||||
struct ionic_dev *idev = &lif->ionic->idev;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&idev->cmb_inuse_lock);
|
||||
ret = bitmap_find_free_region(idev->cmb_inuse, idev->cmb_npages, order);
|
||||
mutex_unlock(&idev->cmb_inuse_lock);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
*pgid = ret;
|
||||
*pgaddr = idev->phy_cmb_pages + ret * PAGE_SIZE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ionic_put_cmb(struct ionic_lif *lif, u32 pgid, int order)
|
||||
{
|
||||
struct ionic_dev *idev = &lif->ionic->idev;
|
||||
|
||||
mutex_lock(&idev->cmb_inuse_lock);
|
||||
bitmap_release_region(idev->cmb_inuse, pgid, order);
|
||||
mutex_unlock(&idev->cmb_inuse_lock);
|
||||
}
|
||||
|
||||
int ionic_cq_init(struct ionic_lif *lif, struct ionic_cq *cq,
|
||||
struct ionic_intr_info *intr,
|
||||
unsigned int num_descs, size_t desc_size)
|
||||
@@ -679,6 +734,18 @@ void ionic_q_map(struct ionic_queue *q, void *base, dma_addr_t base_pa)
|
||||
cur->desc = base + (i * q->desc_size);
|
||||
}
|
||||
|
||||
void ionic_q_cmb_map(struct ionic_queue *q, void __iomem *base, dma_addr_t base_pa)
|
||||
{
|
||||
struct ionic_desc_info *cur;
|
||||
unsigned int i;
|
||||
|
||||
q->cmb_base = base;
|
||||
q->cmb_base_pa = base_pa;
|
||||
|
||||
for (i = 0, cur = q->info; i < q->num_descs; i++, cur++)
|
||||
cur->cmb_desc = base + (i * q->desc_size);
|
||||
}
|
||||
|
||||
void ionic_q_sg_map(struct ionic_queue *q, void *base, dma_addr_t base_pa)
|
||||
{
|
||||
struct ionic_desc_info *cur;
|
||||
|
||||
Reference in New Issue
Block a user