hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/infiniband/hw/i40iw/i40iw_cm.c
....@@ -404,7 +404,7 @@
404404 if (pdata)
405405 pd_len = pdata->size;
406406
407
- if (cm_node->vlan_id < VLAN_TAG_PRESENT)
407
+ if (cm_node->vlan_id <= VLAN_VID_MASK)
408408 eth_hlen += 4;
409409
410410 if (cm_node->ipv4)
....@@ -433,7 +433,7 @@
433433
434434 ether_addr_copy(ethh->h_dest, cm_node->rem_mac);
435435 ether_addr_copy(ethh->h_source, cm_node->loc_mac);
436
- if (cm_node->vlan_id < VLAN_TAG_PRESENT) {
436
+ if (cm_node->vlan_id <= VLAN_VID_MASK) {
437437 ((struct vlan_ethhdr *)ethh)->h_vlan_proto = htons(ETH_P_8021Q);
438438 vtag = (cm_node->user_pri << VLAN_PRIO_SHIFT) | cm_node->vlan_id;
439439 ((struct vlan_ethhdr *)ethh)->h_vlan_TCI = htons(vtag);
....@@ -463,7 +463,7 @@
463463
464464 ether_addr_copy(ethh->h_dest, cm_node->rem_mac);
465465 ether_addr_copy(ethh->h_source, cm_node->loc_mac);
466
- if (cm_node->vlan_id < VLAN_TAG_PRESENT) {
466
+ if (cm_node->vlan_id <= VLAN_VID_MASK) {
467467 ((struct vlan_ethhdr *)ethh)->h_vlan_proto = htons(ETH_P_8021Q);
468468 vtag = (cm_node->user_pri << VLAN_PRIO_SHIFT) | cm_node->vlan_id;
469469 ((struct vlan_ethhdr *)ethh)->h_vlan_TCI = htons(vtag);
....@@ -1773,8 +1773,11 @@
17731773 if ((((rdma_vlan_dev_vlan_id(dev) < I40IW_NO_VLAN) &&
17741774 (rdma_vlan_dev_real_dev(dev) == iwdev->netdev)) ||
17751775 (dev == iwdev->netdev)) && (dev->flags & IFF_UP)) {
1776
+ const struct in_ifaddr *ifa;
1777
+
17761778 idev = in_dev_get(dev);
1777
- for_ifa(idev) {
1779
+
1780
+ in_dev_for_each_ifa_rtnl(ifa, idev) {
17781781 i40iw_debug(&iwdev->sc_dev,
17791782 I40IW_DEBUG_CM,
17801783 "Allocating child CM Listener forIP=%pI4, vlan_id=%d, MAC=%pM\n",
....@@ -1819,7 +1822,7 @@
18191822 cm_parent_listen_node->cm_core->stats_listen_nodes_created--;
18201823 }
18211824 }
1822
- endfor_ifa(idev);
1825
+
18231826 in_dev_put(idev);
18241827 }
18251828 }
....@@ -2319,7 +2322,7 @@
23192322 iwqp = cm_node->iwqp;
23202323 if (iwqp) {
23212324 iwqp->cm_node = NULL;
2322
- i40iw_rem_ref(&iwqp->ibqp);
2325
+ i40iw_qp_rem_ref(&iwqp->ibqp);
23232326 cm_node->iwqp = NULL;
23242327 } else if (cm_node->qhash_set) {
23252328 i40iw_get_addr_info(cm_node, &nfo);
....@@ -2440,7 +2443,7 @@
24402443 case I40IW_CM_STATE_FIN_WAIT1:
24412444 case I40IW_CM_STATE_LAST_ACK:
24422445 cm_node->cm_id->rem_ref(cm_node->cm_id);
2443
- /* fall through */
2446
+ fallthrough;
24442447 case I40IW_CM_STATE_TIME_WAIT:
24452448 cm_node->state = I40IW_CM_STATE_CLOSED;
24462449 i40iw_rem_ref_cm_node(cm_node);
....@@ -3229,7 +3232,7 @@
32293232 * core
32303233 * @iwdev: iwarp device structure
32313234 */
3232
-void i40iw_setup_cm_core(struct i40iw_device *iwdev)
3235
+int i40iw_setup_cm_core(struct i40iw_device *iwdev)
32333236 {
32343237 struct i40iw_cm_core *cm_core = &iwdev->cm_core;
32353238
....@@ -3248,9 +3251,19 @@
32483251
32493252 cm_core->event_wq = alloc_ordered_workqueue("iwewq",
32503253 WQ_MEM_RECLAIM);
3254
+ if (!cm_core->event_wq)
3255
+ goto error;
32513256
32523257 cm_core->disconn_wq = alloc_ordered_workqueue("iwdwq",
32533258 WQ_MEM_RECLAIM);
3259
+ if (!cm_core->disconn_wq)
3260
+ goto error;
3261
+
3262
+ return 0;
3263
+error:
3264
+ i40iw_cleanup_cm_core(&iwdev->cm_core);
3265
+
3266
+ return -ENOMEM;
32543267 }
32553268
32563269 /**
....@@ -3270,8 +3283,10 @@
32703283 del_timer_sync(&cm_core->tcp_timer);
32713284 spin_unlock_irqrestore(&cm_core->ht_lock, flags);
32723285
3273
- destroy_workqueue(cm_core->event_wq);
3274
- destroy_workqueue(cm_core->disconn_wq);
3286
+ if (cm_core->event_wq)
3287
+ destroy_workqueue(cm_core->event_wq);
3288
+ if (cm_core->disconn_wq)
3289
+ destroy_workqueue(cm_core->disconn_wq);
32753290 }
32763291
32773292 /**
....@@ -3315,7 +3330,7 @@
33153330
33163331 tcp_info->flow_label = 0;
33173332 tcp_info->snd_mss = cpu_to_le32(((u32)cm_node->tcp_cntxt.mss));
3318
- if (cm_node->vlan_id < VLAN_TAG_PRESENT) {
3333
+ if (cm_node->vlan_id <= VLAN_VID_MASK) {
33193334 tcp_info->insert_vlan_tag = true;
33203335 tcp_info->vlan_tag = cpu_to_le16(((u16)cm_node->user_pri << I40IW_VLAN_PRIO_SHIFT) |
33213336 cm_node->vlan_id);
....@@ -3437,7 +3452,7 @@
34373452 kfree(work);
34383453 return;
34393454 }
3440
- i40iw_add_ref(&iwqp->ibqp);
3455
+ i40iw_qp_add_ref(&iwqp->ibqp);
34413456 spin_unlock_irqrestore(&iwdev->qptable_lock, flags);
34423457
34433458 work->iwqp = iwqp;
....@@ -3470,7 +3485,8 @@
34703485 /* Need to free the Last Streaming Mode Message */
34713486 if (iwqp->ietf_mem.va) {
34723487 if (iwqp->lsmm_mr)
3473
- iwibdev->ibdev.dereg_mr(iwqp->lsmm_mr);
3488
+ iwibdev->ibdev.ops.dereg_mr(iwqp->lsmm_mr,
3489
+ NULL);
34743490 i40iw_free_dma_mem(iwdev->sc_dev.hw, &iwqp->ietf_mem);
34753491 }
34763492 }
....@@ -3607,7 +3623,7 @@
36073623
36083624 kfree(dwork);
36093625 i40iw_cm_disconn_true(iwqp);
3610
- i40iw_rem_ref(&iwqp->ibqp);
3626
+ i40iw_qp_rem_ref(&iwqp->ibqp);
36113627 }
36123628
36133629 /**
....@@ -3729,7 +3745,7 @@
37293745 cm_node->lsmm_size = accept.size + conn_param->private_data_len;
37303746 i40iw_cm_init_tsa_conn(iwqp, cm_node);
37313747 cm_id->add_ref(cm_id);
3732
- i40iw_add_ref(&iwqp->ibqp);
3748
+ i40iw_qp_add_ref(&iwqp->ibqp);
37333749
37343750 attr.qp_state = IB_QPS_RTS;
37353751 cm_node->qhash_set = false;
....@@ -3892,7 +3908,7 @@
38923908 iwqp->cm_node = cm_node;
38933909 cm_node->iwqp = iwqp;
38943910 iwqp->cm_id = cm_id;
3895
- i40iw_add_ref(&iwqp->ibqp);
3911
+ i40iw_qp_add_ref(&iwqp->ibqp);
38963912
38973913 if (cm_node->state != I40IW_CM_STATE_OFFLOADED) {
38983914 cm_node->state = I40IW_CM_STATE_SYN_SENT;
....@@ -4255,11 +4271,11 @@
42554271 /* if not found then add a child listener if interface is going up */
42564272 if (!ifup)
42574273 return;
4258
- child_listen_node = kzalloc(sizeof(*child_listen_node), GFP_ATOMIC);
4274
+ child_listen_node = kmemdup(parent_listen_node,
4275
+ sizeof(*child_listen_node), GFP_ATOMIC);
42594276 if (!child_listen_node)
42604277 return;
42614278 node_allocated = true;
4262
- memcpy(child_listen_node, parent_listen_node, sizeof(*child_listen_node));
42634279
42644280 memcpy(child_listen_node->loc_addr, ipaddr, ipv4 ? 4 : 16);
42654281