Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 358852
b: refs/heads/master
c: 55abf8d
h: refs/heads/master
v: v3
  • Loading branch information
Vipul Pandya authored and Roland Dreier committed Feb 14, 2013
1 parent 9cc372e commit 82bfdcb
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 270 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6b52a12bc3fc39053b5bac4d4927ec8d974f8f60
refs/heads/master: 55abf8df0aa080eb474f7f46337503351890b361
2 changes: 0 additions & 2 deletions trunk/drivers/infiniband/core/uverbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ IB_UVERBS_DECLARE_CMD(alloc_pd);
IB_UVERBS_DECLARE_CMD(dealloc_pd);
IB_UVERBS_DECLARE_CMD(reg_mr);
IB_UVERBS_DECLARE_CMD(dereg_mr);
IB_UVERBS_DECLARE_CMD(alloc_mw);
IB_UVERBS_DECLARE_CMD(dealloc_mw);
IB_UVERBS_DECLARE_CMD(create_comp_channel);
IB_UVERBS_DECLARE_CMD(create_cq);
IB_UVERBS_DECLARE_CMD(resize_cq);
Expand Down
121 changes: 0 additions & 121 deletions trunk/drivers/infiniband/core/uverbs_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct uverbs_lock_class {

static struct uverbs_lock_class pd_lock_class = { .name = "PD-uobj" };
static struct uverbs_lock_class mr_lock_class = { .name = "MR-uobj" };
static struct uverbs_lock_class mw_lock_class = { .name = "MW-uobj" };
static struct uverbs_lock_class cq_lock_class = { .name = "CQ-uobj" };
static struct uverbs_lock_class qp_lock_class = { .name = "QP-uobj" };
static struct uverbs_lock_class ah_lock_class = { .name = "AH-uobj" };
Expand Down Expand Up @@ -1050,126 +1049,6 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file,
return in_len;
}

ssize_t ib_uverbs_alloc_mw(struct ib_uverbs_file *file,
const char __user *buf, int in_len,
int out_len)
{
struct ib_uverbs_alloc_mw cmd;
struct ib_uverbs_alloc_mw_resp resp;
struct ib_uobject *uobj;
struct ib_pd *pd;
struct ib_mw *mw;
int ret;

if (out_len < sizeof(resp))
return -ENOSPC;

if (copy_from_user(&cmd, buf, sizeof(cmd)))
return -EFAULT;

uobj = kmalloc(sizeof(*uobj), GFP_KERNEL);
if (!uobj)
return -ENOMEM;

init_uobj(uobj, 0, file->ucontext, &mw_lock_class);
down_write(&uobj->mutex);

pd = idr_read_pd(cmd.pd_handle, file->ucontext);
if (!pd) {
ret = -EINVAL;
goto err_free;
}

mw = pd->device->alloc_mw(pd, cmd.mw_type);
if (IS_ERR(mw)) {
ret = PTR_ERR(mw);
goto err_put;
}

mw->device = pd->device;
mw->pd = pd;
mw->uobject = uobj;
atomic_inc(&pd->usecnt);

uobj->object = mw;
ret = idr_add_uobj(&ib_uverbs_mw_idr, uobj);
if (ret)
goto err_unalloc;

memset(&resp, 0, sizeof(resp));
resp.rkey = mw->rkey;
resp.mw_handle = uobj->id;

if (copy_to_user((void __user *)(unsigned long)cmd.response,
&resp, sizeof(resp))) {
ret = -EFAULT;
goto err_copy;
}

put_pd_read(pd);

mutex_lock(&file->mutex);
list_add_tail(&uobj->list, &file->ucontext->mw_list);
mutex_unlock(&file->mutex);

uobj->live = 1;

up_write(&uobj->mutex);

return in_len;

err_copy:
idr_remove_uobj(&ib_uverbs_mw_idr, uobj);

err_unalloc:
ib_dealloc_mw(mw);

err_put:
put_pd_read(pd);

err_free:
put_uobj_write(uobj);
return ret;
}

ssize_t ib_uverbs_dealloc_mw(struct ib_uverbs_file *file,
const char __user *buf, int in_len,
int out_len)
{
struct ib_uverbs_dealloc_mw cmd;
struct ib_mw *mw;
struct ib_uobject *uobj;
int ret = -EINVAL;

if (copy_from_user(&cmd, buf, sizeof(cmd)))
return -EFAULT;

uobj = idr_write_uobj(&ib_uverbs_mw_idr, cmd.mw_handle, file->ucontext);
if (!uobj)
return -EINVAL;

mw = uobj->object;

ret = ib_dealloc_mw(mw);
if (!ret)
uobj->live = 0;

put_uobj_write(uobj);

if (ret)
return ret;

idr_remove_uobj(&ib_uverbs_mw_idr, uobj);

mutex_lock(&file->mutex);
list_del(&uobj->list);
mutex_unlock(&file->mutex);

put_uobj(uobj);

return in_len;
}

ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
const char __user *buf, int in_len,
int out_len)
Expand Down
13 changes: 2 additions & 11 deletions trunk/drivers/infiniband/core/uverbs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
[IB_USER_VERBS_CMD_DEALLOC_PD] = ib_uverbs_dealloc_pd,
[IB_USER_VERBS_CMD_REG_MR] = ib_uverbs_reg_mr,
[IB_USER_VERBS_CMD_DEREG_MR] = ib_uverbs_dereg_mr,
[IB_USER_VERBS_CMD_ALLOC_MW] = ib_uverbs_alloc_mw,
[IB_USER_VERBS_CMD_DEALLOC_MW] = ib_uverbs_dealloc_mw,
[IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL] = ib_uverbs_create_comp_channel,
[IB_USER_VERBS_CMD_CREATE_CQ] = ib_uverbs_create_cq,
[IB_USER_VERBS_CMD_RESIZE_CQ] = ib_uverbs_resize_cq,
Expand Down Expand Up @@ -203,15 +201,6 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
kfree(uobj);
}

/* Remove MWs before QPs, in order to support type 2A MWs. */
list_for_each_entry_safe(uobj, tmp, &context->mw_list, list) {
struct ib_mw *mw = uobj->object;

idr_remove_uobj(&ib_uverbs_mw_idr, uobj);
ib_dealloc_mw(mw);
kfree(uobj);
}

list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) {
struct ib_qp *qp = uobj->object;
struct ib_uqp_object *uqp =
Expand Down Expand Up @@ -251,6 +240,8 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
kfree(uevent);
}

/* XXX Free MWs */

list_for_each_entry_safe(uobj, tmp, &context->mr_list, list) {
struct ib_mr *mr = uobj->object;

Expand Down
5 changes: 2 additions & 3 deletions trunk/drivers/infiniband/core/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,19 +1099,18 @@ EXPORT_SYMBOL(ib_free_fast_reg_page_list);

/* Memory windows */

struct ib_mw *ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
struct ib_mw *ib_alloc_mw(struct ib_pd *pd)
{
struct ib_mw *mw;

if (!pd->device->alloc_mw)
return ERR_PTR(-ENOSYS);

mw = pd->device->alloc_mw(pd, type);
mw = pd->device->alloc_mw(pd);
if (!IS_ERR(mw)) {
mw->device = pd->device;
mw->pd = pd;
mw->uobject = NULL;
mw->type = type;
atomic_inc(&pd->usecnt);
}

Expand Down
5 changes: 1 addition & 4 deletions trunk/drivers/infiniband/hw/cxgb3/iwch_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ static struct ib_mr *iwch_get_dma_mr(struct ib_pd *pd, int acc)
return ibmr;
}

static struct ib_mw *iwch_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
static struct ib_mw *iwch_alloc_mw(struct ib_pd *pd)
{
struct iwch_dev *rhp;
struct iwch_pd *php;
Expand All @@ -747,9 +747,6 @@ static struct ib_mw *iwch_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
u32 stag = 0;
int ret;

if (type != IB_MW_TYPE_1)
return ERR_PTR(-EINVAL);

php = to_iwch_pd(pd);
rhp = php->rhp;
mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
Expand Down
15 changes: 7 additions & 8 deletions trunk/drivers/infiniband/hw/cxgb3/iwch_qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,19 +567,18 @@ int iwch_bind_mw(struct ib_qp *qp,
if (mw_bind->send_flags & IB_SEND_SIGNALED)
t3_wr_flags = T3_COMPLETION_FLAG;

sgl.addr = mw_bind->bind_info.addr;
sgl.lkey = mw_bind->bind_info.mr->lkey;
sgl.length = mw_bind->bind_info.length;
sgl.addr = mw_bind->addr;
sgl.lkey = mw_bind->mr->lkey;
sgl.length = mw_bind->length;
wqe->bind.reserved = 0;
wqe->bind.type = TPT_VATO;

/* TBD: check perms */
wqe->bind.perms = iwch_ib_to_tpt_bind_access(
mw_bind->bind_info.mw_access_flags);
wqe->bind.mr_stag = cpu_to_be32(mw_bind->bind_info.mr->lkey);
wqe->bind.perms = iwch_ib_to_tpt_bind_access(mw_bind->mw_access_flags);
wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey);
wqe->bind.mw_stag = cpu_to_be32(mw->rkey);
wqe->bind.mw_len = cpu_to_be32(mw_bind->bind_info.length);
wqe->bind.mw_va = cpu_to_be64(mw_bind->bind_info.addr);
wqe->bind.mw_len = cpu_to_be32(mw_bind->length);
wqe->bind.mw_va = cpu_to_be64(mw_bind->addr);
err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size);
if (err) {
spin_unlock_irqrestore(&qhp->lock, flag);
Expand Down
19 changes: 10 additions & 9 deletions trunk/drivers/infiniband/hw/cxgb4/cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1391,30 +1391,31 @@ static int rx_data(struct c4iw_dev *dev, struct sk_buff *skb)
skb_pull(skb, sizeof(*hdr));
skb_trim(skb, dlen);

ep->rcv_seq += dlen;
BUG_ON(ep->rcv_seq != (ntohl(hdr->seq) + dlen));

/* update RX credits */
update_rx_credits(ep, dlen);

switch (state_read(&ep->com)) {
case MPA_REQ_SENT:
ep->rcv_seq += dlen;
process_mpa_reply(ep, skb);
break;
case MPA_REQ_WAIT:
ep->rcv_seq += dlen;
process_mpa_request(ep, skb);
break;
case MPA_REP_SENT:
break;
default:
pr_err("%s Unexpected streaming data." \
" ep %p state %d tid %u status %d\n",
__func__, ep, state_read(&ep->com), ep->hwtid, status);

/*
* The ep will timeout and inform the ULP of the failure.
* See ep_timeout().
*/
if (ep->com.qp) {
struct c4iw_qp_attributes attrs;

attrs.next_state = C4IW_QP_STATE_ERROR;
c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp,
C4IW_QP_ATTR_NEXT_STATE, &attrs, 1);
}
c4iw_ep_disconnect(ep, 1, GFP_KERNEL);
break;
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ struct ib_fast_reg_page_list *c4iw_alloc_fastreg_pbl(
int page_list_len);
struct ib_mr *c4iw_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth);
int c4iw_dealloc_mw(struct ib_mw *mw);
struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type);
struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd);
struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start,
u64 length, u64 virt, int acc,
struct ib_udata *udata);
Expand Down
5 changes: 1 addition & 4 deletions trunk/drivers/infiniband/hw/cxgb4/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
return ERR_PTR(err);
}

struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd)
{
struct c4iw_dev *rhp;
struct c4iw_pd *php;
Expand All @@ -659,9 +659,6 @@ struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
u32 stag = 0;
int ret;

if (type != IB_MW_TYPE_1)
return ERR_PTR(-EINVAL);

php = to_c4iw_pd(pd);
rhp = php->rhp;
mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/infiniband/hw/ehca/ehca_iverbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int ehca_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);

int ehca_dereg_mr(struct ib_mr *mr);

struct ib_mw *ehca_alloc_mw(struct ib_pd *pd, enum ib_mw_type type);
struct ib_mw *ehca_alloc_mw(struct ib_pd *pd);

int ehca_bind_mw(struct ib_qp *qp, struct ib_mw *mw,
struct ib_mw_bind *mw_bind);
Expand Down
5 changes: 1 addition & 4 deletions trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ int ehca_dereg_mr(struct ib_mr *mr)

/*----------------------------------------------------------------------*/

struct ib_mw *ehca_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
struct ib_mw *ehca_alloc_mw(struct ib_pd *pd)
{
struct ib_mw *ib_mw;
u64 h_ret;
Expand All @@ -698,9 +698,6 @@ struct ib_mw *ehca_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
container_of(pd->device, struct ehca_shca, ib_device);
struct ehca_mw_hipzout_parms hipzout;

if (type != IB_MW_TYPE_1)
return ERR_PTR(-EINVAL);

e_mw = ehca_mw_new();
if (!e_mw) {
ib_mw = ERR_PTR(-ENOMEM);
Expand Down
19 changes: 8 additions & 11 deletions trunk/drivers/infiniband/hw/nes/nes_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
/**
* nes_alloc_mw
*/
static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type)
{
static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) {
struct nes_pd *nespd = to_nespd(ibpd);
struct nes_vnic *nesvnic = to_nesvnic(ibpd->device);
struct nes_device *nesdev = nesvnic->nesdev;
Expand All @@ -72,9 +71,6 @@ static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type)
u32 driver_key = 0;
u8 stag_key = 0;

if (type != IB_MW_TYPE_1)
return ERR_PTR(-EINVAL);

get_random_bytes(&next_stag_index, sizeof(next_stag_index));
stag_key = (u8)next_stag_index;

Expand Down Expand Up @@ -248,19 +244,20 @@ static int nes_bind_mw(struct ib_qp *ibqp, struct ib_mw *ibmw,
if (ibmw_bind->send_flags & IB_SEND_SIGNALED)
wqe_misc |= NES_IWARP_SQ_WQE_SIGNALED_COMPL;

if (ibmw_bind->bind_info.mw_access_flags & IB_ACCESS_REMOTE_WRITE)
if (ibmw_bind->mw_access_flags & IB_ACCESS_REMOTE_WRITE) {
wqe_misc |= NES_CQP_STAG_RIGHTS_REMOTE_WRITE;
if (ibmw_bind->bind_info.mw_access_flags & IB_ACCESS_REMOTE_READ)
}
if (ibmw_bind->mw_access_flags & IB_ACCESS_REMOTE_READ) {
wqe_misc |= NES_CQP_STAG_RIGHTS_REMOTE_READ;
}

set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_MISC_IDX, wqe_misc);
set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_BIND_WQE_MR_IDX,
ibmw_bind->bind_info.mr->lkey);
set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_BIND_WQE_MR_IDX, ibmw_bind->mr->lkey);
set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_BIND_WQE_MW_IDX, ibmw->rkey);
set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_BIND_WQE_LENGTH_LOW_IDX,
ibmw_bind->bind_info.length);
ibmw_bind->length);
wqe->wqe_words[NES_IWARP_SQ_BIND_WQE_LENGTH_HIGH_IDX] = 0;
u64temp = (u64)ibmw_bind->bind_info.addr;
u64temp = (u64)ibmw_bind->addr;
set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_BIND_WQE_VA_FBO_LOW_IDX, u64temp);

head++;
Expand Down
Loading

0 comments on commit 82bfdcb

Please sign in to comment.