1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Huawei HiNIC PCI Express Linux driver 4 * Copyright(c) 2017 Huawei Technologies Co., Ltd 5 */ 6 7 #include <linux/types.h> 8 #include <linux/netdevice.h> 9 #include <linux/etherdevice.h> 10 #include <linux/if_vlan.h> 11 #include <linux/pci.h> 12 #include <linux/device.h> 13 #include <linux/errno.h> 14 15 #include "hinic_hw_if.h" 16 #include "hinic_hw_dev.h" 17 #include "hinic_port.h" 18 #include "hinic_dev.h" 19 20 #define HINIC_MIN_MTU_SIZE 256 21 #define HINIC_MAX_JUMBO_FRAME_SIZE 15872 22 23 enum mac_op { 24 MAC_DEL, 25 MAC_SET, 26 }; 27 28 /** 29 * change_mac - change(add or delete) mac address 30 * @nic_dev: nic device 31 * @addr: mac address 32 * @vlan_id: vlan number to set with the mac 33 * @op: add or delete the mac 34 * 35 * Return 0 - Success, negative - Failure 36 **/ 37 static int change_mac(struct hinic_dev *nic_dev, const u8 *addr, 38 u16 vlan_id, enum mac_op op) 39 { 40 struct hinic_hwdev *hwdev = nic_dev->hwdev; 41 struct hinic_port_mac_cmd port_mac_cmd; 42 struct hinic_hwif *hwif = hwdev->hwif; 43 u16 out_size = sizeof(port_mac_cmd); 44 struct pci_dev *pdev = hwif->pdev; 45 enum hinic_port_cmd cmd; 46 int err; 47 48 if (op == MAC_SET) 49 cmd = HINIC_PORT_CMD_SET_MAC; 50 else 51 cmd = HINIC_PORT_CMD_DEL_MAC; 52 53 port_mac_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwif); 54 port_mac_cmd.vlan_id = vlan_id; 55 memcpy(port_mac_cmd.mac, addr, ETH_ALEN); 56 57 err = hinic_port_msg_cmd(hwdev, cmd, &port_mac_cmd, 58 sizeof(port_mac_cmd), 59 &port_mac_cmd, &out_size); 60 if (err || out_size != sizeof(port_mac_cmd) || 61 (port_mac_cmd.status && 62 port_mac_cmd.status != HINIC_PF_SET_VF_ALREADY && 63 port_mac_cmd.status != HINIC_MGMT_STATUS_EXIST)) { 64 dev_err(&pdev->dev, "Failed to change MAC, ret = %d\n", 65 port_mac_cmd.status); 66 return -EFAULT; 67 } 68 69 if (port_mac_cmd.status == HINIC_PF_SET_VF_ALREADY) { 70 dev_warn(&pdev->dev, "PF has already set VF mac, ignore %s operation\n", 71 (op == MAC_SET) ? "set" : "del"); 72 return HINIC_PF_SET_VF_ALREADY; 73 } 74 75 if (cmd == HINIC_PORT_CMD_SET_MAC && port_mac_cmd.status == 76 HINIC_MGMT_STATUS_EXIST) 77 dev_warn(&pdev->dev, "MAC is repeated, ignore set operation\n"); 78 79 return 0; 80 } 81 82 /** 83 * hinic_port_add_mac - add mac address 84 * @nic_dev: nic device 85 * @addr: mac address 86 * @vlan_id: vlan number to set with the mac 87 * 88 * Return 0 - Success, negative - Failure 89 **/ 90 int hinic_port_add_mac(struct hinic_dev *nic_dev, 91 const u8 *addr, u16 vlan_id) 92 { 93 return change_mac(nic_dev, addr, vlan_id, MAC_SET); 94 } 95 96 /** 97 * hinic_port_del_mac - remove mac address 98 * @nic_dev: nic device 99 * @addr: mac address 100 * @vlan_id: vlan number that is connected to the mac 101 * 102 * Return 0 - Success, negative - Failure 103 **/ 104 int hinic_port_del_mac(struct hinic_dev *nic_dev, const u8 *addr, 105 u16 vlan_id) 106 { 107 return change_mac(nic_dev, addr, vlan_id, MAC_DEL); 108 } 109 110 /** 111 * hinic_port_get_mac - get the mac address of the nic device 112 * @nic_dev: nic device 113 * @addr: returned mac address 114 * 115 * Return 0 - Success, negative - Failure 116 **/ 117 int hinic_port_get_mac(struct hinic_dev *nic_dev, u8 *addr) 118 { 119 struct hinic_hwdev *hwdev = nic_dev->hwdev; 120 struct hinic_port_mac_cmd port_mac_cmd; 121 struct hinic_hwif *hwif = hwdev->hwif; 122 u16 out_size = sizeof(port_mac_cmd); 123 struct pci_dev *pdev = hwif->pdev; 124 int err; 125 126 port_mac_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwif); 127 128 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_MAC, 129 &port_mac_cmd, sizeof(port_mac_cmd), 130 &port_mac_cmd, &out_size); 131 if (err || (out_size != sizeof(port_mac_cmd)) || port_mac_cmd.status) { 132 dev_err(&pdev->dev, "Failed to get mac, ret = %d\n", 133 port_mac_cmd.status); 134 return -EFAULT; 135 } 136 137 memcpy(addr, port_mac_cmd.mac, ETH_ALEN); 138 return 0; 139 } 140 141 /** 142 * hinic_port_set_mtu - set mtu 143 * @nic_dev: nic device 144 * @new_mtu: new mtu 145 * 146 * Return 0 - Success, negative - Failure 147 **/ 148 int hinic_port_set_mtu(struct hinic_dev *nic_dev, int new_mtu) 149 { 150 struct net_device *netdev = nic_dev->netdev; 151 struct hinic_hwdev *hwdev = nic_dev->hwdev; 152 struct hinic_port_mtu_cmd port_mtu_cmd; 153 struct hinic_hwif *hwif = hwdev->hwif; 154 u16 out_size = sizeof(port_mtu_cmd); 155 struct pci_dev *pdev = hwif->pdev; 156 int err, max_frame; 157 158 if (new_mtu < HINIC_MIN_MTU_SIZE) { 159 netif_err(nic_dev, drv, netdev, "mtu < MIN MTU size"); 160 return -EINVAL; 161 } 162 163 max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; 164 if (max_frame > HINIC_MAX_JUMBO_FRAME_SIZE) { 165 netif_err(nic_dev, drv, netdev, "mtu > MAX MTU size"); 166 return -EINVAL; 167 } 168 169 port_mtu_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwif); 170 port_mtu_cmd.mtu = new_mtu; 171 172 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_CHANGE_MTU, 173 &port_mtu_cmd, sizeof(port_mtu_cmd), 174 &port_mtu_cmd, &out_size); 175 if (err || (out_size != sizeof(port_mtu_cmd)) || port_mtu_cmd.status) { 176 dev_err(&pdev->dev, "Failed to set mtu, ret = %d\n", 177 port_mtu_cmd.status); 178 return -EFAULT; 179 } 180 181 return 0; 182 } 183 184 /** 185 * hinic_port_add_vlan - add vlan to the nic device 186 * @nic_dev: nic device 187 * @vlan_id: the vlan number to add 188 * 189 * Return 0 - Success, negative - Failure 190 **/ 191 int hinic_port_add_vlan(struct hinic_dev *nic_dev, u16 vlan_id) 192 { 193 struct hinic_hwdev *hwdev = nic_dev->hwdev; 194 struct hinic_port_vlan_cmd port_vlan_cmd; 195 196 port_vlan_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwdev->hwif); 197 port_vlan_cmd.vlan_id = vlan_id; 198 199 return hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_ADD_VLAN, 200 &port_vlan_cmd, sizeof(port_vlan_cmd), 201 NULL, NULL); 202 } 203 204 /** 205 * hinic_port_del_vlan - delete vlan from the nic device 206 * @nic_dev: nic device 207 * @vlan_id: the vlan number to delete 208 * 209 * Return 0 - Success, negative - Failure 210 **/ 211 int hinic_port_del_vlan(struct hinic_dev *nic_dev, u16 vlan_id) 212 { 213 struct hinic_hwdev *hwdev = nic_dev->hwdev; 214 struct hinic_port_vlan_cmd port_vlan_cmd; 215 216 port_vlan_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwdev->hwif); 217 port_vlan_cmd.vlan_id = vlan_id; 218 219 return hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_DEL_VLAN, 220 &port_vlan_cmd, sizeof(port_vlan_cmd), 221 NULL, NULL); 222 } 223 224 /** 225 * hinic_port_set_rx_mode - set rx mode in the nic device 226 * @nic_dev: nic device 227 * @rx_mode: the rx mode to set 228 * 229 * Return 0 - Success, negative - Failure 230 **/ 231 int hinic_port_set_rx_mode(struct hinic_dev *nic_dev, u32 rx_mode) 232 { 233 struct hinic_hwdev *hwdev = nic_dev->hwdev; 234 struct hinic_port_rx_mode_cmd rx_mode_cmd; 235 236 rx_mode_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwdev->hwif); 237 rx_mode_cmd.rx_mode = rx_mode; 238 239 return hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RX_MODE, 240 &rx_mode_cmd, sizeof(rx_mode_cmd), 241 NULL, NULL); 242 } 243 244 /** 245 * hinic_port_link_state - get the link state 246 * @nic_dev: nic device 247 * @link_state: the returned link state 248 * 249 * Return 0 - Success, negative - Failure 250 **/ 251 int hinic_port_link_state(struct hinic_dev *nic_dev, 252 enum hinic_port_link_state *link_state) 253 { 254 struct hinic_hwdev *hwdev = nic_dev->hwdev; 255 struct hinic_hwif *hwif = hwdev->hwif; 256 struct hinic_port_link_cmd link_cmd; 257 struct pci_dev *pdev = hwif->pdev; 258 u16 out_size = sizeof(link_cmd); 259 int err; 260 261 link_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwif); 262 263 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_LINK_STATE, 264 &link_cmd, sizeof(link_cmd), 265 &link_cmd, &out_size); 266 if (err || (out_size != sizeof(link_cmd)) || link_cmd.status) { 267 dev_err(&pdev->dev, "Failed to get link state, ret = %d\n", 268 link_cmd.status); 269 return -EINVAL; 270 } 271 272 *link_state = link_cmd.state; 273 return 0; 274 } 275 276 /** 277 * hinic_port_set_state - set port state 278 * @nic_dev: nic device 279 * @state: the state to set 280 * 281 * Return 0 - Success, negative - Failure 282 **/ 283 int hinic_port_set_state(struct hinic_dev *nic_dev, enum hinic_port_state state) 284 { 285 struct hinic_hwdev *hwdev = nic_dev->hwdev; 286 struct hinic_port_state_cmd port_state; 287 struct hinic_hwif *hwif = hwdev->hwif; 288 struct pci_dev *pdev = hwif->pdev; 289 u16 out_size = sizeof(port_state); 290 int err; 291 292 if (HINIC_IS_VF(hwdev->hwif)) 293 return 0; 294 295 port_state.state = state; 296 297 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_PORT_STATE, 298 &port_state, sizeof(port_state), 299 &port_state, &out_size); 300 if (err || (out_size != sizeof(port_state)) || port_state.status) { 301 dev_err(&pdev->dev, "Failed to set port state, ret = %d\n", 302 port_state.status); 303 return -EFAULT; 304 } 305 306 return 0; 307 } 308 309 /** 310 * hinic_port_set_func_state- set func device state 311 * @nic_dev: nic device 312 * @state: the state to set 313 * 314 * Return 0 - Success, negative - Failure 315 **/ 316 int hinic_port_set_func_state(struct hinic_dev *nic_dev, 317 enum hinic_func_port_state state) 318 { 319 struct hinic_port_func_state_cmd func_state; 320 struct hinic_hwdev *hwdev = nic_dev->hwdev; 321 struct hinic_hwif *hwif = hwdev->hwif; 322 struct pci_dev *pdev = hwif->pdev; 323 u16 out_size = sizeof(func_state); 324 int err; 325 326 func_state.func_idx = HINIC_HWIF_FUNC_IDX(hwif); 327 func_state.state = state; 328 329 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_FUNC_STATE, 330 &func_state, sizeof(func_state), 331 &func_state, &out_size); 332 if (err || (out_size != sizeof(func_state)) || func_state.status) { 333 dev_err(&pdev->dev, "Failed to set port func state, ret = %d\n", 334 func_state.status); 335 return -EFAULT; 336 } 337 338 return 0; 339 } 340 341 /** 342 * hinic_port_get_cap - get port capabilities 343 * @nic_dev: nic device 344 * @port_cap: returned port capabilities 345 * 346 * Return 0 - Success, negative - Failure 347 **/ 348 int hinic_port_get_cap(struct hinic_dev *nic_dev, 349 struct hinic_port_cap *port_cap) 350 { 351 struct hinic_hwdev *hwdev = nic_dev->hwdev; 352 struct hinic_hwif *hwif = hwdev->hwif; 353 struct pci_dev *pdev = hwif->pdev; 354 u16 out_size = sizeof(*port_cap); 355 int err; 356 357 port_cap->func_idx = HINIC_HWIF_FUNC_IDX(hwif); 358 359 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_CAP, 360 port_cap, sizeof(*port_cap), 361 port_cap, &out_size); 362 if (err || (out_size != sizeof(*port_cap)) || port_cap->status) { 363 dev_err(&pdev->dev, 364 "Failed to get port capabilities, ret = %d\n", 365 port_cap->status); 366 return -EINVAL; 367 } 368 369 return 0; 370 } 371 372 /** 373 * hinic_port_set_tso - set port tso configuration 374 * @nic_dev: nic device 375 * @state: the tso state to set 376 * 377 * Return 0 - Success, negative - Failure 378 **/ 379 int hinic_port_set_tso(struct hinic_dev *nic_dev, enum hinic_tso_state state) 380 { 381 struct hinic_hwdev *hwdev = nic_dev->hwdev; 382 struct hinic_hwif *hwif = hwdev->hwif; 383 struct hinic_tso_config tso_cfg = {0}; 384 struct pci_dev *pdev = hwif->pdev; 385 u16 out_size = sizeof(tso_cfg); 386 int err; 387 388 tso_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif); 389 tso_cfg.tso_en = state; 390 391 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_TSO, 392 &tso_cfg, sizeof(tso_cfg), 393 &tso_cfg, &out_size); 394 if (err || out_size != sizeof(tso_cfg) || tso_cfg.status) { 395 dev_err(&pdev->dev, 396 "Failed to set port tso, ret = %d\n", 397 tso_cfg.status); 398 return -EINVAL; 399 } 400 401 return 0; 402 } 403 404 int hinic_set_rx_csum_offload(struct hinic_dev *nic_dev, u32 en) 405 { 406 struct hinic_checksum_offload rx_csum_cfg = {0}; 407 struct hinic_hwdev *hwdev = nic_dev->hwdev; 408 u16 out_size = sizeof(rx_csum_cfg); 409 struct hinic_hwif *hwif; 410 struct pci_dev *pdev; 411 int err; 412 413 if (!hwdev) 414 return -EINVAL; 415 416 hwif = hwdev->hwif; 417 pdev = hwif->pdev; 418 rx_csum_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif); 419 rx_csum_cfg.rx_csum_offload = en; 420 421 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RX_CSUM, 422 &rx_csum_cfg, sizeof(rx_csum_cfg), 423 &rx_csum_cfg, &out_size); 424 if (err || !out_size || rx_csum_cfg.status) { 425 dev_err(&pdev->dev, 426 "Failed to set rx csum offload, ret = %d\n", 427 rx_csum_cfg.status); 428 return -EINVAL; 429 } 430 431 return 0; 432 } 433 434 int hinic_set_rx_vlan_offload(struct hinic_dev *nic_dev, u8 en) 435 { 436 struct hinic_hwdev *hwdev = nic_dev->hwdev; 437 struct hinic_vlan_cfg vlan_cfg; 438 struct hinic_hwif *hwif; 439 struct pci_dev *pdev; 440 u16 out_size; 441 int err; 442 443 if (!hwdev) 444 return -EINVAL; 445 446 out_size = sizeof(vlan_cfg); 447 hwif = hwdev->hwif; 448 pdev = hwif->pdev; 449 vlan_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif); 450 vlan_cfg.vlan_rx_offload = en; 451 452 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RX_VLAN_OFFLOAD, 453 &vlan_cfg, sizeof(vlan_cfg), 454 &vlan_cfg, &out_size); 455 if (err || !out_size || vlan_cfg.status) { 456 dev_err(&pdev->dev, 457 "Failed to set rx vlan offload, err: %d, status: 0x%x, out size: 0x%x\n", 458 err, vlan_cfg.status, out_size); 459 return -EINVAL; 460 } 461 462 return 0; 463 } 464 465 int hinic_set_max_qnum(struct hinic_dev *nic_dev, u8 num_rqs) 466 { 467 struct hinic_hwdev *hwdev = nic_dev->hwdev; 468 struct hinic_hwif *hwif = hwdev->hwif; 469 struct hinic_rq_num rq_num = { 0 }; 470 struct pci_dev *pdev = hwif->pdev; 471 u16 out_size = sizeof(rq_num); 472 int err; 473 474 rq_num.func_id = HINIC_HWIF_FUNC_IDX(hwif); 475 rq_num.num_rqs = num_rqs; 476 rq_num.rq_depth = ilog2(nic_dev->rq_depth); 477 478 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RQ_IQ_MAP, 479 &rq_num, sizeof(rq_num), 480 &rq_num, &out_size); 481 if (err || !out_size || rq_num.status) { 482 dev_err(&pdev->dev, 483 "Failed to rxq number, ret = %d\n", 484 rq_num.status); 485 return -EINVAL; 486 } 487 488 return 0; 489 } 490 491 static int hinic_set_rx_lro(struct hinic_dev *nic_dev, u8 ipv4_en, u8 ipv6_en, 492 u8 max_wqe_num) 493 { 494 struct hinic_hwdev *hwdev = nic_dev->hwdev; 495 struct hinic_lro_config lro_cfg = { 0 }; 496 struct hinic_hwif *hwif = hwdev->hwif; 497 struct pci_dev *pdev = hwif->pdev; 498 u16 out_size = sizeof(lro_cfg); 499 int err; 500 501 lro_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif); 502 lro_cfg.lro_ipv4_en = ipv4_en; 503 lro_cfg.lro_ipv6_en = ipv6_en; 504 lro_cfg.lro_max_wqe_num = max_wqe_num; 505 506 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LRO, 507 &lro_cfg, sizeof(lro_cfg), 508 &lro_cfg, &out_size); 509 if (err || !out_size || lro_cfg.status) { 510 dev_err(&pdev->dev, 511 "Failed to set lro offload, ret = %d\n", 512 lro_cfg.status); 513 return -EINVAL; 514 } 515 516 return 0; 517 } 518 519 static int hinic_set_rx_lro_timer(struct hinic_dev *nic_dev, u32 timer_value) 520 { 521 struct hinic_hwdev *hwdev = nic_dev->hwdev; 522 struct hinic_lro_timer lro_timer = { 0 }; 523 struct hinic_hwif *hwif = hwdev->hwif; 524 struct pci_dev *pdev = hwif->pdev; 525 u16 out_size = sizeof(lro_timer); 526 int err; 527 528 lro_timer.status = 0; 529 lro_timer.type = 0; 530 lro_timer.enable = 1; 531 lro_timer.timer = timer_value; 532 533 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LRO_TIMER, 534 &lro_timer, sizeof(lro_timer), 535 &lro_timer, &out_size); 536 if (lro_timer.status == 0xFF) { 537 /* For this case, we think status (0xFF) is OK */ 538 lro_timer.status = 0; 539 dev_dbg(&pdev->dev, 540 "Set lro timer not supported by the current FW version, it will be 1ms default\n"); 541 } 542 543 if (err || !out_size || lro_timer.status) { 544 dev_err(&pdev->dev, 545 "Failed to set lro timer, ret = %d\n", 546 lro_timer.status); 547 548 return -EINVAL; 549 } 550 551 return 0; 552 } 553 554 int hinic_set_rx_lro_state(struct hinic_dev *nic_dev, u8 lro_en, 555 u32 lro_timer, u32 wqe_num) 556 { 557 struct hinic_hwdev *hwdev = nic_dev->hwdev; 558 u8 ipv4_en; 559 u8 ipv6_en; 560 int err; 561 562 if (!hwdev) 563 return -EINVAL; 564 565 ipv4_en = lro_en ? 1 : 0; 566 ipv6_en = lro_en ? 1 : 0; 567 568 err = hinic_set_rx_lro(nic_dev, ipv4_en, ipv6_en, (u8)wqe_num); 569 if (err) 570 return err; 571 572 if (HINIC_IS_VF(nic_dev->hwdev->hwif)) 573 return 0; 574 575 err = hinic_set_rx_lro_timer(nic_dev, lro_timer); 576 if (err) 577 return err; 578 579 return 0; 580 } 581 582 int hinic_rss_set_indir_tbl(struct hinic_dev *nic_dev, u32 tmpl_idx, 583 const u32 *indir_table) 584 { 585 struct hinic_rss_indirect_tbl *indir_tbl; 586 struct hinic_func_to_io *func_to_io; 587 struct hinic_cmdq_buf cmd_buf; 588 struct hinic_hwdev *hwdev; 589 struct hinic_hwif *hwif; 590 struct pci_dev *pdev; 591 u32 indir_size; 592 u64 out_param; 593 int err, i; 594 u32 *temp; 595 596 hwdev = nic_dev->hwdev; 597 func_to_io = &hwdev->func_to_io; 598 hwif = hwdev->hwif; 599 pdev = hwif->pdev; 600 601 err = hinic_alloc_cmdq_buf(&func_to_io->cmdqs, &cmd_buf); 602 if (err) { 603 dev_err(&pdev->dev, "Failed to allocate cmdq buf\n"); 604 return err; 605 } 606 607 cmd_buf.size = sizeof(*indir_tbl); 608 609 indir_tbl = cmd_buf.buf; 610 indir_tbl->group_index = cpu_to_be32(tmpl_idx); 611 612 for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++) { 613 indir_tbl->entry[i] = indir_table[i]; 614 615 if (0x3 == (i & 0x3)) { 616 temp = (u32 *)&indir_tbl->entry[i - 3]; 617 *temp = cpu_to_be32(*temp); 618 } 619 } 620 621 /* cfg the rss indirect table by command queue */ 622 indir_size = HINIC_RSS_INDIR_SIZE / 2; 623 indir_tbl->offset = 0; 624 indir_tbl->size = cpu_to_be32(indir_size); 625 626 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC, 627 HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE, 628 &cmd_buf, &out_param); 629 if (err || out_param != 0) { 630 dev_err(&pdev->dev, "Failed to set rss indir table\n"); 631 err = -EFAULT; 632 goto free_buf; 633 } 634 635 indir_tbl->offset = cpu_to_be32(indir_size); 636 indir_tbl->size = cpu_to_be32(indir_size); 637 memcpy(&indir_tbl->entry[0], &indir_tbl->entry[indir_size], indir_size); 638 639 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC, 640 HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE, 641 &cmd_buf, &out_param); 642 if (err || out_param != 0) { 643 dev_err(&pdev->dev, "Failed to set rss indir table\n"); 644 err = -EFAULT; 645 } 646 647 free_buf: 648 hinic_free_cmdq_buf(&func_to_io->cmdqs, &cmd_buf); 649 650 return err; 651 } 652 653 int hinic_rss_get_indir_tbl(struct hinic_dev *nic_dev, u32 tmpl_idx, 654 u32 *indir_table) 655 { 656 struct hinic_rss_indir_table rss_cfg = { 0 }; 657 struct hinic_hwdev *hwdev = nic_dev->hwdev; 658 struct hinic_hwif *hwif = hwdev->hwif; 659 struct pci_dev *pdev = hwif->pdev; 660 u16 out_size = sizeof(rss_cfg); 661 int err = 0, i; 662 663 rss_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif); 664 rss_cfg.template_id = tmpl_idx; 665 666 err = hinic_port_msg_cmd(hwdev, 667 HINIC_PORT_CMD_GET_RSS_TEMPLATE_INDIR_TBL, 668 &rss_cfg, sizeof(rss_cfg), &rss_cfg, 669 &out_size); 670 if (err || !out_size || rss_cfg.status) { 671 dev_err(&pdev->dev, "Failed to get indir table, err: %d, status: 0x%x, out size: 0x%x\n", 672 err, rss_cfg.status, out_size); 673 return -EINVAL; 674 } 675 676 hinic_be32_to_cpu(rss_cfg.indir, HINIC_RSS_INDIR_SIZE); 677 for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++) 678 indir_table[i] = rss_cfg.indir[i]; 679 680 return 0; 681 } 682 683 int hinic_set_rss_type(struct hinic_dev *nic_dev, u32 tmpl_idx, 684 struct hinic_rss_type rss_type) 685 { 686 struct hinic_rss_context_tbl *ctx_tbl; 687 struct hinic_func_to_io *func_to_io; 688 struct hinic_cmdq_buf cmd_buf; 689 struct hinic_hwdev *hwdev; 690 struct hinic_hwif *hwif; 691 struct pci_dev *pdev; 692 u64 out_param; 693 u32 ctx = 0; 694 int err; 695 696 hwdev = nic_dev->hwdev; 697 func_to_io = &hwdev->func_to_io; 698 hwif = hwdev->hwif; 699 pdev = hwif->pdev; 700 701 err = hinic_alloc_cmdq_buf(&func_to_io->cmdqs, &cmd_buf); 702 if (err) { 703 dev_err(&pdev->dev, "Failed to allocate cmd buf\n"); 704 return -ENOMEM; 705 } 706 707 ctx |= HINIC_RSS_TYPE_SET(1, VALID) | 708 HINIC_RSS_TYPE_SET(rss_type.ipv4, IPV4) | 709 HINIC_RSS_TYPE_SET(rss_type.ipv6, IPV6) | 710 HINIC_RSS_TYPE_SET(rss_type.ipv6_ext, IPV6_EXT) | 711 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv4, TCP_IPV4) | 712 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6, TCP_IPV6) | 713 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6_ext, TCP_IPV6_EXT) | 714 HINIC_RSS_TYPE_SET(rss_type.udp_ipv4, UDP_IPV4) | 715 HINIC_RSS_TYPE_SET(rss_type.udp_ipv6, UDP_IPV6); 716 717 cmd_buf.size = sizeof(struct hinic_rss_context_tbl); 718 719 ctx_tbl = (struct hinic_rss_context_tbl *)cmd_buf.buf; 720 ctx_tbl->group_index = cpu_to_be32(tmpl_idx); 721 ctx_tbl->offset = 0; 722 ctx_tbl->size = sizeof(u32); 723 ctx_tbl->size = cpu_to_be32(ctx_tbl->size); 724 ctx_tbl->rsvd = 0; 725 ctx_tbl->ctx = cpu_to_be32(ctx); 726 727 /* cfg the rss context table by command queue */ 728 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC, 729 HINIC_UCODE_CMD_SET_RSS_CONTEXT_TABLE, 730 &cmd_buf, &out_param); 731 732 hinic_free_cmdq_buf(&func_to_io->cmdqs, &cmd_buf); 733 734 if (err || out_param != 0) { 735 dev_err(&pdev->dev, "Failed to set rss context table, err: %d\n", 736 err); 737 return -EFAULT; 738 } 739 740 return 0; 741 } 742 743 int hinic_get_rss_type(struct hinic_dev *nic_dev, u32 tmpl_idx, 744 struct hinic_rss_type *rss_type) 745 { 746 struct hinic_rss_context_table ctx_tbl = { 0 }; 747 struct hinic_hwdev *hwdev = nic_dev->hwdev; 748 u16 out_size = sizeof(ctx_tbl); 749 struct hinic_hwif *hwif; 750 struct pci_dev *pdev; 751 int err; 752 753 if (!hwdev || !rss_type) 754 return -EINVAL; 755 756 hwif = hwdev->hwif; 757 pdev = hwif->pdev; 758 759 ctx_tbl.func_id = HINIC_HWIF_FUNC_IDX(hwif); 760 ctx_tbl.template_id = tmpl_idx; 761 762 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_RSS_CTX_TBL, 763 &ctx_tbl, sizeof(ctx_tbl), 764 &ctx_tbl, &out_size); 765 if (err || !out_size || ctx_tbl.status) { 766 dev_err(&pdev->dev, "Failed to get hash type, err: %d, status: 0x%x, out size: 0x%x\n", 767 err, ctx_tbl.status, out_size); 768 return -EINVAL; 769 } 770 771 rss_type->ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV4); 772 rss_type->ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6); 773 rss_type->ipv6_ext = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6_EXT); 774 rss_type->tcp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV4); 775 rss_type->tcp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV6); 776 rss_type->tcp_ipv6_ext = HINIC_RSS_TYPE_GET(ctx_tbl.context, 777 TCP_IPV6_EXT); 778 rss_type->udp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV4); 779 rss_type->udp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV6); 780 781 return 0; 782 } 783 784 int hinic_rss_set_template_tbl(struct hinic_dev *nic_dev, u32 template_id, 785 const u8 *temp) 786 { 787 struct hinic_hwdev *hwdev = nic_dev->hwdev; 788 struct hinic_hwif *hwif = hwdev->hwif; 789 struct hinic_rss_key rss_key = { 0 }; 790 struct pci_dev *pdev = hwif->pdev; 791 u16 out_size = sizeof(rss_key); 792 int err; 793 794 rss_key.func_id = HINIC_HWIF_FUNC_IDX(hwif); 795 rss_key.template_id = template_id; 796 memcpy(rss_key.key, temp, HINIC_RSS_KEY_SIZE); 797 798 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RSS_TEMPLATE_TBL, 799 &rss_key, sizeof(rss_key), 800 &rss_key, &out_size); 801 if (err || !out_size || rss_key.status) { 802 dev_err(&pdev->dev, 803 "Failed to set rss hash key, err: %d, status: 0x%x, out size: 0x%x\n", 804 err, rss_key.status, out_size); 805 return -EINVAL; 806 } 807 808 return 0; 809 } 810 811 int hinic_rss_get_template_tbl(struct hinic_dev *nic_dev, u32 tmpl_idx, 812 u8 *temp) 813 { 814 struct hinic_rss_template_key temp_key = { 0 }; 815 struct hinic_hwdev *hwdev = nic_dev->hwdev; 816 u16 out_size = sizeof(temp_key); 817 struct hinic_hwif *hwif; 818 struct pci_dev *pdev; 819 int err; 820 821 if (!hwdev || !temp) 822 return -EINVAL; 823 824 hwif = hwdev->hwif; 825 pdev = hwif->pdev; 826 827 temp_key.func_id = HINIC_HWIF_FUNC_IDX(hwif); 828 temp_key.template_id = tmpl_idx; 829 830 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_RSS_TEMPLATE_TBL, 831 &temp_key, sizeof(temp_key), 832 &temp_key, &out_size); 833 if (err || !out_size || temp_key.status) { 834 dev_err(&pdev->dev, "Failed to set hash key, err: %d, status: 0x%x, out size: 0x%x\n", 835 err, temp_key.status, out_size); 836 return -EINVAL; 837 } 838 839 memcpy(temp, temp_key.key, HINIC_RSS_KEY_SIZE); 840 841 return 0; 842 } 843 844 int hinic_rss_set_hash_engine(struct hinic_dev *nic_dev, u8 template_id, 845 u8 type) 846 { 847 struct hinic_rss_engine_type rss_engine = { 0 }; 848 struct hinic_hwdev *hwdev = nic_dev->hwdev; 849 struct hinic_hwif *hwif = hwdev->hwif; 850 struct pci_dev *pdev = hwif->pdev; 851 u16 out_size = sizeof(rss_engine); 852 int err; 853 854 rss_engine.func_id = HINIC_HWIF_FUNC_IDX(hwif); 855 rss_engine.hash_engine = type; 856 rss_engine.template_id = template_id; 857 858 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RSS_HASH_ENGINE, 859 &rss_engine, sizeof(rss_engine), 860 &rss_engine, &out_size); 861 if (err || !out_size || rss_engine.status) { 862 dev_err(&pdev->dev, 863 "Failed to set hash engine, err: %d, status: 0x%x, out size: 0x%x\n", 864 err, rss_engine.status, out_size); 865 return -EINVAL; 866 } 867 868 return 0; 869 } 870 871 int hinic_rss_get_hash_engine(struct hinic_dev *nic_dev, u8 tmpl_idx, u8 *type) 872 { 873 struct hinic_rss_engine_type hash_type = { 0 }; 874 struct hinic_hwdev *hwdev = nic_dev->hwdev; 875 u16 out_size = sizeof(hash_type); 876 struct hinic_hwif *hwif; 877 struct pci_dev *pdev; 878 int err; 879 880 if (!hwdev || !type) 881 return -EINVAL; 882 883 hwif = hwdev->hwif; 884 pdev = hwif->pdev; 885 886 hash_type.func_id = HINIC_HWIF_FUNC_IDX(hwif); 887 hash_type.template_id = tmpl_idx; 888 889 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_RSS_HASH_ENGINE, 890 &hash_type, sizeof(hash_type), 891 &hash_type, &out_size); 892 if (err || !out_size || hash_type.status) { 893 dev_err(&pdev->dev, "Failed to get hash engine, err: %d, status: 0x%x, out size: 0x%x\n", 894 err, hash_type.status, out_size); 895 return -EINVAL; 896 } 897 898 *type = hash_type.hash_engine; 899 return 0; 900 } 901 902 int hinic_rss_cfg(struct hinic_dev *nic_dev, u8 rss_en, u8 template_id) 903 { 904 struct hinic_hwdev *hwdev = nic_dev->hwdev; 905 struct hinic_rss_config rss_cfg = { 0 }; 906 struct hinic_hwif *hwif = hwdev->hwif; 907 struct pci_dev *pdev = hwif->pdev; 908 u16 out_size = sizeof(rss_cfg); 909 int err; 910 911 rss_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif); 912 rss_cfg.rss_en = rss_en; 913 rss_cfg.template_id = template_id; 914 rss_cfg.rq_priority_number = 0; 915 916 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_RSS_CFG, 917 &rss_cfg, sizeof(rss_cfg), 918 &rss_cfg, &out_size); 919 if (err || !out_size || rss_cfg.status) { 920 dev_err(&pdev->dev, 921 "Failed to set rss cfg, err: %d, status: 0x%x, out size: 0x%x\n", 922 err, rss_cfg.status, out_size); 923 return -EINVAL; 924 } 925 926 return 0; 927 } 928 929 int hinic_rss_template_alloc(struct hinic_dev *nic_dev, u8 *tmpl_idx) 930 { 931 struct hinic_rss_template_mgmt template_mgmt = { 0 }; 932 struct hinic_hwdev *hwdev = nic_dev->hwdev; 933 struct hinic_hwif *hwif = hwdev->hwif; 934 u16 out_size = sizeof(template_mgmt); 935 struct pci_dev *pdev = hwif->pdev; 936 int err; 937 938 template_mgmt.func_id = HINIC_HWIF_FUNC_IDX(hwif); 939 template_mgmt.cmd = NIC_RSS_CMD_TEMP_ALLOC; 940 941 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR, 942 &template_mgmt, sizeof(template_mgmt), 943 &template_mgmt, &out_size); 944 if (err || !out_size || template_mgmt.status) { 945 dev_err(&pdev->dev, "Failed to alloc rss template, err: %d, status: 0x%x, out size: 0x%x\n", 946 err, template_mgmt.status, out_size); 947 return -EINVAL; 948 } 949 950 *tmpl_idx = template_mgmt.template_id; 951 952 return 0; 953 } 954 955 int hinic_rss_template_free(struct hinic_dev *nic_dev, u8 tmpl_idx) 956 { 957 struct hinic_rss_template_mgmt template_mgmt = { 0 }; 958 struct hinic_hwdev *hwdev = nic_dev->hwdev; 959 struct hinic_hwif *hwif = hwdev->hwif; 960 u16 out_size = sizeof(template_mgmt); 961 struct pci_dev *pdev = hwif->pdev; 962 int err; 963 964 template_mgmt.func_id = HINIC_HWIF_FUNC_IDX(hwif); 965 template_mgmt.template_id = tmpl_idx; 966 template_mgmt.cmd = NIC_RSS_CMD_TEMP_FREE; 967 968 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR, 969 &template_mgmt, sizeof(template_mgmt), 970 &template_mgmt, &out_size); 971 if (err || !out_size || template_mgmt.status) { 972 dev_err(&pdev->dev, "Failed to free rss template, err: %d, status: 0x%x, out size: 0x%x\n", 973 err, template_mgmt.status, out_size); 974 return -EINVAL; 975 } 976 977 return 0; 978 } 979 980 int hinic_get_vport_stats(struct hinic_dev *nic_dev, 981 struct hinic_vport_stats *stats) 982 { 983 struct hinic_cmd_vport_stats vport_stats = { 0 }; 984 struct hinic_port_stats_info stats_info = { 0 }; 985 struct hinic_hwdev *hwdev = nic_dev->hwdev; 986 struct hinic_hwif *hwif = hwdev->hwif; 987 u16 out_size = sizeof(vport_stats); 988 struct pci_dev *pdev = hwif->pdev; 989 int err; 990 991 stats_info.stats_version = HINIC_PORT_STATS_VERSION; 992 stats_info.func_id = HINIC_HWIF_FUNC_IDX(hwif); 993 stats_info.stats_size = sizeof(vport_stats); 994 995 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_VPORT_STAT, 996 &stats_info, sizeof(stats_info), 997 &vport_stats, &out_size); 998 if (err || !out_size || vport_stats.status) { 999 dev_err(&pdev->dev, 1000 "Failed to get function statistics, err: %d, status: 0x%x, out size: 0x%x\n", 1001 err, vport_stats.status, out_size); 1002 return -EFAULT; 1003 } 1004 1005 memcpy(stats, &vport_stats.stats, sizeof(*stats)); 1006 return 0; 1007 } 1008 1009 int hinic_get_phy_port_stats(struct hinic_dev *nic_dev, 1010 struct hinic_phy_port_stats *stats) 1011 { 1012 struct hinic_port_stats_info stats_info = { 0 }; 1013 struct hinic_hwdev *hwdev = nic_dev->hwdev; 1014 struct hinic_hwif *hwif = hwdev->hwif; 1015 struct hinic_port_stats *port_stats; 1016 u16 out_size = sizeof(*port_stats); 1017 struct pci_dev *pdev = hwif->pdev; 1018 int err; 1019 1020 port_stats = kzalloc(sizeof(*port_stats), GFP_KERNEL); 1021 if (!port_stats) 1022 return -ENOMEM; 1023 1024 stats_info.stats_version = HINIC_PORT_STATS_VERSION; 1025 stats_info.stats_size = sizeof(*port_stats); 1026 1027 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_PORT_STATISTICS, 1028 &stats_info, sizeof(stats_info), 1029 port_stats, &out_size); 1030 if (err || !out_size || port_stats->status) { 1031 dev_err(&pdev->dev, 1032 "Failed to get port statistics, err: %d, status: 0x%x, out size: 0x%x\n", 1033 err, port_stats->status, out_size); 1034 err = -EINVAL; 1035 goto out; 1036 } 1037 1038 memcpy(stats, &port_stats->stats, sizeof(*stats)); 1039 1040 out: 1041 kfree(port_stats); 1042 1043 return err; 1044 } 1045 1046 int hinic_get_mgmt_version(struct hinic_dev *nic_dev, u8 *mgmt_ver) 1047 { 1048 struct hinic_hwdev *hwdev = nic_dev->hwdev; 1049 struct hinic_version_info up_ver = {0}; 1050 u16 out_size = sizeof(up_ver); 1051 struct hinic_hwif *hwif; 1052 struct pci_dev *pdev; 1053 int err; 1054 1055 if (!hwdev) 1056 return -EINVAL; 1057 1058 hwif = hwdev->hwif; 1059 pdev = hwif->pdev; 1060 1061 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_MGMT_VERSION, 1062 &up_ver, sizeof(up_ver), &up_ver, 1063 &out_size); 1064 if (err || !out_size || up_ver.status) { 1065 dev_err(&pdev->dev, 1066 "Failed to get mgmt version, err: %d, status: 0x%x, out size: 0x%x\n", 1067 err, up_ver.status, out_size); 1068 return -EINVAL; 1069 } 1070 1071 snprintf(mgmt_ver, HINIC_MGMT_VERSION_MAX_LEN, "%s", up_ver.ver); 1072 1073 return 0; 1074 } 1075 1076 int hinic_get_link_mode(struct hinic_hwdev *hwdev, 1077 struct hinic_link_mode_cmd *link_mode) 1078 { 1079 u16 out_size; 1080 int err; 1081 1082 if (!hwdev || !link_mode) 1083 return -EINVAL; 1084 1085 out_size = sizeof(*link_mode); 1086 1087 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_LINK_MODE, 1088 link_mode, sizeof(*link_mode), 1089 link_mode, &out_size); 1090 if (err || !out_size || link_mode->status) { 1091 dev_err(&hwdev->hwif->pdev->dev, 1092 "Failed to get link mode, err: %d, status: 0x%x, out size: 0x%x\n", 1093 err, link_mode->status, out_size); 1094 return -EIO; 1095 } 1096 1097 return 0; 1098 } 1099 1100 int hinic_set_autoneg(struct hinic_hwdev *hwdev, bool enable) 1101 { 1102 struct hinic_set_autoneg_cmd autoneg = {0}; 1103 u16 out_size = sizeof(autoneg); 1104 int err; 1105 1106 if (!hwdev) 1107 return -EINVAL; 1108 1109 autoneg.func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif); 1110 autoneg.enable = enable; 1111 1112 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_AUTONEG, 1113 &autoneg, sizeof(autoneg), 1114 &autoneg, &out_size); 1115 if (err || !out_size || autoneg.status) { 1116 dev_err(&hwdev->hwif->pdev->dev, "Failed to %s autoneg, err: %d, status: 0x%x, out size: 0x%x\n", 1117 enable ? "enable" : "disable", err, autoneg.status, 1118 out_size); 1119 return -EIO; 1120 } 1121 1122 return 0; 1123 } 1124 1125 int hinic_set_speed(struct hinic_hwdev *hwdev, enum nic_speed_level speed) 1126 { 1127 struct hinic_speed_cmd speed_info = {0}; 1128 u16 out_size = sizeof(speed_info); 1129 int err; 1130 1131 if (!hwdev) 1132 return -EINVAL; 1133 1134 speed_info.func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif); 1135 speed_info.speed = speed; 1136 1137 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_SPEED, 1138 &speed_info, sizeof(speed_info), 1139 &speed_info, &out_size); 1140 if (err || !out_size || speed_info.status) { 1141 dev_err(&hwdev->hwif->pdev->dev, 1142 "Failed to set speed, err: %d, status: 0x%x, out size: 0x%x\n", 1143 err, speed_info.status, out_size); 1144 return -EIO; 1145 } 1146 1147 return 0; 1148 } 1149 1150 int hinic_set_link_settings(struct hinic_hwdev *hwdev, 1151 struct hinic_link_ksettings_info *info) 1152 { 1153 u16 out_size = sizeof(*info); 1154 int err; 1155 1156 err = hinic_hilink_msg_cmd(hwdev, HINIC_HILINK_CMD_SET_LINK_SETTINGS, 1157 info, sizeof(*info), info, &out_size); 1158 if ((info->status != HINIC_MGMT_CMD_UNSUPPORTED && 1159 info->status) || err || !out_size) { 1160 dev_err(&hwdev->hwif->pdev->dev, 1161 "Failed to set link settings, err: %d, status: 0x%x, out size: 0x%x\n", 1162 err, info->status, out_size); 1163 return -EFAULT; 1164 } 1165 1166 return info->status; 1167 } 1168 1169 int hinic_get_hw_pause_info(struct hinic_hwdev *hwdev, 1170 struct hinic_pause_config *pause_info) 1171 { 1172 u16 out_size = sizeof(*pause_info); 1173 int err; 1174 1175 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_PAUSE_INFO, 1176 pause_info, sizeof(*pause_info), 1177 pause_info, &out_size); 1178 if (err || !out_size || pause_info->status) { 1179 dev_err(&hwdev->hwif->pdev->dev, "Failed to get pause info, err: %d, status: 0x%x, out size: 0x%x\n", 1180 err, pause_info->status, out_size); 1181 return -EIO; 1182 } 1183 1184 return 0; 1185 } 1186 1187 int hinic_set_hw_pause_info(struct hinic_hwdev *hwdev, 1188 struct hinic_pause_config *pause_info) 1189 { 1190 u16 out_size = sizeof(*pause_info); 1191 int err; 1192 1193 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_PAUSE_INFO, 1194 pause_info, sizeof(*pause_info), 1195 pause_info, &out_size); 1196 if (err || !out_size || pause_info->status) { 1197 dev_err(&hwdev->hwif->pdev->dev, "Failed to set pause info, err: %d, status: 0x%x, out size: 0x%x\n", 1198 err, pause_info->status, out_size); 1199 return -EIO; 1200 } 1201 1202 return 0; 1203 } 1204