Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 121453
b: refs/heads/master
c: b8dd786
h: refs/heads/master
i:
  121451: 56db901
v: v3
  • Loading branch information
Yevgeny Petrilin authored and Roland Dreier committed Dec 22, 2008
1 parent 1085412 commit 1afc481
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 159 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: bba7ebba3b17f4fe8c5907a32e16d9bd3fcf5192
refs/heads/master: b8dd786f9417e5885929bfe33a235c76a9c1c569
2 changes: 1 addition & 1 deletion trunk/drivers/infiniband/hw/mlx4/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector
}

err = mlx4_cq_alloc(dev->dev, entries, &cq->buf.mtt, uar,
cq->db.dma, &cq->mcq, 0);
cq->db.dma, &cq->mcq, vector, 0);
if (err)
goto err_dbmap;

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/infiniband/hw/mlx4/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
ibdev->num_ports++;
ibdev->ib_dev.phys_port_cnt = ibdev->num_ports;
ibdev->ib_dev.num_comp_vectors = 1;
ibdev->ib_dev.num_comp_vectors = dev->caps.num_comp_vectors;
ibdev->ib_dev.dma_device = &dev->pdev->dev;

ibdev->ib_dev.uverbs_abi_ver = MLX4_IB_UVERBS_ABI_VERSION;
Expand Down
3 changes: 0 additions & 3 deletions trunk/drivers/infiniband/ulp/iser/iscsi_iser.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ struct iser_conn {
wait_queue_head_t wait; /* waitq for conn/disconn */
atomic_t post_recv_buf_count; /* posted rx count */
atomic_t post_send_buf_count; /* posted tx count */
atomic_t unexpected_pdu_count;/* count of received *
* unexpected pdus *
* not yet retired */
char name[ISER_OBJECT_NAME_SIZE];
struct iser_page_vec *page_vec; /* represents SG to fmr maps*
* maps serialized as tx is*/
Expand Down
132 changes: 41 additions & 91 deletions trunk/drivers/infiniband/ulp/iser/iser_initiator.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,14 @@ static int iser_post_receive_control(struct iscsi_conn *conn)
struct iser_regd_buf *regd_data;
struct iser_dto *recv_dto = NULL;
struct iser_device *device = iser_conn->ib_conn->device;
int rx_data_size, err;
int posts, outstanding_unexp_pdus;
int rx_data_size, err = 0;

rx_desc = kmem_cache_alloc(ig.desc_cache, GFP_NOIO);
if (rx_desc == NULL) {
iser_err("Failed to alloc desc for post recv\n");
return -ENOMEM;
}
rx_desc->type = ISCSI_RX;

/* for the login sequence we must support rx of upto 8K; login is done
* after conn create/bind (connect) and conn stop/bind (reconnect),
Expand All @@ -195,80 +201,46 @@ static int iser_post_receive_control(struct iscsi_conn *conn)
else /* FIXME till user space sets conn->max_recv_dlength correctly */
rx_data_size = 128;

outstanding_unexp_pdus =
atomic_xchg(&iser_conn->ib_conn->unexpected_pdu_count, 0);

/*
* in addition to the response buffer, replace those consumed by
* unexpected pdus.
*/
for (posts = 0; posts < 1 + outstanding_unexp_pdus; posts++) {
rx_desc = kmem_cache_alloc(ig.desc_cache, GFP_NOIO);
if (rx_desc == NULL) {
iser_err("Failed to alloc desc for post recv %d\n",
posts);
err = -ENOMEM;
goto post_rx_cache_alloc_failure;
}
rx_desc->type = ISCSI_RX;
rx_desc->data = kmalloc(rx_data_size, GFP_NOIO);
if (rx_desc->data == NULL) {
iser_err("Failed to alloc data buf for post recv %d\n",
posts);
err = -ENOMEM;
goto post_rx_kmalloc_failure;
}
rx_desc->data = kmalloc(rx_data_size, GFP_NOIO);
if (rx_desc->data == NULL) {
iser_err("Failed to alloc data buf for post recv\n");
err = -ENOMEM;
goto post_rx_kmalloc_failure;
}

recv_dto = &rx_desc->dto;
recv_dto->ib_conn = iser_conn->ib_conn;
recv_dto->regd_vector_len = 0;
recv_dto = &rx_desc->dto;
recv_dto->ib_conn = iser_conn->ib_conn;
recv_dto->regd_vector_len = 0;

regd_hdr = &rx_desc->hdr_regd_buf;
memset(regd_hdr, 0, sizeof(struct iser_regd_buf));
regd_hdr->device = device;
regd_hdr->virt_addr = rx_desc; /* == &rx_desc->iser_header */
regd_hdr->data_size = ISER_TOTAL_HEADERS_LEN;
regd_hdr = &rx_desc->hdr_regd_buf;
memset(regd_hdr, 0, sizeof(struct iser_regd_buf));
regd_hdr->device = device;
regd_hdr->virt_addr = rx_desc; /* == &rx_desc->iser_header */
regd_hdr->data_size = ISER_TOTAL_HEADERS_LEN;

iser_reg_single(device, regd_hdr, DMA_FROM_DEVICE);
iser_reg_single(device, regd_hdr, DMA_FROM_DEVICE);

iser_dto_add_regd_buff(recv_dto, regd_hdr, 0, 0);
iser_dto_add_regd_buff(recv_dto, regd_hdr, 0, 0);

regd_data = &rx_desc->data_regd_buf;
memset(regd_data, 0, sizeof(struct iser_regd_buf));
regd_data->device = device;
regd_data->virt_addr = rx_desc->data;
regd_data->data_size = rx_data_size;
regd_data = &rx_desc->data_regd_buf;
memset(regd_data, 0, sizeof(struct iser_regd_buf));
regd_data->device = device;
regd_data->virt_addr = rx_desc->data;
regd_data->data_size = rx_data_size;

iser_reg_single(device, regd_data, DMA_FROM_DEVICE);
iser_reg_single(device, regd_data, DMA_FROM_DEVICE);

iser_dto_add_regd_buff(recv_dto, regd_data, 0, 0);
iser_dto_add_regd_buff(recv_dto, regd_data, 0, 0);

err = iser_post_recv(rx_desc);
if (err) {
iser_err("Failed iser_post_recv for post %d\n", posts);
goto post_rx_post_recv_failure;
}
}
/* all posts successful */
return 0;
err = iser_post_recv(rx_desc);
if (!err)
return 0;

post_rx_post_recv_failure:
/* iser_post_recv failed */
iser_dto_buffs_release(recv_dto);
kfree(rx_desc->data);
post_rx_kmalloc_failure:
kmem_cache_free(ig.desc_cache, rx_desc);
post_rx_cache_alloc_failure:
if (posts > 0) {
/*
* response buffer posted, but did not replace all unexpected
* pdu recv bufs. Ignore error, retry occurs next send
*/
outstanding_unexp_pdus -= (posts - 1);
err = 0;
}
atomic_add(outstanding_unexp_pdus,
&iser_conn->ib_conn->unexpected_pdu_count);

return err;
}

Expand Down Expand Up @@ -302,10 +274,8 @@ int iser_conn_set_full_featured_mode(struct iscsi_conn *conn)
struct iscsi_iser_conn *iser_conn = conn->dd_data;

int i;
/*
* FIXME this value should be declared to the target during login with
* the MaxOutstandingUnexpectedPDUs key when supported
*/
/* no need to keep it in a var, we are after login so if this should
* be negotiated, by now the result should be available here */
int initial_post_recv_bufs_num = ISER_MAX_RX_MISC_PDUS;

iser_dbg("Initially post: %d\n", initial_post_recv_bufs_num);
Expand Down Expand Up @@ -508,7 +478,6 @@ int iser_send_control(struct iscsi_conn *conn,
int err = 0;
struct iser_regd_buf *regd_buf;
struct iser_device *device;
unsigned char opcode;

if (!iser_conn_state_comp(iser_conn->ib_conn, ISER_CONN_UP)) {
iser_err("Failed to send, conn: 0x%p is not up\n", iser_conn->ib_conn);
Expand Down Expand Up @@ -543,15 +512,10 @@ int iser_send_control(struct iscsi_conn *conn,
data_seg_len);
}

opcode = task->hdr->opcode & ISCSI_OPCODE_MASK;

/* post recv buffer for response if one is expected */
if (!(opcode == ISCSI_OP_NOOP_OUT && task->hdr->itt == RESERVED_ITT)) {
if (iser_post_receive_control(conn) != 0) {
iser_err("post_rcv_buff failed!\n");
err = -ENOMEM;
goto send_control_error;
}
if (iser_post_receive_control(conn) != 0) {
iser_err("post_rcv_buff failed!\n");
err = -ENOMEM;
goto send_control_error;
}

err = iser_post_send(mdesc);
Expand Down Expand Up @@ -622,20 +586,6 @@ void iser_rcv_completion(struct iser_desc *rx_desc,
* parallel to the execution of iser_conn_term. So the code that waits *
* for the posted rx bufs refcount to become zero handles everything */
atomic_dec(&conn->ib_conn->post_recv_buf_count);

/*
* if an unexpected PDU was received then the recv wr consumed must
* be replaced, this is done in the next send of a control-type PDU
*/
if (opcode == ISCSI_OP_NOOP_IN && hdr->itt == RESERVED_ITT) {
/* nop-in with itt = 0xffffffff */
atomic_inc(&conn->ib_conn->unexpected_pdu_count);
}
else if (opcode == ISCSI_OP_ASYNC_EVENT) {
/* asyncronous message */
atomic_inc(&conn->ib_conn->unexpected_pdu_count);
}
/* a reject PDU consumes the recv buf posted for the response */
}

void iser_snd_completion(struct iser_desc *tx_desc)
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/infiniband/ulp/iser/iser_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ void iser_conn_init(struct iser_conn *ib_conn)
init_waitqueue_head(&ib_conn->wait);
atomic_set(&ib_conn->post_recv_buf_count, 0);
atomic_set(&ib_conn->post_send_buf_count, 0);
atomic_set(&ib_conn->unexpected_pdu_count, 0);
atomic_set(&ib_conn->refcount, 1);
INIT_LIST_HEAD(&ib_conn->conn_list);
spin_lock_init(&ib_conn->lock);
Expand Down
11 changes: 8 additions & 3 deletions trunk/drivers/net/mlx4/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ EXPORT_SYMBOL_GPL(mlx4_cq_resize);

int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,
struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq,
int collapsed)
unsigned vector, int collapsed)
{
struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_cq_table *cq_table = &priv->cq_table;
Expand All @@ -198,6 +198,11 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,
u64 mtt_addr;
int err;

if (vector >= dev->caps.num_comp_vectors)
return -EINVAL;

cq->vector = vector;

cq->cqn = mlx4_bitmap_alloc(&cq_table->bitmap);
if (cq->cqn == -1)
return -ENOMEM;
Expand Down Expand Up @@ -227,7 +232,7 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,

cq_context->flags = cpu_to_be32(!!collapsed << 18);
cq_context->logsize_usrpage = cpu_to_be32((ilog2(nent) << 24) | uar->index);
cq_context->comp_eqn = priv->eq_table.eq[MLX4_EQ_COMP].eqn;
cq_context->comp_eqn = priv->eq_table.eq[vector].eqn;
cq_context->log_page_size = mtt->page_shift - MLX4_ICM_PAGE_SHIFT;

mtt_addr = mlx4_mtt_addr(dev, mtt);
Expand Down Expand Up @@ -276,7 +281,7 @@ void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq)
if (err)
mlx4_warn(dev, "HW2SW_CQ failed (%d) for CQN %06x\n", err, cq->cqn);

synchronize_irq(priv->eq_table.eq[MLX4_EQ_COMP].irq);
synchronize_irq(priv->eq_table.eq[cq->vector].irq);

spin_lock_irq(&cq_table->lock);
radix_tree_delete(&cq_table->tree, cq->cqn);
Expand Down
9 changes: 6 additions & 3 deletions trunk/drivers/net/mlx4/en_cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ int mlx4_en_create_cq(struct mlx4_en_priv *priv,
int err;

cq->size = entries;
if (mode == RX)
if (mode == RX) {
cq->buf_size = cq->size * sizeof(struct mlx4_cqe);
else
cq->vector = ring % mdev->dev->caps.num_comp_vectors;
} else {
cq->buf_size = sizeof(struct mlx4_cqe);
cq->vector = 0;
}

cq->ring = ring;
cq->is_tx = mode;
Expand Down Expand Up @@ -86,7 +89,7 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq)
memset(cq->buf, 0, cq->buf_size);

err = mlx4_cq_alloc(mdev->dev, cq->size, &cq->wqres.mtt, &mdev->priv_uar,
cq->wqres.db.dma, &cq->mcq, cq->is_tx);
cq->wqres.db.dma, &cq->mcq, cq->vector, cq->is_tx);
if (err)
return err;

Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/net/mlx4/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ static void *mlx4_en_add(struct mlx4_dev *dev)
mlx4_info(mdev, "Using %d tx rings for port:%d\n",
mdev->profile.prof[i].tx_ring_num, i);
if (!mdev->profile.prof[i].rx_ring_num) {
mdev->profile.prof[i].rx_ring_num = 1;
mdev->profile.prof[i].rx_ring_num = dev->caps.num_comp_vectors;
mlx4_info(mdev, "Defaulting to %d rx rings for port:%d\n",
1, i);
mdev->profile.prof[i].rx_ring_num, i);
} else
mlx4_info(mdev, "Using %d rx rings for port:%d\n",
mdev->profile.prof[i].rx_ring_num, i);
Expand Down
Loading

0 comments on commit 1afc481

Please sign in to comment.