Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/irdma: Refactor GEN2 auxiliary driver

Refactor the irdma auxiliary driver and associated interfaces out of main.c
and into a standalone GEN2-specific source file and rename as gen_2 driver.

This is in preparation for adding GEN3 auxiliary drivers. Each HW
generation will have its own gen-specific interface file.

Additionally, move the Address Handle hash table and associated locks
under rf struct. This will allow GEN3 code to migrate to use it easily.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Co-developed-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
Link: https://patch.msgid.link/20250827152545.2056-2-tatyana.e.nikolova@intel.com
Tested-by: Jacob Moroni <jmoroni@google.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Mustafa Ismail and committed by
Leon Romanovsky
0c2b80ca 2bd7dd38

+360 -354
+1
drivers/infiniband/hw/irdma/Makefile
··· 13 13 hw.o \ 14 14 i40iw_hw.o \ 15 15 i40iw_if.o \ 16 + icrdma_if.o \ 16 17 icrdma_hw.o \ 17 18 main.o \ 18 19 pble.o \
+2
drivers/infiniband/hw/irdma/i40iw_if.c
··· 75 75 struct irdma_pci_f *rf = iwdev->rf; 76 76 77 77 rf->rdma_ver = IRDMA_GEN_1; 78 + rf->sc_dev.hw = &rf->hw; 79 + rf->sc_dev.hw_attrs.uk_attrs.hw_rev = IRDMA_GEN_1; 78 80 rf->gen_ops.request_reset = i40iw_request_reset; 79 81 rf->pcidev = cdev_info->pcidev; 80 82 rf->pf_id = cdev_info->fid;
+341
drivers/infiniband/hw/irdma/icrdma_if.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB 2 + /* Copyright (c) 2015 - 2024 Intel Corporation */ 3 + 4 + #include "main.h" 5 + #include <linux/net/intel/iidc_rdma_ice.h> 6 + 7 + static void icrdma_prep_tc_change(struct irdma_device *iwdev) 8 + { 9 + iwdev->vsi.tc_change_pending = true; 10 + irdma_sc_suspend_resume_qps(&iwdev->vsi, IRDMA_OP_SUSPEND); 11 + 12 + /* Wait for all qp's to suspend */ 13 + wait_event_timeout(iwdev->suspend_wq, 14 + !atomic_read(&iwdev->vsi.qp_suspend_reqs), 15 + msecs_to_jiffies(IRDMA_EVENT_TIMEOUT_MS)); 16 + irdma_ws_reset(&iwdev->vsi); 17 + } 18 + 19 + static void icrdma_fill_qos_info(struct irdma_l2params *l2params, 20 + struct iidc_rdma_qos_params *qos_info) 21 + { 22 + int i; 23 + 24 + l2params->num_tc = qos_info->num_tc; 25 + l2params->vsi_prio_type = qos_info->vport_priority_type; 26 + l2params->vsi_rel_bw = qos_info->vport_relative_bw; 27 + for (i = 0; i < l2params->num_tc; i++) { 28 + l2params->tc_info[i].egress_virt_up = 29 + qos_info->tc_info[i].egress_virt_up; 30 + l2params->tc_info[i].ingress_virt_up = 31 + qos_info->tc_info[i].ingress_virt_up; 32 + l2params->tc_info[i].prio_type = qos_info->tc_info[i].prio_type; 33 + l2params->tc_info[i].rel_bw = qos_info->tc_info[i].rel_bw; 34 + l2params->tc_info[i].tc_ctx = qos_info->tc_info[i].tc_ctx; 35 + } 36 + for (i = 0; i < IIDC_MAX_USER_PRIORITY; i++) 37 + l2params->up2tc[i] = qos_info->up2tc[i]; 38 + if (qos_info->pfc_mode == IIDC_DSCP_PFC_MODE) { 39 + l2params->dscp_mode = true; 40 + memcpy(l2params->dscp_map, qos_info->dscp_map, sizeof(l2params->dscp_map)); 41 + } 42 + } 43 + 44 + static void icrdma_iidc_event_handler(struct iidc_rdma_core_dev_info *cdev_info, 45 + struct iidc_rdma_event *event) 46 + { 47 + struct irdma_device *iwdev = dev_get_drvdata(&cdev_info->adev->dev); 48 + struct irdma_l2params l2params = {}; 49 + 50 + if (*event->type & BIT(IIDC_RDMA_EVENT_AFTER_MTU_CHANGE)) { 51 + ibdev_dbg(&iwdev->ibdev, "CLNT: new MTU = %d\n", iwdev->netdev->mtu); 52 + if (iwdev->vsi.mtu != iwdev->netdev->mtu) { 53 + l2params.mtu = iwdev->netdev->mtu; 54 + l2params.mtu_changed = true; 55 + irdma_log_invalid_mtu(l2params.mtu, &iwdev->rf->sc_dev); 56 + irdma_change_l2params(&iwdev->vsi, &l2params); 57 + } 58 + } else if (*event->type & BIT(IIDC_RDMA_EVENT_BEFORE_TC_CHANGE)) { 59 + if (iwdev->vsi.tc_change_pending) 60 + return; 61 + 62 + icrdma_prep_tc_change(iwdev); 63 + } else if (*event->type & BIT(IIDC_RDMA_EVENT_AFTER_TC_CHANGE)) { 64 + struct iidc_rdma_priv_dev_info *idc_priv = cdev_info->iidc_priv; 65 + 66 + if (!iwdev->vsi.tc_change_pending) 67 + return; 68 + 69 + l2params.tc_changed = true; 70 + ibdev_dbg(&iwdev->ibdev, "CLNT: TC Change\n"); 71 + 72 + icrdma_fill_qos_info(&l2params, &idc_priv->qos_info); 73 + if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY) 74 + iwdev->dcb_vlan_mode = 75 + l2params.num_tc > 1 && !l2params.dscp_mode; 76 + irdma_change_l2params(&iwdev->vsi, &l2params); 77 + } else if (*event->type & BIT(IIDC_RDMA_EVENT_CRIT_ERR)) { 78 + ibdev_warn(&iwdev->ibdev, "ICE OICR event notification: oicr = 0x%08x\n", 79 + event->reg); 80 + if (event->reg & IRDMAPFINT_OICR_PE_CRITERR_M) { 81 + u32 pe_criterr; 82 + 83 + pe_criterr = readl(iwdev->rf->sc_dev.hw_regs[IRDMA_GLPE_CRITERR]); 84 + #define IRDMA_Q1_RESOURCE_ERR 0x0001024d 85 + if (pe_criterr != IRDMA_Q1_RESOURCE_ERR) { 86 + ibdev_err(&iwdev->ibdev, "critical PE Error, GLPE_CRITERR=0x%08x\n", 87 + pe_criterr); 88 + iwdev->rf->reset = true; 89 + } else { 90 + ibdev_warn(&iwdev->ibdev, "Q1 Resource Check\n"); 91 + } 92 + } 93 + if (event->reg & IRDMAPFINT_OICR_HMC_ERR_M) { 94 + ibdev_err(&iwdev->ibdev, "HMC Error\n"); 95 + iwdev->rf->reset = true; 96 + } 97 + if (event->reg & IRDMAPFINT_OICR_PE_PUSH_M) { 98 + ibdev_err(&iwdev->ibdev, "PE Push Error\n"); 99 + iwdev->rf->reset = true; 100 + } 101 + if (iwdev->rf->reset) 102 + iwdev->rf->gen_ops.request_reset(iwdev->rf); 103 + } 104 + } 105 + 106 + /** 107 + * icrdma_lan_register_qset - Register qset with LAN driver 108 + * @vsi: vsi structure 109 + * @tc_node: Traffic class node 110 + */ 111 + static int icrdma_lan_register_qset(struct irdma_sc_vsi *vsi, 112 + struct irdma_ws_node *tc_node) 113 + { 114 + struct irdma_device *iwdev = vsi->back_vsi; 115 + struct iidc_rdma_core_dev_info *cdev_info = iwdev->rf->cdev; 116 + struct iidc_rdma_qset_params qset = {}; 117 + int ret; 118 + 119 + qset.qs_handle = tc_node->qs_handle; 120 + qset.tc = tc_node->traffic_class; 121 + qset.vport_id = vsi->vsi_idx; 122 + ret = ice_add_rdma_qset(cdev_info, &qset); 123 + if (ret) { 124 + ibdev_dbg(&iwdev->ibdev, "WS: LAN alloc_res for rdma qset failed.\n"); 125 + return ret; 126 + } 127 + 128 + tc_node->l2_sched_node_id = qset.teid; 129 + vsi->qos[tc_node->user_pri].l2_sched_node_id = qset.teid; 130 + 131 + return 0; 132 + } 133 + 134 + /** 135 + * icrdma_lan_unregister_qset - Unregister qset with LAN driver 136 + * @vsi: vsi structure 137 + * @tc_node: Traffic class node 138 + */ 139 + static void icrdma_lan_unregister_qset(struct irdma_sc_vsi *vsi, 140 + struct irdma_ws_node *tc_node) 141 + { 142 + struct irdma_device *iwdev = vsi->back_vsi; 143 + struct iidc_rdma_core_dev_info *cdev_info = iwdev->rf->cdev; 144 + struct iidc_rdma_qset_params qset = {}; 145 + 146 + qset.qs_handle = tc_node->qs_handle; 147 + qset.tc = tc_node->traffic_class; 148 + qset.vport_id = vsi->vsi_idx; 149 + qset.teid = tc_node->l2_sched_node_id; 150 + 151 + if (ice_del_rdma_qset(cdev_info, &qset)) 152 + ibdev_dbg(&iwdev->ibdev, "WS: LAN free_res for rdma qset failed.\n"); 153 + } 154 + 155 + /** 156 + * icrdma_request_reset - Request a reset 157 + * @rf: RDMA PCI function 158 + */ 159 + static void icrdma_request_reset(struct irdma_pci_f *rf) 160 + { 161 + ibdev_warn(&rf->iwdev->ibdev, "Requesting a reset\n"); 162 + ice_rdma_request_reset(rf->cdev, IIDC_FUNC_RESET); 163 + } 164 + 165 + static int icrdma_init_interrupts(struct irdma_pci_f *rf, struct iidc_rdma_core_dev_info *cdev) 166 + { 167 + int i; 168 + 169 + rf->msix_count = num_online_cpus() + IRDMA_NUM_AEQ_MSIX; 170 + rf->msix_entries = kcalloc(rf->msix_count, sizeof(*rf->msix_entries), 171 + GFP_KERNEL); 172 + if (!rf->msix_entries) 173 + return -ENOMEM; 174 + 175 + for (i = 0; i < rf->msix_count; i++) 176 + if (ice_alloc_rdma_qvector(cdev, &rf->msix_entries[i])) 177 + break; 178 + 179 + if (i < IRDMA_MIN_MSIX) { 180 + while (--i >= 0) 181 + ice_free_rdma_qvector(cdev, &rf->msix_entries[i]); 182 + 183 + kfree(rf->msix_entries); 184 + return -ENOMEM; 185 + } 186 + 187 + rf->msix_count = i; 188 + 189 + return 0; 190 + } 191 + 192 + static void icrdma_deinit_interrupts(struct irdma_pci_f *rf, struct iidc_rdma_core_dev_info *cdev) 193 + { 194 + int i; 195 + 196 + for (i = 0; i < rf->msix_count; i++) 197 + ice_free_rdma_qvector(cdev, &rf->msix_entries[i]); 198 + 199 + kfree(rf->msix_entries); 200 + } 201 + 202 + static void icrdma_fill_device_info(struct irdma_device *iwdev, 203 + struct iidc_rdma_core_dev_info *cdev_info) 204 + { 205 + struct iidc_rdma_priv_dev_info *idc_priv = cdev_info->iidc_priv; 206 + struct irdma_pci_f *rf = iwdev->rf; 207 + 208 + rf->sc_dev.hw = &rf->hw; 209 + rf->iwdev = iwdev; 210 + rf->cdev = cdev_info; 211 + rf->hw.hw_addr = idc_priv->hw_addr; 212 + rf->pcidev = cdev_info->pdev; 213 + rf->hw.device = &rf->pcidev->dev; 214 + rf->pf_id = idc_priv->pf_id; 215 + rf->rdma_ver = IRDMA_GEN_2; 216 + rf->sc_dev.hw_attrs.uk_attrs.hw_rev = IRDMA_GEN_2; 217 + 218 + rf->gen_ops.register_qset = icrdma_lan_register_qset; 219 + rf->gen_ops.unregister_qset = icrdma_lan_unregister_qset; 220 + 221 + rf->default_vsi.vsi_idx = idc_priv->vport_id; 222 + rf->protocol_used = 223 + cdev_info->rdma_protocol == IIDC_RDMA_PROTOCOL_ROCEV2 ? 224 + IRDMA_ROCE_PROTOCOL_ONLY : IRDMA_IWARP_PROTOCOL_ONLY; 225 + rf->rsrc_profile = IRDMA_HMC_PROFILE_DEFAULT; 226 + rf->rst_to = IRDMA_RST_TIMEOUT_HZ; 227 + rf->gen_ops.request_reset = icrdma_request_reset; 228 + rf->limits_sel = 7; 229 + mutex_init(&rf->ah_tbl_lock); 230 + 231 + iwdev->netdev = idc_priv->netdev; 232 + iwdev->vsi_num = idc_priv->vport_id; 233 + iwdev->init_state = INITIAL_STATE; 234 + iwdev->roce_cwnd = IRDMA_ROCE_CWND_DEFAULT; 235 + iwdev->roce_ackcreds = IRDMA_ROCE_ACKCREDS_DEFAULT; 236 + iwdev->rcv_wnd = IRDMA_CM_DEFAULT_RCV_WND_SCALED; 237 + iwdev->rcv_wscale = IRDMA_CM_DEFAULT_RCV_WND_SCALE; 238 + if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY) 239 + iwdev->roce_mode = true; 240 + } 241 + 242 + static int icrdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_device_id *id) 243 + { 244 + struct iidc_rdma_core_auxiliary_dev *iidc_adev; 245 + struct iidc_rdma_core_dev_info *cdev_info; 246 + struct iidc_rdma_priv_dev_info *idc_priv; 247 + struct irdma_l2params l2params = {}; 248 + struct irdma_device *iwdev; 249 + struct irdma_pci_f *rf; 250 + int err; 251 + 252 + iidc_adev = container_of(aux_dev, struct iidc_rdma_core_auxiliary_dev, adev); 253 + cdev_info = iidc_adev->cdev_info; 254 + idc_priv = cdev_info->iidc_priv; 255 + 256 + iwdev = ib_alloc_device(irdma_device, ibdev); 257 + if (!iwdev) 258 + return -ENOMEM; 259 + iwdev->rf = kzalloc(sizeof(*rf), GFP_KERNEL); 260 + if (!iwdev->rf) { 261 + ib_dealloc_device(&iwdev->ibdev); 262 + return -ENOMEM; 263 + } 264 + 265 + icrdma_fill_device_info(iwdev, cdev_info); 266 + rf = iwdev->rf; 267 + 268 + err = icrdma_init_interrupts(rf, cdev_info); 269 + if (err) 270 + goto err_init_interrupts; 271 + 272 + err = irdma_ctrl_init_hw(rf); 273 + if (err) 274 + goto err_ctrl_init; 275 + 276 + l2params.mtu = iwdev->netdev->mtu; 277 + icrdma_fill_qos_info(&l2params, &idc_priv->qos_info); 278 + if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY) 279 + iwdev->dcb_vlan_mode = l2params.num_tc > 1 && !l2params.dscp_mode; 280 + 281 + err = irdma_rt_init_hw(iwdev, &l2params); 282 + if (err) 283 + goto err_rt_init; 284 + 285 + err = irdma_ib_register_device(iwdev); 286 + if (err) 287 + goto err_ibreg; 288 + 289 + ice_rdma_update_vsi_filter(cdev_info, iwdev->vsi_num, true); 290 + 291 + ibdev_dbg(&iwdev->ibdev, "INIT: Gen2 PF[%d] device probe success\n", PCI_FUNC(rf->pcidev->devfn)); 292 + auxiliary_set_drvdata(aux_dev, iwdev); 293 + 294 + return 0; 295 + 296 + err_ibreg: 297 + irdma_rt_deinit_hw(iwdev); 298 + err_rt_init: 299 + irdma_ctrl_deinit_hw(rf); 300 + err_ctrl_init: 301 + icrdma_deinit_interrupts(rf, cdev_info); 302 + err_init_interrupts: 303 + kfree(iwdev->rf); 304 + ib_dealloc_device(&iwdev->ibdev); 305 + 306 + return err; 307 + } 308 + 309 + static void icrdma_remove(struct auxiliary_device *aux_dev) 310 + { 311 + struct iidc_rdma_core_auxiliary_dev *idc_adev = 312 + container_of(aux_dev, struct iidc_rdma_core_auxiliary_dev, adev); 313 + struct iidc_rdma_core_dev_info *cdev_info = idc_adev->cdev_info; 314 + struct irdma_device *iwdev = auxiliary_get_drvdata(aux_dev); 315 + u8 rdma_ver = iwdev->rf->rdma_ver; 316 + 317 + ice_rdma_update_vsi_filter(cdev_info, iwdev->vsi_num, false); 318 + irdma_ib_unregister_device(iwdev); 319 + icrdma_deinit_interrupts(iwdev->rf, cdev_info); 320 + 321 + pr_debug("INIT: Gen[%d] func[%d] device remove success\n", 322 + rdma_ver, PCI_FUNC(cdev_info->pdev->devfn)); 323 + } 324 + 325 + static const struct auxiliary_device_id icrdma_auxiliary_id_table[] = { 326 + {.name = "ice.iwarp", }, 327 + {.name = "ice.roce", }, 328 + {}, 329 + }; 330 + 331 + MODULE_DEVICE_TABLE(auxiliary, icrdma_auxiliary_id_table); 332 + 333 + struct iidc_rdma_core_auxiliary_drv icrdma_core_auxiliary_drv = { 334 + .adrv = { 335 + .name = "gen_2", 336 + .id_table = icrdma_auxiliary_id_table, 337 + .probe = icrdma_probe, 338 + .remove = icrdma_remove, 339 + }, 340 + .event_handler = icrdma_iidc_event_handler, 341 + };
+4 -343
drivers/infiniband/hw/irdma/main.c
··· 38 38 unregister_netdevice_notifier(&irdma_netdevice_notifier); 39 39 } 40 40 41 - static void irdma_prep_tc_change(struct irdma_device *iwdev) 42 - { 43 - iwdev->vsi.tc_change_pending = true; 44 - irdma_sc_suspend_resume_qps(&iwdev->vsi, IRDMA_OP_SUSPEND); 45 - 46 - /* Wait for all qp's to suspend */ 47 - wait_event_timeout(iwdev->suspend_wq, 48 - !atomic_read(&iwdev->vsi.qp_suspend_reqs), 49 - msecs_to_jiffies(IRDMA_EVENT_TIMEOUT_MS)); 50 - irdma_ws_reset(&iwdev->vsi); 51 - } 52 - 53 - static void irdma_log_invalid_mtu(u16 mtu, struct irdma_sc_dev *dev) 41 + void irdma_log_invalid_mtu(u16 mtu, struct irdma_sc_dev *dev) 54 42 { 55 43 if (mtu < IRDMA_MIN_MTU_IPV4) 56 44 ibdev_warn(to_ibdev(dev), "MTU setting [%d] too low for RDMA traffic. Minimum MTU is 576 for IPv4\n", mtu); 57 45 else if (mtu < IRDMA_MIN_MTU_IPV6) 58 46 ibdev_warn(to_ibdev(dev), "MTU setting [%d] too low for RDMA traffic. Minimum MTU is 1280 for IPv6\\n", mtu); 59 47 } 60 - 61 - static void irdma_fill_qos_info(struct irdma_l2params *l2params, 62 - struct iidc_rdma_qos_params *qos_info) 63 - { 64 - int i; 65 - 66 - l2params->num_tc = qos_info->num_tc; 67 - l2params->vsi_prio_type = qos_info->vport_priority_type; 68 - l2params->vsi_rel_bw = qos_info->vport_relative_bw; 69 - for (i = 0; i < l2params->num_tc; i++) { 70 - l2params->tc_info[i].egress_virt_up = 71 - qos_info->tc_info[i].egress_virt_up; 72 - l2params->tc_info[i].ingress_virt_up = 73 - qos_info->tc_info[i].ingress_virt_up; 74 - l2params->tc_info[i].prio_type = qos_info->tc_info[i].prio_type; 75 - l2params->tc_info[i].rel_bw = qos_info->tc_info[i].rel_bw; 76 - l2params->tc_info[i].tc_ctx = qos_info->tc_info[i].tc_ctx; 77 - } 78 - for (i = 0; i < IIDC_MAX_USER_PRIORITY; i++) 79 - l2params->up2tc[i] = qos_info->up2tc[i]; 80 - if (qos_info->pfc_mode == IIDC_DSCP_PFC_MODE) { 81 - l2params->dscp_mode = true; 82 - memcpy(l2params->dscp_map, qos_info->dscp_map, sizeof(l2params->dscp_map)); 83 - } 84 - } 85 - 86 - static void irdma_iidc_event_handler(struct iidc_rdma_core_dev_info *cdev_info, 87 - struct iidc_rdma_event *event) 88 - { 89 - struct irdma_device *iwdev = dev_get_drvdata(&cdev_info->adev->dev); 90 - struct irdma_l2params l2params = {}; 91 - 92 - if (*event->type & BIT(IIDC_RDMA_EVENT_AFTER_MTU_CHANGE)) { 93 - ibdev_dbg(&iwdev->ibdev, "CLNT: new MTU = %d\n", iwdev->netdev->mtu); 94 - if (iwdev->vsi.mtu != iwdev->netdev->mtu) { 95 - l2params.mtu = iwdev->netdev->mtu; 96 - l2params.mtu_changed = true; 97 - irdma_log_invalid_mtu(l2params.mtu, &iwdev->rf->sc_dev); 98 - irdma_change_l2params(&iwdev->vsi, &l2params); 99 - } 100 - } else if (*event->type & BIT(IIDC_RDMA_EVENT_BEFORE_TC_CHANGE)) { 101 - if (iwdev->vsi.tc_change_pending) 102 - return; 103 - 104 - irdma_prep_tc_change(iwdev); 105 - } else if (*event->type & BIT(IIDC_RDMA_EVENT_AFTER_TC_CHANGE)) { 106 - struct iidc_rdma_priv_dev_info *iidc_priv = cdev_info->iidc_priv; 107 - 108 - if (!iwdev->vsi.tc_change_pending) 109 - return; 110 - 111 - l2params.tc_changed = true; 112 - ibdev_dbg(&iwdev->ibdev, "CLNT: TC Change\n"); 113 - 114 - irdma_fill_qos_info(&l2params, &iidc_priv->qos_info); 115 - if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY) 116 - iwdev->dcb_vlan_mode = 117 - l2params.num_tc > 1 && !l2params.dscp_mode; 118 - irdma_change_l2params(&iwdev->vsi, &l2params); 119 - } else if (*event->type & BIT(IIDC_RDMA_EVENT_CRIT_ERR)) { 120 - ibdev_warn(&iwdev->ibdev, "ICE OICR event notification: oicr = 0x%08x\n", 121 - event->reg); 122 - if (event->reg & IRDMAPFINT_OICR_PE_CRITERR_M) { 123 - u32 pe_criterr; 124 - 125 - pe_criterr = readl(iwdev->rf->sc_dev.hw_regs[IRDMA_GLPE_CRITERR]); 126 - #define IRDMA_Q1_RESOURCE_ERR 0x0001024d 127 - if (pe_criterr != IRDMA_Q1_RESOURCE_ERR) { 128 - ibdev_err(&iwdev->ibdev, "critical PE Error, GLPE_CRITERR=0x%08x\n", 129 - pe_criterr); 130 - iwdev->rf->reset = true; 131 - } else { 132 - ibdev_warn(&iwdev->ibdev, "Q1 Resource Check\n"); 133 - } 134 - } 135 - if (event->reg & IRDMAPFINT_OICR_HMC_ERR_M) { 136 - ibdev_err(&iwdev->ibdev, "HMC Error\n"); 137 - iwdev->rf->reset = true; 138 - } 139 - if (event->reg & IRDMAPFINT_OICR_PE_PUSH_M) { 140 - ibdev_err(&iwdev->ibdev, "PE Push Error\n"); 141 - iwdev->rf->reset = true; 142 - } 143 - if (iwdev->rf->reset) 144 - iwdev->rf->gen_ops.request_reset(iwdev->rf); 145 - } 146 - } 147 - 148 - /** 149 - * irdma_request_reset - Request a reset 150 - * @rf: RDMA PCI function 151 - */ 152 - static void irdma_request_reset(struct irdma_pci_f *rf) 153 - { 154 - ibdev_warn(&rf->iwdev->ibdev, "Requesting a reset\n"); 155 - ice_rdma_request_reset(rf->cdev, IIDC_FUNC_RESET); 156 - } 157 - 158 - /** 159 - * irdma_lan_register_qset - Register qset with LAN driver 160 - * @vsi: vsi structure 161 - * @tc_node: Traffic class node 162 - */ 163 - static int irdma_lan_register_qset(struct irdma_sc_vsi *vsi, 164 - struct irdma_ws_node *tc_node) 165 - { 166 - struct irdma_device *iwdev = vsi->back_vsi; 167 - struct iidc_rdma_core_dev_info *cdev_info; 168 - struct iidc_rdma_qset_params qset = {}; 169 - int ret; 170 - 171 - cdev_info = iwdev->rf->cdev; 172 - qset.qs_handle = tc_node->qs_handle; 173 - qset.tc = tc_node->traffic_class; 174 - qset.vport_id = vsi->vsi_idx; 175 - ret = ice_add_rdma_qset(cdev_info, &qset); 176 - if (ret) { 177 - ibdev_dbg(&iwdev->ibdev, "WS: LAN alloc_res for rdma qset failed.\n"); 178 - return ret; 179 - } 180 - 181 - tc_node->l2_sched_node_id = qset.teid; 182 - vsi->qos[tc_node->user_pri].l2_sched_node_id = qset.teid; 183 - 184 - return 0; 185 - } 186 - 187 - /** 188 - * irdma_lan_unregister_qset - Unregister qset with LAN driver 189 - * @vsi: vsi structure 190 - * @tc_node: Traffic class node 191 - */ 192 - static void irdma_lan_unregister_qset(struct irdma_sc_vsi *vsi, 193 - struct irdma_ws_node *tc_node) 194 - { 195 - struct irdma_device *iwdev = vsi->back_vsi; 196 - struct iidc_rdma_core_dev_info *cdev_info; 197 - struct iidc_rdma_qset_params qset = {}; 198 - 199 - cdev_info = iwdev->rf->cdev; 200 - qset.qs_handle = tc_node->qs_handle; 201 - qset.tc = tc_node->traffic_class; 202 - qset.vport_id = vsi->vsi_idx; 203 - qset.teid = tc_node->l2_sched_node_id; 204 - 205 - if (ice_del_rdma_qset(cdev_info, &qset)) 206 - ibdev_dbg(&iwdev->ibdev, "WS: LAN free_res for rdma qset failed.\n"); 207 - } 208 - 209 - static int irdma_init_interrupts(struct irdma_pci_f *rf, struct iidc_rdma_core_dev_info *cdev) 210 - { 211 - int i; 212 - 213 - rf->msix_count = num_online_cpus() + IRDMA_NUM_AEQ_MSIX; 214 - rf->msix_entries = kcalloc(rf->msix_count, sizeof(*rf->msix_entries), 215 - GFP_KERNEL); 216 - if (!rf->msix_entries) 217 - return -ENOMEM; 218 - 219 - for (i = 0; i < rf->msix_count; i++) 220 - if (ice_alloc_rdma_qvector(cdev, &rf->msix_entries[i])) 221 - break; 222 - 223 - if (i < IRDMA_MIN_MSIX) { 224 - while (--i >= 0) 225 - ice_free_rdma_qvector(cdev, &rf->msix_entries[i]); 226 - 227 - kfree(rf->msix_entries); 228 - return -ENOMEM; 229 - } 230 - 231 - rf->msix_count = i; 232 - 233 - return 0; 234 - } 235 - 236 - static void irdma_deinit_interrupts(struct irdma_pci_f *rf, struct iidc_rdma_core_dev_info *cdev) 237 - { 238 - int i; 239 - 240 - for (i = 0; i < rf->msix_count; i++) 241 - ice_free_rdma_qvector(cdev, &rf->msix_entries[i]); 242 - 243 - kfree(rf->msix_entries); 244 - } 245 - 246 - static void irdma_remove(struct auxiliary_device *aux_dev) 247 - { 248 - struct irdma_device *iwdev = auxiliary_get_drvdata(aux_dev); 249 - struct iidc_rdma_core_auxiliary_dev *iidc_adev; 250 - struct iidc_rdma_core_dev_info *cdev_info; 251 - 252 - iidc_adev = container_of(aux_dev, struct iidc_rdma_core_auxiliary_dev, adev); 253 - cdev_info = iidc_adev->cdev_info; 254 - 255 - ice_rdma_update_vsi_filter(cdev_info, iwdev->vsi_num, false); 256 - irdma_ib_unregister_device(iwdev); 257 - irdma_deinit_interrupts(iwdev->rf, cdev_info); 258 - 259 - kfree(iwdev->rf); 260 - 261 - pr_debug("INIT: Gen2 PF[%d] device remove success\n", PCI_FUNC(cdev_info->pdev->devfn)); 262 - } 263 - 264 - static void irdma_fill_device_info(struct irdma_device *iwdev, 265 - struct iidc_rdma_core_dev_info *cdev_info) 266 - { 267 - struct iidc_rdma_priv_dev_info *iidc_priv = cdev_info->iidc_priv; 268 - struct irdma_pci_f *rf = iwdev->rf; 269 - 270 - rf->sc_dev.hw = &rf->hw; 271 - rf->iwdev = iwdev; 272 - rf->cdev = cdev_info; 273 - rf->hw.hw_addr = iidc_priv->hw_addr; 274 - rf->pcidev = cdev_info->pdev; 275 - rf->hw.device = &rf->pcidev->dev; 276 - rf->pf_id = iidc_priv->pf_id; 277 - rf->gen_ops.register_qset = irdma_lan_register_qset; 278 - rf->gen_ops.unregister_qset = irdma_lan_unregister_qset; 279 - 280 - rf->default_vsi.vsi_idx = iidc_priv->vport_id; 281 - rf->protocol_used = 282 - cdev_info->rdma_protocol == IIDC_RDMA_PROTOCOL_ROCEV2 ? 283 - IRDMA_ROCE_PROTOCOL_ONLY : IRDMA_IWARP_PROTOCOL_ONLY; 284 - rf->rdma_ver = IRDMA_GEN_2; 285 - rf->rsrc_profile = IRDMA_HMC_PROFILE_DEFAULT; 286 - rf->rst_to = IRDMA_RST_TIMEOUT_HZ; 287 - rf->gen_ops.request_reset = irdma_request_reset; 288 - rf->limits_sel = 7; 289 - rf->iwdev = iwdev; 290 - 291 - mutex_init(&iwdev->ah_tbl_lock); 292 - 293 - iwdev->netdev = iidc_priv->netdev; 294 - iwdev->vsi_num = iidc_priv->vport_id; 295 - iwdev->init_state = INITIAL_STATE; 296 - iwdev->roce_cwnd = IRDMA_ROCE_CWND_DEFAULT; 297 - iwdev->roce_ackcreds = IRDMA_ROCE_ACKCREDS_DEFAULT; 298 - iwdev->rcv_wnd = IRDMA_CM_DEFAULT_RCV_WND_SCALED; 299 - iwdev->rcv_wscale = IRDMA_CM_DEFAULT_RCV_WND_SCALE; 300 - if (rf->protocol_used == IRDMA_ROCE_PROTOCOL_ONLY) 301 - iwdev->roce_mode = true; 302 - } 303 - 304 - static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_device_id *id) 305 - { 306 - struct iidc_rdma_core_auxiliary_dev *iidc_adev; 307 - struct iidc_rdma_core_dev_info *cdev_info; 308 - struct iidc_rdma_priv_dev_info *iidc_priv; 309 - struct irdma_l2params l2params = {}; 310 - struct irdma_device *iwdev; 311 - struct irdma_pci_f *rf; 312 - int err; 313 - 314 - iidc_adev = container_of(aux_dev, struct iidc_rdma_core_auxiliary_dev, adev); 315 - cdev_info = iidc_adev->cdev_info; 316 - iidc_priv = cdev_info->iidc_priv; 317 - 318 - iwdev = ib_alloc_device(irdma_device, ibdev); 319 - if (!iwdev) 320 - return -ENOMEM; 321 - iwdev->rf = kzalloc(sizeof(*rf), GFP_KERNEL); 322 - if (!iwdev->rf) { 323 - ib_dealloc_device(&iwdev->ibdev); 324 - return -ENOMEM; 325 - } 326 - 327 - irdma_fill_device_info(iwdev, cdev_info); 328 - rf = iwdev->rf; 329 - 330 - err = irdma_init_interrupts(rf, cdev_info); 331 - if (err) 332 - goto err_init_interrupts; 333 - 334 - err = irdma_ctrl_init_hw(rf); 335 - if (err) 336 - goto err_ctrl_init; 337 - 338 - l2params.mtu = iwdev->netdev->mtu; 339 - irdma_fill_qos_info(&l2params, &iidc_priv->qos_info); 340 - if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY) 341 - iwdev->dcb_vlan_mode = l2params.num_tc > 1 && !l2params.dscp_mode; 342 - 343 - err = irdma_rt_init_hw(iwdev, &l2params); 344 - if (err) 345 - goto err_rt_init; 346 - 347 - err = irdma_ib_register_device(iwdev); 348 - if (err) 349 - goto err_ibreg; 350 - 351 - ice_rdma_update_vsi_filter(cdev_info, iwdev->vsi_num, true); 352 - 353 - ibdev_dbg(&iwdev->ibdev, "INIT: Gen2 PF[%d] device probe success\n", PCI_FUNC(rf->pcidev->devfn)); 354 - auxiliary_set_drvdata(aux_dev, iwdev); 355 - 356 - return 0; 357 - 358 - err_ibreg: 359 - irdma_rt_deinit_hw(iwdev); 360 - err_rt_init: 361 - irdma_ctrl_deinit_hw(rf); 362 - err_ctrl_init: 363 - irdma_deinit_interrupts(rf, cdev_info); 364 - err_init_interrupts: 365 - kfree(iwdev->rf); 366 - ib_dealloc_device(&iwdev->ibdev); 367 - 368 - return err; 369 - } 370 - 371 - static const struct auxiliary_device_id irdma_auxiliary_id_table[] = { 372 - {.name = "ice.iwarp", }, 373 - {.name = "ice.roce", }, 374 - {}, 375 - }; 376 - 377 - MODULE_DEVICE_TABLE(auxiliary, irdma_auxiliary_id_table); 378 - 379 - static struct iidc_rdma_core_auxiliary_drv irdma_auxiliary_drv = { 380 - .adrv = { 381 - .id_table = irdma_auxiliary_id_table, 382 - .probe = irdma_probe, 383 - .remove = irdma_remove, 384 - }, 385 - .event_handler = irdma_iidc_event_handler, 386 - }; 387 48 388 49 static int __init irdma_init_module(void) 389 50 { ··· 57 396 return ret; 58 397 } 59 398 60 - ret = auxiliary_driver_register(&irdma_auxiliary_drv.adrv); 399 + ret = auxiliary_driver_register(&icrdma_core_auxiliary_drv.adrv); 61 400 if (ret) { 62 401 auxiliary_driver_unregister(&i40iw_auxiliary_drv); 63 - pr_err("Failed irdma auxiliary_driver_register() ret=%d\n", 402 + pr_err("Failed icrdma(gen_2) auxiliary_driver_register() ret=%d\n", 64 403 ret); 65 404 return ret; 66 405 } ··· 73 412 static void __exit irdma_exit_module(void) 74 413 { 75 414 irdma_unregister_notifiers(); 76 - auxiliary_driver_unregister(&irdma_auxiliary_drv.adrv); 415 + auxiliary_driver_unregister(&icrdma_core_auxiliary_drv.adrv); 77 416 auxiliary_driver_unregister(&i40iw_auxiliary_drv); 78 417 } 79 418
+4 -3
drivers/infiniband/hw/irdma/main.h
··· 30 30 #endif 31 31 #include <linux/auxiliary_bus.h> 32 32 #include <linux/net/intel/iidc_rdma.h> 33 - #include <linux/net/intel/iidc_rdma_ice.h> 34 33 #include <rdma/ib_smi.h> 35 34 #include <rdma/ib_verbs.h> 36 35 #include <rdma/ib_pack.h> ··· 53 54 #include "puda.h" 54 55 55 56 extern struct auxiliary_driver i40iw_auxiliary_drv; 57 + extern struct iidc_rdma_core_auxiliary_drv icrdma_core_auxiliary_drv; 56 58 57 59 #define IRDMA_FW_VER_DEFAULT 2 58 60 #define IRDMA_HW_VER 2 ··· 331 331 void *back_fcn; 332 332 struct irdma_gen_ops gen_ops; 333 333 struct irdma_device *iwdev; 334 + DECLARE_HASHTABLE(ah_hash_tbl, 8); 335 + struct mutex ah_tbl_lock; /* protect AH hash table access */ 334 336 }; 335 337 336 338 struct irdma_device { ··· 342 340 struct workqueue_struct *cleanup_wq; 343 341 struct irdma_sc_vsi vsi; 344 342 struct irdma_cm_core cm_core; 345 - DECLARE_HASHTABLE(ah_hash_tbl, 8); 346 - struct mutex ah_tbl_lock; /* protect AH hash table access */ 347 343 u32 roce_cwnd; 348 344 u32 roce_ackcreds; 349 345 u32 vendor_id; ··· 557 557 void *ptr); 558 558 void irdma_add_ip(struct irdma_device *iwdev); 559 559 void cqp_compl_worker(struct work_struct *work); 560 + void irdma_log_invalid_mtu(u16 mtu, struct irdma_sc_dev *dev); 560 561 #endif /* IRDMA_MAIN_H */
+8 -8
drivers/infiniband/hw/irdma/verbs.c
··· 4539 4539 new_ah->sc_ah.ah_info.dest_ip_addr[2] ^ 4540 4540 new_ah->sc_ah.ah_info.dest_ip_addr[3]; 4541 4541 4542 - hash_for_each_possible(iwdev->ah_hash_tbl, ah, list, key) { 4542 + hash_for_each_possible(iwdev->rf->ah_hash_tbl, ah, list, key) { 4543 4543 /* Set ah_valid and ah_id the same so memcmp can work */ 4544 4544 new_ah->sc_ah.ah_info.ah_idx = ah->sc_ah.ah_info.ah_idx; 4545 4545 new_ah->sc_ah.ah_info.ah_valid = ah->sc_ah.ah_info.ah_valid; ··· 4565 4565 struct irdma_ah *ah = to_iwah(ibah); 4566 4566 4567 4567 if ((ah_flags & RDMA_DESTROY_AH_SLEEPABLE) && ah->parent_ah) { 4568 - mutex_lock(&iwdev->ah_tbl_lock); 4568 + mutex_lock(&iwdev->rf->ah_tbl_lock); 4569 4569 if (!refcount_dec_and_test(&ah->parent_ah->refcnt)) { 4570 - mutex_unlock(&iwdev->ah_tbl_lock); 4570 + mutex_unlock(&iwdev->rf->ah_tbl_lock); 4571 4571 return 0; 4572 4572 } 4573 4573 hash_del(&ah->parent_ah->list); 4574 4574 kfree(ah->parent_ah); 4575 - mutex_unlock(&iwdev->ah_tbl_lock); 4575 + mutex_unlock(&iwdev->rf->ah_tbl_lock); 4576 4576 } 4577 4577 4578 4578 irdma_ah_cqp_op(iwdev->rf, &ah->sc_ah, IRDMA_OP_AH_DESTROY, ··· 4609 4609 err = irdma_setup_ah(ibah, attr); 4610 4610 if (err) 4611 4611 return err; 4612 - mutex_lock(&iwdev->ah_tbl_lock); 4612 + mutex_lock(&iwdev->rf->ah_tbl_lock); 4613 4613 if (!irdma_ah_exists(iwdev, ah)) { 4614 4614 err = irdma_create_hw_ah(iwdev, ah, true); 4615 4615 if (err) { 4616 - mutex_unlock(&iwdev->ah_tbl_lock); 4616 + mutex_unlock(&iwdev->rf->ah_tbl_lock); 4617 4617 return err; 4618 4618 } 4619 4619 /* Add new AH to list */ ··· 4625 4625 parent_ah->sc_ah.ah_info.dest_ip_addr[3]; 4626 4626 4627 4627 ah->parent_ah = parent_ah; 4628 - hash_add(iwdev->ah_hash_tbl, &parent_ah->list, key); 4628 + hash_add(iwdev->rf->ah_hash_tbl, &parent_ah->list, key); 4629 4629 refcount_set(&parent_ah->refcnt, 1); 4630 4630 } 4631 4631 } 4632 - mutex_unlock(&iwdev->ah_tbl_lock); 4632 + mutex_unlock(&iwdev->rf->ah_tbl_lock); 4633 4633 4634 4634 uresp.ah_id = ah->sc_ah.ah_info.ah_idx; 4635 4635 err = ib_copy_to_udata(udata, &uresp, min(sizeof(uresp), udata->outlen));