提交 5924aea6 编写于 作者: C Chien Tung 提交者: Roland Dreier

RDMA/nes: Add max_cqe check to nes_create_cq()

Add a check to nes_create_cq() to return -EINVAL if creating a CQ with
depth > max_cqe (32766).
Signed-off-by: NChien Tung <chien.tin.tung@intel.com>
Signed-off-by: NRoland Dreier <rolandd@cisco.com>
上级 75742c63
...@@ -482,7 +482,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) { ...@@ -482,7 +482,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) {
nesadapter->max_irrq_wr = (u32temp >> 16) & 3; nesadapter->max_irrq_wr = (u32temp >> 16) & 3;
nesadapter->max_sge = 4; nesadapter->max_sge = 4;
nesadapter->max_cqe = 32767; nesadapter->max_cqe = 32766;
if (nes_read_eeprom_values(nesdev, nesadapter)) { if (nes_read_eeprom_values(nesdev, nesadapter)) {
printk(KERN_ERR PFX "Unable to read EEPROM data.\n"); printk(KERN_ERR PFX "Unable to read EEPROM data.\n");
......
...@@ -527,7 +527,7 @@ static int nes_query_device(struct ib_device *ibdev, struct ib_device_attr *prop ...@@ -527,7 +527,7 @@ static int nes_query_device(struct ib_device *ibdev, struct ib_device_attr *prop
props->max_qp_wr = nesdev->nesadapter->max_qp_wr - 2; props->max_qp_wr = nesdev->nesadapter->max_qp_wr - 2;
props->max_sge = nesdev->nesadapter->max_sge; props->max_sge = nesdev->nesadapter->max_sge;
props->max_cq = nesibdev->max_cq; props->max_cq = nesibdev->max_cq;
props->max_cqe = nesdev->nesadapter->max_cqe - 1; props->max_cqe = nesdev->nesadapter->max_cqe;
props->max_mr = nesibdev->max_mr; props->max_mr = nesibdev->max_mr;
props->max_mw = nesibdev->max_mr; props->max_mw = nesibdev->max_mr;
props->max_pd = nesibdev->max_pd; props->max_pd = nesibdev->max_pd;
...@@ -1543,6 +1543,9 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries, ...@@ -1543,6 +1543,9 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
unsigned long flags; unsigned long flags;
int ret; int ret;
if (entries > nesadapter->max_cqe)
return ERR_PTR(-EINVAL);
err = nes_alloc_resource(nesadapter, nesadapter->allocated_cqs, err = nes_alloc_resource(nesadapter, nesadapter->allocated_cqs,
nesadapter->max_cq, &cq_num, &nesadapter->next_cq); nesadapter->max_cq, &cq_num, &nesadapter->next_cq);
if (err) { if (err) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册