Skip to content

Commit 08d49c4

Browse files
committed
Merge tag 'rdma-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband
Pull InfiniBand/RDMA fixes from Roland Dreier: - Fixes to new ocrdma driver - Typo in test in CMA * tag 'rdma-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband: RDMA/cma: QP type check on received REQs should be AND not OR RDMA/ocrdma: Fix off by one in ocrdma_query_gid() RDMA/ocrdma: Fixed RQ error CQE polling RDMA/ocrdma: Correct queue SGE calculation RDMA/ocrdma: Correct reported max queue sizes RDMA/ocrdma: Fixed GID table for vlan and events
2 parents a4a20fd + 2e51fd3 commit 08d49c4

File tree

6 files changed

+55
-46
lines changed

6 files changed

+55
-46
lines changed

drivers/infiniband/core/cma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ static void cma_set_req_event_data(struct rdma_cm_event *event,
11841184

11851185
static int cma_check_req_qp_type(struct rdma_cm_id *id, struct ib_cm_event *ib_event)
11861186
{
1187-
return (((ib_event->event == IB_CM_REQ_RECEIVED) ||
1187+
return (((ib_event->event == IB_CM_REQ_RECEIVED) &&
11881188
(ib_event->param.req_rcvd.qp_type == id->qp_type)) ||
11891189
((ib_event->event == IB_CM_SIDR_REQ_RECEIVED) &&
11901190
(id->qp_type == IB_QPT_UD)) ||

drivers/infiniband/hw/ocrdma/ocrdma.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct ocrdma_dev_attr {
6161
u32 max_inline_data;
6262
int max_send_sge;
6363
int max_recv_sge;
64+
int max_srq_sge;
6465
int max_mr;
6566
u64 max_mr_size;
6667
u32 max_num_mr_pbl;

drivers/infiniband/hw/ocrdma/ocrdma_hw.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,6 @@ static void ocrdma_get_attr(struct ocrdma_dev *dev,
990990
struct ocrdma_dev_attr *attr,
991991
struct ocrdma_mbx_query_config *rsp)
992992
{
993-
int max_q_mem;
994-
995993
attr->max_pd =
996994
(rsp->max_pd_ca_ack_delay & OCRDMA_MBX_QUERY_CFG_MAX_PD_MASK) >>
997995
OCRDMA_MBX_QUERY_CFG_MAX_PD_SHIFT;
@@ -1004,6 +1002,9 @@ static void ocrdma_get_attr(struct ocrdma_dev *dev,
10041002
attr->max_recv_sge = (rsp->max_write_send_sge &
10051003
OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK) >>
10061004
OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT;
1005+
attr->max_srq_sge = (rsp->max_srq_rqe_sge &
1006+
OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_MASK) >>
1007+
OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_OFFSET;
10071008
attr->max_ord_per_qp = (rsp->max_ird_ord_per_qp &
10081009
OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_MASK) >>
10091010
OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_SHIFT;
@@ -1037,18 +1038,15 @@ static void ocrdma_get_attr(struct ocrdma_dev *dev,
10371038
attr->max_inline_data =
10381039
attr->wqe_size - (sizeof(struct ocrdma_hdr_wqe) +
10391040
sizeof(struct ocrdma_sge));
1040-
max_q_mem = OCRDMA_Q_PAGE_BASE_SIZE << (OCRDMA_MAX_Q_PAGE_SIZE_CNT - 1);
1041-
/* hw can queue one less then the configured size,
1042-
* so publish less by one to stack.
1043-
*/
10441041
if (dev->nic_info.dev_family == OCRDMA_GEN2_FAMILY) {
1045-
dev->attr.max_wqe = max_q_mem / dev->attr.wqe_size;
10461042
attr->ird = 1;
10471043
attr->ird_page_size = OCRDMA_MIN_Q_PAGE_SIZE;
10481044
attr->num_ird_pages = MAX_OCRDMA_IRD_PAGES;
1049-
} else
1050-
dev->attr.max_wqe = (max_q_mem / dev->attr.wqe_size) - 1;
1051-
dev->attr.max_rqe = (max_q_mem / dev->attr.rqe_size) - 1;
1045+
}
1046+
dev->attr.max_wqe = rsp->max_wqes_rqes_per_q >>
1047+
OCRDMA_MBX_QUERY_CFG_MAX_WQES_PER_WQ_OFFSET;
1048+
dev->attr.max_rqe = rsp->max_wqes_rqes_per_q &
1049+
OCRDMA_MBX_QUERY_CFG_MAX_RQES_PER_RQ_MASK;
10521050
}
10531051

10541052
static int ocrdma_check_fw_config(struct ocrdma_dev *dev,

drivers/infiniband/hw/ocrdma/ocrdma_main.c

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,11 @@ static void ocrdma_build_sgid_mac(union ib_gid *sgid, unsigned char *mac_addr,
9797
sgid->raw[15] = mac_addr[5];
9898
}
9999

100-
static void ocrdma_add_sgid(struct ocrdma_dev *dev, unsigned char *mac_addr,
100+
static bool ocrdma_add_sgid(struct ocrdma_dev *dev, unsigned char *mac_addr,
101101
bool is_vlan, u16 vlan_id)
102102
{
103103
int i;
104-
bool found = false;
105104
union ib_gid new_sgid;
106-
int free_idx = OCRDMA_MAX_SGID;
107105
unsigned long flags;
108106

109107
memset(&ocrdma_zero_sgid, 0, sizeof(union ib_gid));
@@ -115,23 +113,19 @@ static void ocrdma_add_sgid(struct ocrdma_dev *dev, unsigned char *mac_addr,
115113
if (!memcmp(&dev->sgid_tbl[i], &ocrdma_zero_sgid,
116114
sizeof(union ib_gid))) {
117115
/* found free entry */
118-
if (!found) {
119-
free_idx = i;
120-
found = true;
121-
break;
122-
}
116+
memcpy(&dev->sgid_tbl[i], &new_sgid,
117+
sizeof(union ib_gid));
118+
spin_unlock_irqrestore(&dev->sgid_lock, flags);
119+
return true;
123120
} else if (!memcmp(&dev->sgid_tbl[i], &new_sgid,
124121
sizeof(union ib_gid))) {
125122
/* entry already present, no addition is required. */
126123
spin_unlock_irqrestore(&dev->sgid_lock, flags);
127-
return;
124+
return false;
128125
}
129126
}
130-
/* if entry doesn't exist and if table has some space, add entry */
131-
if (found)
132-
memcpy(&dev->sgid_tbl[free_idx], &new_sgid,
133-
sizeof(union ib_gid));
134127
spin_unlock_irqrestore(&dev->sgid_lock, flags);
128+
return false;
135129
}
136130

137131
static bool ocrdma_del_sgid(struct ocrdma_dev *dev, unsigned char *mac_addr,
@@ -167,16 +161,15 @@ static void ocrdma_add_default_sgid(struct ocrdma_dev *dev)
167161
ocrdma_get_guid(dev, &sgid->raw[8]);
168162
}
169163

170-
static int ocrdma_build_sgid_tbl(struct ocrdma_dev *dev)
164+
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
165+
static void ocrdma_add_vlan_sgids(struct ocrdma_dev *dev)
171166
{
172167
struct net_device *netdev, *tmp;
173168
u16 vlan_id;
174169
bool is_vlan;
175170

176171
netdev = dev->nic_info.netdev;
177172

178-
ocrdma_add_default_sgid(dev);
179-
180173
rcu_read_lock();
181174
for_each_netdev_rcu(&init_net, tmp) {
182175
if (netdev == tmp || vlan_dev_real_dev(tmp) == netdev) {
@@ -194,10 +187,23 @@ static int ocrdma_build_sgid_tbl(struct ocrdma_dev *dev)
194187
}
195188
}
196189
rcu_read_unlock();
190+
}
191+
#else
192+
static void ocrdma_add_vlan_sgids(struct ocrdma_dev *dev)
193+
{
194+
195+
}
196+
#endif /* VLAN */
197+
198+
static int ocrdma_build_sgid_tbl(struct ocrdma_dev *dev)
199+
{
200+
ocrdma_add_default_sgid(dev);
201+
ocrdma_add_vlan_sgids(dev);
197202
return 0;
198203
}
199204

200-
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
205+
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) || \
206+
defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
201207

202208
static int ocrdma_inet6addr_event(struct notifier_block *notifier,
203209
unsigned long event, void *ptr)
@@ -208,6 +214,7 @@ static int ocrdma_inet6addr_event(struct notifier_block *notifier,
208214
struct ib_event gid_event;
209215
struct ocrdma_dev *dev;
210216
bool found = false;
217+
bool updated = false;
211218
bool is_vlan = false;
212219
u16 vid = 0;
213220

@@ -233,23 +240,21 @@ static int ocrdma_inet6addr_event(struct notifier_block *notifier,
233240
mutex_lock(&dev->dev_lock);
234241
switch (event) {
235242
case NETDEV_UP:
236-
ocrdma_add_sgid(dev, netdev->dev_addr, is_vlan, vid);
243+
updated = ocrdma_add_sgid(dev, netdev->dev_addr, is_vlan, vid);
237244
break;
238245
case NETDEV_DOWN:
239-
found = ocrdma_del_sgid(dev, netdev->dev_addr, is_vlan, vid);
240-
if (found) {
241-
/* found the matching entry, notify
242-
* the consumers about it
243-
*/
244-
gid_event.device = &dev->ibdev;
245-
gid_event.element.port_num = 1;
246-
gid_event.event = IB_EVENT_GID_CHANGE;
247-
ib_dispatch_event(&gid_event);
248-
}
246+
updated = ocrdma_del_sgid(dev, netdev->dev_addr, is_vlan, vid);
249247
break;
250248
default:
251249
break;
252250
}
251+
if (updated) {
252+
/* GID table updated, notify the consumers about it */
253+
gid_event.device = &dev->ibdev;
254+
gid_event.element.port_num = 1;
255+
gid_event.event = IB_EVENT_GID_CHANGE;
256+
ib_dispatch_event(&gid_event);
257+
}
253258
mutex_unlock(&dev->dev_lock);
254259
return NOTIFY_OK;
255260
}
@@ -258,7 +263,7 @@ static struct notifier_block ocrdma_inet6addr_notifier = {
258263
.notifier_call = ocrdma_inet6addr_event
259264
};
260265

261-
#endif /* IPV6 */
266+
#endif /* IPV6 and VLAN */
262267

263268
static enum rdma_link_layer ocrdma_link_layer(struct ib_device *device,
264269
u8 port_num)

drivers/infiniband/hw/ocrdma/ocrdma_sli.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ enum {
418418

419419
OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT = 0,
420420
OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK = 0xFFFF,
421+
OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_SHIFT = 16,
422+
OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_MASK = 0xFFFF <<
423+
OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_SHIFT,
421424

422425
OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_SHIFT = 0,
423426
OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_MASK = 0xFFFF,
@@ -458,7 +461,7 @@ enum {
458461
OCRDMA_MBX_QUERY_CFG_MAX_WQES_PER_WQ_OFFSET,
459462
OCRDMA_MBX_QUERY_CFG_MAX_RQES_PER_RQ_OFFSET = 0,
460463
OCRDMA_MBX_QUERY_CFG_MAX_RQES_PER_RQ_MASK = 0xFFFF <<
461-
OCRDMA_MBX_QUERY_CFG_MAX_WQES_PER_WQ_OFFSET,
464+
OCRDMA_MBX_QUERY_CFG_MAX_RQES_PER_RQ_OFFSET,
462465

463466
OCRDMA_MBX_QUERY_CFG_MAX_CQ_OFFSET = 16,
464467
OCRDMA_MBX_QUERY_CFG_MAX_CQ_MASK = 0xFFFF <<

drivers/infiniband/hw/ocrdma/ocrdma_verbs.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int ocrdma_query_gid(struct ib_device *ibdev, u8 port,
5353

5454
dev = get_ocrdma_dev(ibdev);
5555
memset(sgid, 0, sizeof(*sgid));
56-
if (index > OCRDMA_MAX_SGID)
56+
if (index >= OCRDMA_MAX_SGID)
5757
return -EINVAL;
5858

5959
memcpy(sgid, &dev->sgid_tbl[index], sizeof(*sgid));
@@ -83,8 +83,8 @@ int ocrdma_query_device(struct ib_device *ibdev, struct ib_device_attr *attr)
8383
IB_DEVICE_SHUTDOWN_PORT |
8484
IB_DEVICE_SYS_IMAGE_GUID |
8585
IB_DEVICE_LOCAL_DMA_LKEY;
86-
attr->max_sge = dev->attr.max_send_sge;
87-
attr->max_sge_rd = dev->attr.max_send_sge;
86+
attr->max_sge = min(dev->attr.max_send_sge, dev->attr.max_srq_sge);
87+
attr->max_sge_rd = 0;
8888
attr->max_cq = dev->attr.max_cq;
8989
attr->max_cqe = dev->attr.max_cqe;
9090
attr->max_mr = dev->attr.max_mr;
@@ -97,7 +97,7 @@ int ocrdma_query_device(struct ib_device *ibdev, struct ib_device_attr *attr)
9797
min(dev->attr.max_ord_per_qp, dev->attr.max_ird_per_qp);
9898
attr->max_qp_init_rd_atom = dev->attr.max_ord_per_qp;
9999
attr->max_srq = (dev->attr.max_qp - 1);
100-
attr->max_srq_sge = attr->max_sge;
100+
attr->max_srq_sge = attr->max_srq_sge;
101101
attr->max_srq_wr = dev->attr.max_rqe;
102102
attr->local_ca_ack_delay = dev->attr.local_ca_ack_delay;
103103
attr->max_fast_reg_page_list_len = 0;
@@ -2301,8 +2301,10 @@ static bool ocrdma_poll_err_rcqe(struct ocrdma_qp *qp, struct ocrdma_cqe *cqe,
23012301
*stop = true;
23022302
expand = false;
23032303
}
2304-
} else
2304+
} else {
2305+
*polled = true;
23052306
expand = ocrdma_update_err_rcqe(ibwc, cqe, qp, status);
2307+
}
23062308
return expand;
23072309
}
23082310

0 commit comments

Comments
 (0)