Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/cxgbe/iw_cxgbe/provider.c
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
static int c4iw_modify_port(struct ib_device *ibdev, | static int c4iw_modify_port(struct ib_device *ibdev, | ||||
u8 port, int port_modify_mask, | u8 port, int port_modify_mask, | ||||
struct ib_port_modify *props) | struct ib_port_modify *props) | ||||
{ | { | ||||
return -ENOSYS; | return -ENOSYS; | ||||
} | } | ||||
static struct ib_ah *c4iw_ah_create(struct ib_pd *pd, | static int c4iw_ah_create(struct ib_ah *ah, | ||||
struct ib_ah_attr *ah_attr, | struct ib_ah_attr *ah_attr, u32 flags, | ||||
struct ib_udata *udata) | struct ib_udata *udata) | ||||
{ | { | ||||
return ERR_PTR(-ENOSYS); | return -ENOSYS; | ||||
} | } | ||||
static int c4iw_ah_destroy(struct ib_ah *ah) | static void c4iw_ah_destroy(struct ib_ah *ah, u32 flags) | ||||
{ | { | ||||
return -ENOSYS; | |||||
} | } | ||||
static int c4iw_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) | static int c4iw_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) | ||||
{ | { | ||||
return -ENOSYS; | return -ENOSYS; | ||||
} | } | ||||
static int c4iw_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) | static int c4iw_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) | ||||
Show All 9 Lines | static int c4iw_process_mad(struct ib_device *ibdev, int mad_flags, | ||||
struct ib_mad_hdr *out_mad, | struct ib_mad_hdr *out_mad, | ||||
size_t *out_mad_size, | size_t *out_mad_size, | ||||
u16 *out_mad_pkey_index) | u16 *out_mad_pkey_index) | ||||
{ | { | ||||
return -ENOSYS; | return -ENOSYS; | ||||
} | } | ||||
void _c4iw_free_ucontext(struct kref *kref) | static void c4iw_dealloc_ucontext(struct ib_ucontext *context) | ||||
{ | { | ||||
struct c4iw_ucontext *ucontext; | struct c4iw_ucontext *ucontext = to_c4iw_ucontext(context); | ||||
struct c4iw_dev *rhp; | struct c4iw_dev *rhp; | ||||
struct c4iw_mm_entry *mm, *tmp; | struct c4iw_mm_entry *mm, *tmp; | ||||
ucontext = container_of(kref, struct c4iw_ucontext, kref); | pr_debug("context %p\n", context); | ||||
rhp = to_c4iw_dev(ucontext->ibucontext.device); | rhp = to_c4iw_dev(ucontext->ibucontext.device); | ||||
CTR2(KTR_IW_CXGBE, "%s ucontext %p", __func__, ucontext); | CTR2(KTR_IW_CXGBE, "%s ucontext %p", __func__, ucontext); | ||||
list_for_each_entry_safe(mm, tmp, &ucontext->mmaps, entry) | list_for_each_entry_safe(mm, tmp, &ucontext->mmaps, entry) | ||||
kfree(mm); | kfree(mm); | ||||
c4iw_release_dev_ucontext(&rhp->rdev, &ucontext->uctx); | c4iw_release_dev_ucontext(&rhp->rdev, &ucontext->uctx); | ||||
kfree(ucontext); | |||||
} | } | ||||
static int c4iw_dealloc_ucontext(struct ib_ucontext *context) | static int c4iw_alloc_ucontext(struct ib_ucontext *ucontext, | ||||
{ | |||||
struct c4iw_ucontext *ucontext = to_c4iw_ucontext(context); | |||||
CTR2(KTR_IW_CXGBE, "%s context %p", __func__, context); | |||||
c4iw_put_ucontext(ucontext); | |||||
return 0; | |||||
} | |||||
static struct ib_ucontext *c4iw_alloc_ucontext(struct ib_device *ibdev, | |||||
struct ib_udata *udata) | struct ib_udata *udata) | ||||
{ | { | ||||
struct c4iw_ucontext *context; | struct ib_device *ibdev = ucontext->device; | ||||
struct c4iw_ucontext *context = to_c4iw_ucontext(ucontext); | |||||
struct c4iw_dev *rhp = to_c4iw_dev(ibdev); | struct c4iw_dev *rhp = to_c4iw_dev(ibdev); | ||||
static int warned; | static int warned; | ||||
struct c4iw_alloc_ucontext_resp uresp; | struct c4iw_alloc_ucontext_resp uresp; | ||||
int ret = 0; | int ret = 0; | ||||
struct c4iw_mm_entry *mm = NULL; | struct c4iw_mm_entry *mm = NULL; | ||||
PDBG("%s ibdev %p\n", __func__, ibdev); | PDBG("%s ibdev %p\n", __func__, ibdev); | ||||
context = kzalloc(sizeof(*context), GFP_KERNEL); | |||||
if (!context) { | |||||
ret = -ENOMEM; | |||||
goto err; | |||||
} | |||||
c4iw_init_dev_ucontext(&rhp->rdev, &context->uctx); | c4iw_init_dev_ucontext(&rhp->rdev, &context->uctx); | ||||
INIT_LIST_HEAD(&context->mmaps); | INIT_LIST_HEAD(&context->mmaps); | ||||
spin_lock_init(&context->mmap_lock); | spin_lock_init(&context->mmap_lock); | ||||
kref_init(&context->kref); | |||||
if (udata->outlen < sizeof(uresp) - sizeof(uresp.reserved)) { | if (udata->outlen < sizeof(uresp) - sizeof(uresp.reserved)) { | ||||
if (!warned++) | if (!warned++) | ||||
log(LOG_ERR, "%s Warning - downlevel libcxgb4 " | log(LOG_ERR, "%s Warning - downlevel libcxgb4 " | ||||
"(non-fatal), device status page disabled.\n", | "(non-fatal), device status page disabled.\n", | ||||
__func__); | __func__); | ||||
rhp->rdev.flags |= T4_STATUS_PAGE_DISABLED; | rhp->rdev.flags |= T4_STATUS_PAGE_DISABLED; | ||||
} else { | } else { | ||||
mm = kmalloc(sizeof *mm, GFP_KERNEL); | mm = kmalloc(sizeof *mm, GFP_KERNEL); | ||||
if (!mm) | if (!mm) | ||||
goto err_free; | goto err; | ||||
uresp.status_page_size = PAGE_SIZE; | uresp.status_page_size = PAGE_SIZE; | ||||
spin_lock(&context->mmap_lock); | spin_lock(&context->mmap_lock); | ||||
uresp.status_page_key = context->key; | uresp.status_page_key = context->key; | ||||
context->key += PAGE_SIZE; | context->key += PAGE_SIZE; | ||||
spin_unlock(&context->mmap_lock); | spin_unlock(&context->mmap_lock); | ||||
ret = ib_copy_to_udata(udata, &uresp, | ret = ib_copy_to_udata(udata, &uresp, | ||||
sizeof(uresp) - sizeof(uresp.reserved)); | sizeof(uresp) - sizeof(uresp.reserved)); | ||||
if (ret) | if (ret) | ||||
goto err_mm; | goto err_mm; | ||||
mm->key = uresp.status_page_key; | mm->key = uresp.status_page_key; | ||||
mm->addr = vtophys(rhp->rdev.status_page); | mm->addr = vtophys(rhp->rdev.status_page); | ||||
mm->len = PAGE_SIZE; | mm->len = PAGE_SIZE; | ||||
insert_mmap(context, mm); | insert_mmap(context, mm); | ||||
} | } | ||||
return &context->ibucontext; | return 0; | ||||
err_mm: | err_mm: | ||||
kfree(mm); | kfree(mm); | ||||
err_free: | |||||
kfree(context); | |||||
err: | err: | ||||
return ERR_PTR(ret); | return ret; | ||||
} | } | ||||
static int c4iw_mmap(struct ib_ucontext *context, struct vm_area_struct *vma) | static int c4iw_mmap(struct ib_ucontext *context, struct vm_area_struct *vma) | ||||
{ | { | ||||
int len = vma->vm_end - vma->vm_start; | int len = vma->vm_end - vma->vm_start; | ||||
u32 key = vma->vm_pgoff << PAGE_SHIFT; | u32 key = vma->vm_pgoff << PAGE_SHIFT; | ||||
struct c4iw_rdev *rdev; | struct c4iw_rdev *rdev; | ||||
int ret = 0; | int ret = 0; | ||||
Show All 34 Lines | static int c4iw_mmap(struct ib_ucontext *context, struct vm_area_struct *vma) | ||||
ret = io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT, | ret = io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT, | ||||
len, vma->vm_page_prot); | len, vma->vm_page_prot); | ||||
CTR4(KTR_IW_CXGBE, "%s:4 ctx %p vma %p ret %u", __func__, context, vma, | CTR4(KTR_IW_CXGBE, "%s:4 ctx %p vma %p ret %u", __func__, context, vma, | ||||
ret); | ret); | ||||
return ret; | return ret; | ||||
} | } | ||||
static int | static void | ||||
c4iw_deallocate_pd(struct ib_pd *pd) | c4iw_deallocate_pd(struct ib_pd *pd, struct ib_udata *udata) | ||||
{ | { | ||||
struct c4iw_pd *php = to_c4iw_pd(pd); | struct c4iw_pd *php = to_c4iw_pd(pd); | ||||
struct c4iw_dev *rhp = php->rhp; | struct c4iw_dev *rhp = php->rhp; | ||||
CTR3(KTR_IW_CXGBE, "%s: pd %p, pdid 0x%x", __func__, pd, php->pdid); | CTR3(KTR_IW_CXGBE, "%s: pd %p, pdid 0x%x", __func__, pd, php->pdid); | ||||
c4iw_put_resource(&rhp->rdev.resource.pdid_table, php->pdid); | c4iw_put_resource(&rhp->rdev.resource.pdid_table, php->pdid); | ||||
mutex_lock(&rhp->rdev.stats.lock); | mutex_lock(&rhp->rdev.stats.lock); | ||||
rhp->rdev.stats.pd.cur--; | rhp->rdev.stats.pd.cur--; | ||||
mutex_unlock(&rhp->rdev.stats.lock); | mutex_unlock(&rhp->rdev.stats.lock); | ||||
kfree(php); | |||||
return (0); | |||||
} | } | ||||
static struct ib_pd * | static int | ||||
c4iw_allocate_pd(struct ib_device *ibdev, struct ib_ucontext *context, | c4iw_allocate_pd(struct ib_pd *pd, struct ib_udata *udata) | ||||
struct ib_udata *udata) | |||||
{ | { | ||||
struct c4iw_pd *php; | struct c4iw_pd *php = to_c4iw_pd(pd); | ||||
struct ib_device *ibdev = pd->device; | |||||
u32 pdid; | u32 pdid; | ||||
struct c4iw_dev *rhp; | struct c4iw_dev *rhp; | ||||
CTR4(KTR_IW_CXGBE, "%s: ibdev %p, context %p, data %p", __func__, ibdev, | CTR4(KTR_IW_CXGBE, "%s: ibdev %p, pd %p, data %p", __func__, ibdev, | ||||
context, udata); | pd, udata); | ||||
rhp = (struct c4iw_dev *) ibdev; | rhp = (struct c4iw_dev *) ibdev; | ||||
pdid = c4iw_get_resource(&rhp->rdev.resource.pdid_table); | pdid = c4iw_get_resource(&rhp->rdev.resource.pdid_table); | ||||
if (!pdid) | if (!pdid) | ||||
return ERR_PTR(-EINVAL); | return -EINVAL; | ||||
php = kzalloc(sizeof(*php), GFP_KERNEL); | |||||
if (!php) { | |||||
c4iw_put_resource(&rhp->rdev.resource.pdid_table, pdid); | |||||
return ERR_PTR(-ENOMEM); | |||||
} | |||||
php->pdid = pdid; | php->pdid = pdid; | ||||
php->rhp = rhp; | php->rhp = rhp; | ||||
if (context) { | if (udata) { | ||||
if (ib_copy_to_udata(udata, &php->pdid, sizeof(u32))) { | if (ib_copy_to_udata(udata, &php->pdid, sizeof(u32))) { | ||||
c4iw_deallocate_pd(&php->ibpd); | c4iw_deallocate_pd(&php->ibpd, udata); | ||||
return ERR_PTR(-EFAULT); | return -EFAULT; | ||||
} | } | ||||
} | } | ||||
mutex_lock(&rhp->rdev.stats.lock); | mutex_lock(&rhp->rdev.stats.lock); | ||||
rhp->rdev.stats.pd.cur++; | rhp->rdev.stats.pd.cur++; | ||||
if (rhp->rdev.stats.pd.cur > rhp->rdev.stats.pd.max) | if (rhp->rdev.stats.pd.cur > rhp->rdev.stats.pd.max) | ||||
rhp->rdev.stats.pd.max = rhp->rdev.stats.pd.cur; | rhp->rdev.stats.pd.max = rhp->rdev.stats.pd.cur; | ||||
mutex_unlock(&rhp->rdev.stats.lock); | mutex_unlock(&rhp->rdev.stats.lock); | ||||
CTR6(KTR_IW_CXGBE, | CTR5(KTR_IW_CXGBE, | ||||
"%s: ibdev %p, context %p, data %p, pddid 0x%x, pd %p", __func__, | "%s: ibdev %p, context %p, data %p, pddid 0x%x, pd %p", __func__, | ||||
ibdev, context, udata, pdid, php); | ibdev, udata, pdid, php); | ||||
np: Fix KTR build. | |||||
return (&php->ibpd); | return (0); | ||||
} | } | ||||
static int | static int | ||||
c4iw_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey) | c4iw_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey) | ||||
{ | { | ||||
CTR5(KTR_IW_CXGBE, "%s ibdev %p, port %d, index %d, pkey %p", __func__, | CTR5(KTR_IW_CXGBE, "%s ibdev %p, port %d, index %d, pkey %p", __func__, | ||||
ibdev, port, index, pkey); | ibdev, port, index, pkey); | ||||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | c4iw_register_device(struct c4iw_dev *dev) | ||||
struct iw_cm_verbs *iwcm; | struct iw_cm_verbs *iwcm; | ||||
int ret; | int ret; | ||||
CTR3(KTR_IW_CXGBE, "%s c4iw_dev %p, adapter %p", __func__, dev, sc); | CTR3(KTR_IW_CXGBE, "%s c4iw_dev %p, adapter %p", __func__, dev, sc); | ||||
BUG_ON(!sc->port[0]); | BUG_ON(!sc->port[0]); | ||||
ret = linux_pci_attach_device(sc->dev, NULL, NULL, &dev->pdev); | ret = linux_pci_attach_device(sc->dev, NULL, NULL, &dev->pdev); | ||||
if (ret) | if (ret) | ||||
return (ret); | return (ret); | ||||
#define c4iw_ib_cq c4iw_cq | |||||
#define c4iw_ib_pd c4iw_pd | |||||
#define c4iw_ib_qp c4iw_qp | |||||
#define c4iw_ib_ucontext c4iw_ucontext | |||||
INIT_IB_DEVICE_OPS(&ibdev->ops, c4iw, CXGB4); | |||||
Done Inline ActionsThis part is to avoid too many changes to the driver. hselasky: This part is to avoid too many changes to the driver.
In the future the device ops structure… | |||||
strlcpy(ibdev->name, device_get_nameunit(sc->dev), sizeof(ibdev->name)); | strlcpy(ibdev->name, device_get_nameunit(sc->dev), sizeof(ibdev->name)); | ||||
memset(&ibdev->node_guid, 0, sizeof(ibdev->node_guid)); | memset(&ibdev->node_guid, 0, sizeof(ibdev->node_guid)); | ||||
memcpy(&ibdev->node_guid, sc->port[0]->vi[0].hw_addr, ETHER_ADDR_LEN); | memcpy(&ibdev->node_guid, sc->port[0]->vi[0].hw_addr, ETHER_ADDR_LEN); | ||||
ibdev->owner = THIS_MODULE; | ibdev->owner = THIS_MODULE; | ||||
dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW; | dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW; | ||||
if (fastreg_support) | if (fastreg_support) | ||||
dev->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS; | dev->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS; | ||||
ibdev->local_dma_lkey = 0; | ibdev->local_dma_lkey = 0; | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |
Fix KTR build.