Commit bcd3df17 authored by Roland Dreier's avatar Roland Dreier Committed by Linus Torvalds

[PATCH] IB/mthca: mem-free address vectors

Update address vector handling to support mem-free mode.  In mem-free
mode, the address vector (in hardware format) is copied by the driver
into each send work queue entry, so our address handle creation can
become pretty trivial: we just kmalloc() a buffer to hold the
formatted address vector.
Signed-off-by: default avatarRoland Dreier <roland@topspin.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f7332bc0
...@@ -60,27 +60,34 @@ int mthca_create_ah(struct mthca_dev *dev, ...@@ -60,27 +60,34 @@ int mthca_create_ah(struct mthca_dev *dev,
u32 index = -1; u32 index = -1;
struct mthca_av *av = NULL; struct mthca_av *av = NULL;
ah->on_hca = 0; ah->type = MTHCA_AH_PCI_POOL;
if (!atomic_read(&pd->sqp_count) && if (dev->hca_type == ARBEL_NATIVE) {
ah->av = kmalloc(sizeof *ah->av, GFP_KERNEL);
if (!ah->av)
return -ENOMEM;
ah->type = MTHCA_AH_KMALLOC;
av = ah->av;
} else if (!atomic_read(&pd->sqp_count) &&
!(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) { !(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) {
index = mthca_alloc(&dev->av_table.alloc); index = mthca_alloc(&dev->av_table.alloc);
/* fall back to allocate in host memory */ /* fall back to allocate in host memory */
if (index == -1) if (index == -1)
goto host_alloc; goto on_hca_fail;
av = kmalloc(sizeof *av, GFP_KERNEL); av = kmalloc(sizeof *av, GFP_KERNEL);
if (!av) if (!av)
goto host_alloc; goto on_hca_fail;
ah->on_hca = 1; ah->type = MTHCA_AH_ON_HCA;
ah->avdma = dev->av_table.ddr_av_base + ah->avdma = dev->av_table.ddr_av_base +
index * MTHCA_AV_SIZE; index * MTHCA_AV_SIZE;
} }
host_alloc: on_hca_fail:
if (!ah->on_hca) { if (ah->type == MTHCA_AH_PCI_POOL) {
ah->av = pci_pool_alloc(dev->av_table.pool, ah->av = pci_pool_alloc(dev->av_table.pool,
SLAB_KERNEL, &ah->avdma); SLAB_KERNEL, &ah->avdma);
if (!ah->av) if (!ah->av)
...@@ -123,7 +130,7 @@ int mthca_create_ah(struct mthca_dev *dev, ...@@ -123,7 +130,7 @@ int mthca_create_ah(struct mthca_dev *dev,
j * 4, be32_to_cpu(((u32 *) av)[j])); j * 4, be32_to_cpu(((u32 *) av)[j]));
} }
if (ah->on_hca) { if (ah->type == MTHCA_AH_ON_HCA) {
memcpy_toio(dev->av_table.av_map + index * MTHCA_AV_SIZE, memcpy_toio(dev->av_table.av_map + index * MTHCA_AV_SIZE,
av, MTHCA_AV_SIZE); av, MTHCA_AV_SIZE);
kfree(av); kfree(av);
...@@ -134,12 +141,21 @@ int mthca_create_ah(struct mthca_dev *dev, ...@@ -134,12 +141,21 @@ int mthca_create_ah(struct mthca_dev *dev,
int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah) int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah)
{ {
if (ah->on_hca) switch (ah->type) {
case MTHCA_AH_ON_HCA:
mthca_free(&dev->av_table.alloc, mthca_free(&dev->av_table.alloc,
(ah->avdma - dev->av_table.ddr_av_base) / (ah->avdma - dev->av_table.ddr_av_base) /
MTHCA_AV_SIZE); MTHCA_AV_SIZE);
else break;
case MTHCA_AH_PCI_POOL:
pci_pool_free(dev->av_table.pool, ah->av, ah->avdma); pci_pool_free(dev->av_table.pool, ah->av, ah->avdma);
break;
case MTHCA_AH_KMALLOC:
kfree(ah->av);
break;
}
return 0; return 0;
} }
...@@ -147,7 +163,7 @@ int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah) ...@@ -147,7 +163,7 @@ int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah)
int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
struct ib_ud_header *header) struct ib_ud_header *header)
{ {
if (ah->on_hca) if (ah->type == MTHCA_AH_ON_HCA)
return -EINVAL; return -EINVAL;
header->lrh.service_level = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28; header->lrh.service_level = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28;
...@@ -176,6 +192,9 @@ int __devinit mthca_init_av_table(struct mthca_dev *dev) ...@@ -176,6 +192,9 @@ int __devinit mthca_init_av_table(struct mthca_dev *dev)
{ {
int err; int err;
if (dev->hca_type == ARBEL_NATIVE)
return 0;
err = mthca_alloc_init(&dev->av_table.alloc, err = mthca_alloc_init(&dev->av_table.alloc,
dev->av_table.num_ddr_avs, dev->av_table.num_ddr_avs,
dev->av_table.num_ddr_avs - 1, dev->av_table.num_ddr_avs - 1,
...@@ -212,6 +231,9 @@ int __devinit mthca_init_av_table(struct mthca_dev *dev) ...@@ -212,6 +231,9 @@ int __devinit mthca_init_av_table(struct mthca_dev *dev)
void __devexit mthca_cleanup_av_table(struct mthca_dev *dev) void __devexit mthca_cleanup_av_table(struct mthca_dev *dev)
{ {
if (dev->hca_type == ARBEL_NATIVE)
return;
if (dev->av_table.av_map) if (dev->av_table.av_map)
iounmap(dev->av_table.av_map); iounmap(dev->av_table.av_map);
pci_pool_destroy(dev->av_table.pool); pci_pool_destroy(dev->av_table.pool);
......
...@@ -82,9 +82,15 @@ struct mthca_eq { ...@@ -82,9 +82,15 @@ struct mthca_eq {
struct mthca_av; struct mthca_av;
enum mthca_ah_type {
MTHCA_AH_ON_HCA,
MTHCA_AH_PCI_POOL,
MTHCA_AH_KMALLOC
};
struct mthca_ah { struct mthca_ah {
struct ib_ah ibah; struct ib_ah ibah;
int on_hca; enum mthca_ah_type type;
u32 key; u32 key;
struct mthca_av *av; struct mthca_av *av;
dma_addr_t avdma; dma_addr_t avdma;
......
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