1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Huawei Technologies Co., Ltd
5 #include "hinic_compat.h"
6 #include "hinic_pmd_hwdev.h"
7 #include "hinic_pmd_hwif.h"
8 #include "hinic_pmd_eqs.h"
9 #include "hinic_pmd_wq.h"
10 #include "hinic_pmd_mgmt.h"
11 #include "hinic_pmd_cmdq.h"
12 #include "hinic_pmd_niccfg.h"
13 #include "hinic_pmd_mbox.h"
15 #define l2nic_msg_to_mgmt_sync(hwdev, cmd, buf_in, \
16 in_size, buf_out, out_size) \
17 hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_L2NIC, cmd, \
22 * hinic_init_function_table - Initialize function table.
25 * The hardware interface of a nic device.
27 * Receive buffer size.
31 * negative error value otherwise.
33 int hinic_init_function_table(void *hwdev, u16 rx_buf_sz)
35 struct hinic_function_table function_table;
36 u16 out_size = sizeof(function_table);
40 PMD_DRV_LOG(ERR, "Hwdev is NULL");
44 memset(&function_table, 0, sizeof(function_table));
45 function_table.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
46 function_table.func_id = hinic_global_func_id(hwdev);
47 function_table.mtu = 0x3FFF; /* default, max mtu */
48 function_table.rx_wqe_buf_size = rx_buf_sz;
50 err = hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_L2NIC,
51 HINIC_PORT_CMD_INIT_FUNC,
52 &function_table, sizeof(function_table),
53 &function_table, &out_size, 0);
54 if (err || function_table.mgmt_msg_head.status || !out_size) {
56 "Failed to init func table, err: %d, status: 0x%x, out size: 0x%x",
57 err, function_table.mgmt_msg_head.status, out_size);
65 * hinic_get_base_qpn - Get global queue number.
68 * The hardware interface of a nic device.
70 * Global queue number.
74 * negative error value otherwise.
76 int hinic_get_base_qpn(void *hwdev, u16 *global_qpn)
78 struct hinic_cmd_qpn cmd_qpn;
79 u16 out_size = sizeof(cmd_qpn);
82 if (!hwdev || !global_qpn) {
83 PMD_DRV_LOG(ERR, "Hwdev or global_qpn is NULL");
87 memset(&cmd_qpn, 0, sizeof(cmd_qpn));
88 cmd_qpn.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
89 cmd_qpn.func_id = hinic_global_func_id(hwdev);
91 err = hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_L2NIC,
92 HINIC_PORT_CMD_GET_GLOBAL_QPN,
93 &cmd_qpn, sizeof(cmd_qpn), &cmd_qpn,
95 if (err || !out_size || cmd_qpn.mgmt_msg_head.status) {
97 "Failed to get base qpn, err: %d, status: 0x%x, out size: 0x%x",
98 err, cmd_qpn.mgmt_msg_head.status, out_size);
102 *global_qpn = cmd_qpn.base_qpn;
108 * hinic_set_mac - Init mac_vlan table in NIC.
111 * The hardware interface of a nic device.
115 * Set 0 for mac_vlan table initialization.
117 * Global function id of NIC.
121 * negative error value otherwise.
123 int hinic_set_mac(void *hwdev, u8 *mac_addr, u16 vlan_id, u16 func_id)
125 struct hinic_port_mac_set mac_info;
126 u16 out_size = sizeof(mac_info);
129 if (!hwdev || !mac_addr) {
130 PMD_DRV_LOG(ERR, "Hwdev or mac_addr is NULL");
134 memset(&mac_info, 0, sizeof(mac_info));
135 mac_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
136 mac_info.func_id = func_id;
137 mac_info.vlan_id = vlan_id;
138 memmove(mac_info.mac, mac_addr, ETH_ALEN);
140 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_MAC, &mac_info,
141 sizeof(mac_info), &mac_info, &out_size);
142 if (err || !out_size || (mac_info.mgmt_msg_head.status &&
143 mac_info.mgmt_msg_head.status != HINIC_PF_SET_VF_ALREADY)) {
144 PMD_DRV_LOG(ERR, "Failed to set MAC, err: %d, status: 0x%x, out size: 0x%x",
145 err, mac_info.mgmt_msg_head.status, out_size);
149 if (mac_info.mgmt_msg_head.status == HINIC_PF_SET_VF_ALREADY) {
150 PMD_DRV_LOG(WARNING, "PF has already set vf mac, Ignore set operation.");
151 return HINIC_PF_SET_VF_ALREADY;
158 * hinic_del_mac - Uninit mac_vlan table in NIC.
161 * The hardware interface of a nic device.
165 * Set 0 for mac_vlan table initialization.
167 * Global function id of NIC.
171 * negative error value otherwise.
173 int hinic_del_mac(void *hwdev, u8 *mac_addr, u16 vlan_id, u16 func_id)
175 struct hinic_port_mac_set mac_info;
176 u16 out_size = sizeof(mac_info);
179 if (!hwdev || !mac_addr) {
180 PMD_DRV_LOG(ERR, "Hwdev or mac_addr is NULL");
184 if (vlan_id >= VLAN_N_VID) {
185 PMD_DRV_LOG(ERR, "Invalid VLAN number");
189 memset(&mac_info, 0, sizeof(mac_info));
190 mac_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
191 mac_info.func_id = func_id;
192 mac_info.vlan_id = vlan_id;
193 memmove(mac_info.mac, mac_addr, ETH_ALEN);
195 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_DEL_MAC, &mac_info,
196 sizeof(mac_info), &mac_info, &out_size);
197 if (err || !out_size || (mac_info.mgmt_msg_head.status &&
198 mac_info.mgmt_msg_head.status != HINIC_PF_SET_VF_ALREADY)) {
199 PMD_DRV_LOG(ERR, "Failed to delete MAC, err: %d, status: 0x%x, out size: 0x%x",
200 err, mac_info.mgmt_msg_head.status, out_size);
203 if (mac_info.mgmt_msg_head.status == HINIC_PF_SET_VF_ALREADY) {
204 PMD_DRV_LOG(WARNING, "PF has already set vf mac, Ignore delete operation.");
205 return HINIC_PF_SET_VF_ALREADY;
212 * hinic_get_default_mac - Get default mac address from hardware.
215 * The hardware interface of a nic device.
221 * negative error value otherwise.
223 int hinic_get_default_mac(void *hwdev, u8 *mac_addr)
225 struct hinic_port_mac_set mac_info;
226 u16 out_size = sizeof(mac_info);
229 if (!hwdev || !mac_addr) {
230 PMD_DRV_LOG(ERR, "Hwdev or mac_addr is NULL");
234 memset(&mac_info, 0, sizeof(mac_info));
235 mac_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
236 mac_info.func_id = hinic_global_func_id(hwdev);
238 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_MAC,
239 &mac_info, sizeof(mac_info),
240 &mac_info, &out_size);
241 if (err || !out_size || mac_info.mgmt_msg_head.status) {
242 PMD_DRV_LOG(ERR, "Failed to get mac, err: %d, status: 0x%x, out size: 0x%x",
243 err, mac_info.mgmt_msg_head.status, out_size);
247 memmove(mac_addr, mac_info.mac, ETH_ALEN);
253 * hinic_set_port_mtu - Set MTU to port.
256 * The hardware interface of a nic device.
262 * negative error value otherwise.
264 int hinic_set_port_mtu(void *hwdev, u32 new_mtu)
266 struct hinic_mtu mtu_info;
267 u16 out_size = sizeof(mtu_info);
271 PMD_DRV_LOG(ERR, "Hwdev is NULL");
275 memset(&mtu_info, 0, sizeof(mtu_info));
276 mtu_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
277 mtu_info.func_id = hinic_global_func_id(hwdev);
278 mtu_info.mtu = new_mtu;
280 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_CHANGE_MTU,
281 &mtu_info, sizeof(mtu_info),
282 &mtu_info, &out_size);
283 if (err || !out_size || mtu_info.mgmt_msg_head.status) {
284 PMD_DRV_LOG(ERR, "Failed to set mtu, err: %d, status: 0x%x, out size: 0x%x",
285 err, mtu_info.mgmt_msg_head.status, out_size);
293 * hinic_get_link_status - Get link status from hardware.
296 * The hardware interface of a nic device.
302 * negative error value otherwise.
304 int hinic_get_link_status(void *hwdev, u8 *link_state)
306 struct hinic_get_link get_link;
307 u16 out_size = sizeof(get_link);
310 if (!hwdev || !link_state) {
311 PMD_DRV_LOG(ERR, "Hwdev or link_state is NULL");
315 memset(&get_link, 0, sizeof(get_link));
316 get_link.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
317 get_link.func_id = hinic_global_func_id(hwdev);
319 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_LINK_STATE,
320 &get_link, sizeof(get_link),
321 &get_link, &out_size);
322 if (err || !out_size || get_link.mgmt_msg_head.status) {
323 PMD_DRV_LOG(ERR, "Failed to get link state, err: %d, status: 0x%x, out size: 0x%x",
324 err, get_link.mgmt_msg_head.status, out_size);
328 *link_state = get_link.link_status;
334 * hinic_set_vport_enable - Notify firmware that driver is ready or not.
337 * The hardware interface of a nic device.
339 * 1: driver is ready; 0: driver is not ok.
343 * negative error value otherwise.
345 int hinic_set_vport_enable(void *hwdev, bool enable)
347 struct hinic_vport_state en_state;
348 u16 out_size = sizeof(en_state);
352 PMD_DRV_LOG(ERR, "Hwdev is NULL");
356 memset(&en_state, 0, sizeof(en_state));
357 en_state.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
358 en_state.func_id = hinic_global_func_id(hwdev);
359 en_state.state = (enable ? 1 : 0);
361 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_VPORT_ENABLE,
362 &en_state, sizeof(en_state),
363 &en_state, &out_size);
364 if (err || !out_size || en_state.mgmt_msg_head.status) {
365 PMD_DRV_LOG(ERR, "Failed to set vport state, err: %d, status: 0x%x, out size: 0x%x",
366 err, en_state.mgmt_msg_head.status, out_size);
374 * hinic_set_port_enable - Open MAG to receive packets.
377 * The hardware interface of a nic device.
379 * 1: open MAG; 0: close MAG.
383 * negative error value otherwise.
385 int hinic_set_port_enable(void *hwdev, bool enable)
387 struct hinic_port_state en_state;
388 u16 out_size = sizeof(en_state);
392 PMD_DRV_LOG(ERR, "Hwdev is NULL");
396 if (HINIC_IS_VF((struct hinic_hwdev *)hwdev))
399 memset(&en_state, 0, sizeof(en_state));
400 en_state.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
401 en_state.state = (enable ? HINIC_PORT_ENABLE : HINIC_PORT_DISABLE);
403 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_PORT_ENABLE,
404 &en_state, sizeof(en_state),
405 &en_state, &out_size);
406 if (err || !out_size || en_state.mgmt_msg_head.status) {
407 PMD_DRV_LOG(ERR, "Failed to set phy port state, err: %d, status: 0x%x, out size: 0x%x",
408 err, en_state.mgmt_msg_head.status, out_size);
415 int hinic_get_port_info(void *hwdev, struct nic_port_info *port_info)
417 struct hinic_port_info port_msg;
418 u16 out_size = sizeof(port_msg);
421 if (!hwdev || !port_info) {
422 PMD_DRV_LOG(ERR, "Hwdev or port_info is NULL");
426 memset(&port_msg, 0, sizeof(port_msg));
427 port_msg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
428 port_msg.func_id = hinic_global_func_id(hwdev);
430 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_PORT_INFO,
431 &port_msg, sizeof(port_msg),
432 &port_msg, &out_size);
433 if (err || !out_size || port_msg.mgmt_msg_head.status) {
435 "Failed to get port info, err: %d, status: 0x%x, out size: 0x%x",
436 err, port_msg.mgmt_msg_head.status, out_size);
440 port_info->autoneg_cap = port_msg.autoneg_cap;
441 port_info->autoneg_state = port_msg.autoneg_state;
442 port_info->duplex = port_msg.duplex;
443 port_info->port_type = port_msg.port_type;
444 port_info->speed = port_msg.speed;
449 int hinic_set_pause_config(void *hwdev, struct nic_pause_config nic_pause)
451 struct hinic_pause_config pause_info;
452 u16 out_size = sizeof(pause_info);
456 PMD_DRV_LOG(ERR, "Hwdev is NULL");
460 memset(&pause_info, 0, sizeof(pause_info));
461 pause_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
462 pause_info.func_id = hinic_global_func_id(hwdev);
463 pause_info.auto_neg = nic_pause.auto_neg;
464 pause_info.rx_pause = nic_pause.rx_pause;
465 pause_info.tx_pause = nic_pause.tx_pause;
467 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_PAUSE_INFO,
468 &pause_info, sizeof(pause_info),
469 &pause_info, &out_size);
470 if (err || !out_size || pause_info.mgmt_msg_head.status) {
471 PMD_DRV_LOG(ERR, "Failed to set pause info, err: %d, status: 0x%x, out size: 0x%x",
472 err, pause_info.mgmt_msg_head.status, out_size);
479 int hinic_dcb_set_ets(void *hwdev, u8 *up_tc, u8 *pg_bw,
480 u8 *pgid, u8 *up_bw, u8 *prio)
482 struct hinic_up_ets_cfg ets;
483 u16 out_size = sizeof(ets);
488 if (!hwdev || !up_tc || !pg_bw || !pgid || !up_bw || !prio) {
489 PMD_DRV_LOG(ERR, "Hwdev, up_tc, pg_bw, pgid, up_bw or prio is NULL");
493 for (i = 0; i < HINIC_DCB_TC_MAX; i++) {
494 up_bw_t += *(up_bw + i);
495 pg_bw_t += *(pg_bw + i);
497 if (*(up_tc + i) > HINIC_DCB_TC_MAX) {
499 "Invalid up %d mapping tc: %d", i,
505 if (pg_bw_t != 100 || (up_bw_t % 100) != 0) {
507 "Invalid pg_bw: %d or up_bw: %d", pg_bw_t, up_bw_t);
511 memset(&ets, 0, sizeof(ets));
512 ets.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
513 ets.port_id = 0; /* reserved */
514 memcpy(ets.up_tc, up_tc, HINIC_DCB_TC_MAX);
515 memcpy(ets.pg_bw, pg_bw, HINIC_DCB_UP_MAX);
516 memcpy(ets.pgid, pgid, HINIC_DCB_UP_MAX);
517 memcpy(ets.up_bw, up_bw, HINIC_DCB_UP_MAX);
518 memcpy(ets.prio, prio, HINIC_DCB_UP_MAX);
520 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_ETS,
521 &ets, sizeof(ets), &ets, &out_size);
522 if (err || ets.mgmt_msg_head.status || !out_size) {
524 "Failed to set ets, err: %d, status: 0x%x, out size: 0x%x",
525 err, ets.mgmt_msg_head.status, out_size);
532 int hinic_get_vport_stats(void *hwdev, struct hinic_vport_stats *stats)
534 struct hinic_port_stats_info vport_stats_cmd;
535 struct hinic_cmd_vport_stats vport_stats_rsp;
536 u16 out_size = sizeof(vport_stats_rsp);
539 if (!hwdev || !stats) {
540 PMD_DRV_LOG(ERR, "Hwdev or stats is NULL");
544 memset(&vport_stats_rsp, 0, sizeof(vport_stats_rsp));
545 memset(&vport_stats_cmd, 0, sizeof(vport_stats_cmd));
546 vport_stats_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
547 vport_stats_cmd.stats_version = HINIC_PORT_STATS_VERSION;
548 vport_stats_cmd.func_id = hinic_global_func_id(hwdev);
549 vport_stats_cmd.stats_size = sizeof(vport_stats_rsp);
551 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_VPORT_STAT,
552 &vport_stats_cmd, sizeof(vport_stats_cmd),
553 &vport_stats_rsp, &out_size);
554 if (err || !out_size || vport_stats_rsp.mgmt_msg_head.status) {
556 "Get vport stats from fw failed, err: %d, status: 0x%x, out size: 0x%x",
557 err, vport_stats_rsp.mgmt_msg_head.status, out_size);
561 memcpy(stats, &vport_stats_rsp.stats, sizeof(*stats));
566 int hinic_get_phy_port_stats(void *hwdev, struct hinic_phy_port_stats *stats)
568 struct hinic_port_stats_info port_stats_cmd;
569 struct hinic_port_stats port_stats_rsp;
570 u16 out_size = sizeof(port_stats_rsp);
573 if (!hwdev || !stats) {
574 PMD_DRV_LOG(ERR, "Hwdev or stats is NULL");
578 memset(&port_stats_rsp, 0, sizeof(port_stats_rsp));
579 memset(&port_stats_cmd, 0, sizeof(port_stats_cmd));
580 port_stats_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
581 port_stats_cmd.stats_version = HINIC_PORT_STATS_VERSION;
582 port_stats_cmd.stats_size = sizeof(port_stats_rsp);
584 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_PORT_STATISTICS,
585 &port_stats_cmd, sizeof(port_stats_cmd),
586 &port_stats_rsp, &out_size);
587 if (err || !out_size || port_stats_rsp.mgmt_msg_head.status) {
589 "Failed to get port statistics, err: %d, status: 0x%x, out size: 0x%x",
590 err, port_stats_rsp.mgmt_msg_head.status, out_size);
594 memcpy(stats, &port_stats_rsp.stats, sizeof(*stats));
599 int hinic_set_rss_type(void *hwdev, u32 tmpl_idx, struct nic_rss_type rss_type)
601 struct nic_rss_context_tbl *ctx_tbl;
602 struct hinic_cmd_buf *cmd_buf;
608 PMD_DRV_LOG(ERR, "Hwdev is NULL");
612 cmd_buf = hinic_alloc_cmd_buf(hwdev);
614 PMD_DRV_LOG(ERR, "Failed to allocate cmd buf");
618 ctx |= HINIC_RSS_TYPE_SET(1, VALID) |
619 HINIC_RSS_TYPE_SET(rss_type.ipv4, IPV4) |
620 HINIC_RSS_TYPE_SET(rss_type.ipv6, IPV6) |
621 HINIC_RSS_TYPE_SET(rss_type.ipv6_ext, IPV6_EXT) |
622 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv4, TCP_IPV4) |
623 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6, TCP_IPV6) |
624 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6_ext, TCP_IPV6_EXT) |
625 HINIC_RSS_TYPE_SET(rss_type.udp_ipv4, UDP_IPV4) |
626 HINIC_RSS_TYPE_SET(rss_type.udp_ipv6, UDP_IPV6);
628 cmd_buf->size = sizeof(struct nic_rss_context_tbl);
630 ctx_tbl = (struct nic_rss_context_tbl *)cmd_buf->buf;
631 ctx_tbl->group_index = cpu_to_be32(tmpl_idx);
633 ctx_tbl->size = sizeof(u32);
634 ctx_tbl->size = cpu_to_be32(ctx_tbl->size);
636 ctx_tbl->ctx = cpu_to_be32(ctx);
638 /* cfg the rss context table by command queue */
639 err = hinic_cmdq_direct_resp(hwdev, HINIC_ACK_TYPE_CMDQ,
641 HINIC_UCODE_CMD_SET_RSS_CONTEXT_TABLE,
642 cmd_buf, &out_param, 0);
644 hinic_free_cmd_buf(hwdev, cmd_buf);
646 if (err || out_param != 0) {
647 PMD_DRV_LOG(ERR, "Failed to set rss context table");
654 int hinic_get_rss_type(void *hwdev, u32 tmpl_idx, struct nic_rss_type *rss_type)
656 struct hinic_rss_context_table ctx_tbl;
657 u16 out_size = sizeof(ctx_tbl);
660 if (!hwdev || !rss_type) {
661 PMD_DRV_LOG(ERR, "Hwdev or rss_type is NULL");
665 ctx_tbl.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
666 ctx_tbl.func_id = hinic_global_func_id(hwdev);
667 ctx_tbl.template_id = (u8)tmpl_idx;
669 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_RSS_CTX_TBL,
670 &ctx_tbl, sizeof(ctx_tbl),
671 &ctx_tbl, &out_size);
672 if (err || !out_size || ctx_tbl.mgmt_msg_head.status) {
674 "Failed to get hash type, err: %d, status: 0x%x, out size: 0x%x",
675 err, ctx_tbl.mgmt_msg_head.status, out_size);
679 rss_type->ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV4);
680 rss_type->ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6);
681 rss_type->ipv6_ext = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6_EXT);
682 rss_type->tcp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV4);
683 rss_type->tcp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV6);
684 rss_type->tcp_ipv6_ext =
685 HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV6_EXT);
686 rss_type->udp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV4);
687 rss_type->udp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV6);
692 int hinic_rss_set_template_tbl(void *hwdev, u32 tmpl_idx, u8 *temp)
694 struct hinic_rss_template_key temp_key;
695 u16 out_size = sizeof(temp_key);
698 if (!hwdev || !temp) {
699 PMD_DRV_LOG(ERR, "Hwdev or temp is NULL");
703 memset(&temp_key, 0, sizeof(temp_key));
704 temp_key.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
705 temp_key.func_id = hinic_global_func_id(hwdev);
706 temp_key.template_id = (u8)tmpl_idx;
707 memcpy(temp_key.key, temp, HINIC_RSS_KEY_SIZE);
709 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RSS_TEMPLATE_TBL,
710 &temp_key, sizeof(temp_key),
711 &temp_key, &out_size);
712 if (err || !out_size || temp_key.mgmt_msg_head.status) {
714 "Failed to set hash key, err: %d, status: 0x%x, out size: 0x%x",
715 err, temp_key.mgmt_msg_head.status, out_size);
722 int hinic_rss_get_template_tbl(void *hwdev, u32 tmpl_idx, u8 *temp)
724 struct hinic_rss_template_key temp_key;
725 u16 out_size = sizeof(temp_key);
728 if (!hwdev || !temp) {
729 PMD_DRV_LOG(ERR, "Hwdev or temp is NULL");
733 memset(&temp_key, 0, sizeof(temp_key));
734 temp_key.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
735 temp_key.func_id = hinic_global_func_id(hwdev);
736 temp_key.template_id = (u8)tmpl_idx;
738 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_RSS_TEMPLATE_TBL,
739 &temp_key, sizeof(temp_key),
740 &temp_key, &out_size);
741 if (err || !out_size || temp_key.mgmt_msg_head.status) {
742 PMD_DRV_LOG(ERR, "Failed to get hash key, err: %d, status: 0x%x, out size: 0x%x",
743 err, temp_key.mgmt_msg_head.status, out_size);
747 memcpy(temp, temp_key.key, HINIC_RSS_KEY_SIZE);
753 * hinic_rss_set_hash_engine - Init rss hash function.
756 * The hardware interface of a nic device.
758 * Index of rss template from NIC.
760 * Hash function, such as Toeplitz or XOR.
764 * negative error value otherwise.
766 int hinic_rss_set_hash_engine(void *hwdev, u8 tmpl_idx, u8 type)
768 struct hinic_rss_engine_type hash_type;
769 u16 out_size = sizeof(hash_type);
773 PMD_DRV_LOG(ERR, "Hwdev is NULL");
777 memset(&hash_type, 0, sizeof(hash_type));
778 hash_type.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
779 hash_type.func_id = hinic_global_func_id(hwdev);
780 hash_type.hash_engine = type;
781 hash_type.template_id = tmpl_idx;
783 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RSS_HASH_ENGINE,
784 &hash_type, sizeof(hash_type),
785 &hash_type, &out_size);
786 if (err || !out_size || hash_type.mgmt_msg_head.status) {
787 PMD_DRV_LOG(ERR, "Failed to get hash engine, err: %d, status: 0x%x, out size: 0x%x",
788 err, hash_type.mgmt_msg_head.status, out_size);
795 int hinic_rss_set_indir_tbl(void *hwdev, u32 tmpl_idx, u32 *indir_table)
797 struct nic_rss_indirect_tbl *indir_tbl;
798 struct hinic_cmd_buf *cmd_buf;
805 if (!hwdev || !indir_table) {
806 PMD_DRV_LOG(ERR, "Hwdev or indir_table is NULL");
810 cmd_buf = hinic_alloc_cmd_buf(hwdev);
812 PMD_DRV_LOG(ERR, "Failed to allocate cmd buf");
816 cmd_buf->size = sizeof(struct nic_rss_indirect_tbl);
817 indir_tbl = cmd_buf->buf;
818 indir_tbl->group_index = cpu_to_be32(tmpl_idx);
820 for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++) {
821 indir_tbl->entry[i] = (u8)(*(indir_table + i));
823 if (0x3 == (i & 0x3)) {
824 temp = (u32 *)&indir_tbl->entry[i - 3];
825 *temp = cpu_to_be32(*temp);
829 /* configure the rss indirect table by command queue */
830 indir_size = HINIC_RSS_INDIR_SIZE / 2;
831 indir_tbl->offset = 0;
832 indir_tbl->size = cpu_to_be32(indir_size);
834 err = hinic_cmdq_direct_resp(hwdev, HINIC_ACK_TYPE_CMDQ,
836 HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE,
837 cmd_buf, &out_param, 0);
838 if (err || out_param != 0) {
839 PMD_DRV_LOG(ERR, "Failed to set rss indir table");
844 indir_tbl->offset = cpu_to_be32(indir_size);
845 indir_tbl->size = cpu_to_be32(indir_size);
846 memcpy(indir_tbl->entry, &indir_tbl->entry[indir_size], indir_size);
848 err = hinic_cmdq_direct_resp(hwdev, HINIC_ACK_TYPE_CMDQ,
850 HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE,
851 cmd_buf, &out_param, 0);
852 if (err || out_param != 0) {
853 PMD_DRV_LOG(ERR, "Failed to set rss indir table");
858 hinic_free_cmd_buf(hwdev, cmd_buf);
863 int hinic_rss_get_indir_tbl(void *hwdev, u32 tmpl_idx, u32 *indir_table)
865 struct hinic_rss_indir_table rss_cfg;
866 u16 out_size = sizeof(rss_cfg);
869 if (!hwdev || !indir_table) {
870 PMD_DRV_LOG(ERR, "Hwdev or indir_table is NULL");
874 memset(&rss_cfg, 0, sizeof(rss_cfg));
875 rss_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
876 rss_cfg.func_id = hinic_global_func_id(hwdev);
877 rss_cfg.template_id = (u8)tmpl_idx;
879 err = l2nic_msg_to_mgmt_sync(hwdev,
880 HINIC_PORT_CMD_GET_RSS_TEMPLATE_INDIR_TBL,
881 &rss_cfg, sizeof(rss_cfg), &rss_cfg,
883 if (err || !out_size || rss_cfg.mgmt_msg_head.status) {
884 PMD_DRV_LOG(ERR, "Failed to get indir table, err: %d, status: 0x%x, out size: 0x%x",
885 err, rss_cfg.mgmt_msg_head.status, out_size);
889 hinic_be32_to_cpu(rss_cfg.indir, HINIC_RSS_INDIR_SIZE);
890 for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++)
891 indir_table[i] = rss_cfg.indir[i];
896 int hinic_rss_cfg(void *hwdev, u8 rss_en, u8 tmpl_idx, u8 tc_num, u8 *prio_tc)
898 struct hinic_rss_config rss_cfg;
899 u16 out_size = sizeof(rss_cfg);
902 /* micro code required: number of TC should be power of 2 */
903 if (!hwdev || !prio_tc || (tc_num & (tc_num - 1))) {
904 PMD_DRV_LOG(ERR, "Hwdev or prio_tc is NULL, or tc_num: %u Not power of 2",
909 memset(&rss_cfg, 0, sizeof(rss_cfg));
910 rss_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
911 rss_cfg.func_id = hinic_global_func_id(hwdev);
912 rss_cfg.rss_en = rss_en;
913 rss_cfg.template_id = tmpl_idx;
914 rss_cfg.rq_priority_number = tc_num ? (u8)ilog2(tc_num) : 0;
916 memcpy(rss_cfg.prio_tc, prio_tc, HINIC_DCB_UP_MAX);
918 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RSS_CFG,
919 &rss_cfg, sizeof(rss_cfg), &rss_cfg,
921 if (err || !out_size || rss_cfg.mgmt_msg_head.status) {
922 PMD_DRV_LOG(ERR, "Failed to set rss cfg, err: %d, status: 0x%x, out size: 0x%x",
923 err, rss_cfg.mgmt_msg_head.status, out_size);
931 * hinic_rss_template_alloc - Get rss template id from the chip,
932 * all functions share 96 templates.
935 * The hardware interface of a nic device.
937 * Index of rss template from chip.
941 * negative error value otherwise.
943 int hinic_rss_template_alloc(void *hwdev, u8 *tmpl_idx)
945 struct hinic_rss_template_mgmt template_mgmt;
946 u16 out_size = sizeof(template_mgmt);
949 if (!hwdev || !tmpl_idx) {
950 PMD_DRV_LOG(ERR, "Hwdev or tmpl_idx is NULL");
954 memset(&template_mgmt, 0, sizeof(template_mgmt));
955 template_mgmt.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
956 template_mgmt.func_id = hinic_global_func_id(hwdev);
957 template_mgmt.cmd = NIC_RSS_CMD_TEMP_ALLOC;
959 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR,
960 &template_mgmt, sizeof(template_mgmt),
961 &template_mgmt, &out_size);
962 if (err || !out_size || template_mgmt.mgmt_msg_head.status) {
963 PMD_DRV_LOG(ERR, "Failed to alloc rss template, err: %d, status: 0x%x, out size: 0x%x",
964 err, template_mgmt.mgmt_msg_head.status, out_size);
968 *tmpl_idx = template_mgmt.template_id;
974 * hinic_rss_template_free - Free rss template id to the chip.
977 * The hardware interface of a nic device.
979 * Index of rss template from chip.
983 * negative error value otherwise.
985 int hinic_rss_template_free(void *hwdev, u8 tmpl_idx)
987 struct hinic_rss_template_mgmt template_mgmt;
988 u16 out_size = sizeof(template_mgmt);
992 PMD_DRV_LOG(ERR, "Hwdev is NULL");
996 memset(&template_mgmt, 0, sizeof(template_mgmt));
997 template_mgmt.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
998 template_mgmt.func_id = hinic_global_func_id(hwdev);
999 template_mgmt.template_id = tmpl_idx;
1000 template_mgmt.cmd = NIC_RSS_CMD_TEMP_FREE;
1002 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR,
1003 &template_mgmt, sizeof(template_mgmt),
1004 &template_mgmt, &out_size);
1005 if (err || !out_size || template_mgmt.mgmt_msg_head.status) {
1006 PMD_DRV_LOG(ERR, "Failed to free rss template, err: %d, status: 0x%x, out size: 0x%x",
1007 err, template_mgmt.mgmt_msg_head.status, out_size);
1015 * hinic_set_rx_vhd_mode - Change rx buffer size after initialization.
1018 * The hardware interface of a nic device.
1022 * receive buffer size.
1026 * negative error value otherwise.
1028 int hinic_set_rx_vhd_mode(void *hwdev, u16 vhd_mode, u16 rx_buf_sz)
1030 struct hinic_set_vhd_mode vhd_mode_cfg;
1031 u16 out_size = sizeof(vhd_mode_cfg);
1035 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1039 memset(&vhd_mode_cfg, 0, sizeof(vhd_mode_cfg));
1041 vhd_mode_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1042 vhd_mode_cfg.func_id = hinic_global_func_id(hwdev);
1043 vhd_mode_cfg.vhd_type = vhd_mode;
1044 vhd_mode_cfg.rx_wqe_buffer_size = rx_buf_sz;
1046 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_VHD_CFG,
1047 &vhd_mode_cfg, sizeof(vhd_mode_cfg),
1048 &vhd_mode_cfg, &out_size);
1049 if (err || !out_size || vhd_mode_cfg.mgmt_msg_head.status) {
1051 "Failed to set vhd mode, err: %d, status: 0x%x, out size: 0x%x",
1052 err, vhd_mode_cfg.mgmt_msg_head.status, out_size);
1060 int hinic_set_rx_mode(void *hwdev, u32 enable)
1062 struct hinic_rx_mode_config rx_mode_cfg;
1063 u16 out_size = sizeof(rx_mode_cfg);
1067 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1071 memset(&rx_mode_cfg, 0, sizeof(rx_mode_cfg));
1072 rx_mode_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1073 rx_mode_cfg.func_id = hinic_global_func_id(hwdev);
1074 rx_mode_cfg.rx_mode = enable;
1076 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RX_MODE,
1077 &rx_mode_cfg, sizeof(rx_mode_cfg),
1078 &rx_mode_cfg, &out_size);
1079 if (err || !out_size || rx_mode_cfg.mgmt_msg_head.status) {
1080 PMD_DRV_LOG(ERR, "Failed to set rx mode, err: %d, status: 0x%x, out size: 0x%x",
1081 err, rx_mode_cfg.mgmt_msg_head.status, out_size);
1088 int hinic_set_rx_csum_offload(void *hwdev, u32 en)
1090 struct hinic_checksum_offload rx_csum_cfg;
1091 u16 out_size = sizeof(rx_csum_cfg);
1095 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1099 memset(&rx_csum_cfg, 0, sizeof(rx_csum_cfg));
1100 rx_csum_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1101 rx_csum_cfg.func_id = hinic_global_func_id(hwdev);
1102 rx_csum_cfg.rx_csum_offload = en;
1104 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RX_CSUM,
1105 &rx_csum_cfg, sizeof(rx_csum_cfg),
1106 &rx_csum_cfg, &out_size);
1107 if (err || !out_size || rx_csum_cfg.mgmt_msg_head.status) {
1109 "Failed to set rx csum offload, err: %d, status: 0x%x, out size: 0x%x",
1110 err, rx_csum_cfg.mgmt_msg_head.status, out_size);
1117 int hinic_set_rx_lro(void *hwdev, u8 ipv4_en, u8 ipv6_en, u8 max_wqe_num)
1119 struct hinic_lro_config lro_cfg;
1120 u16 out_size = sizeof(lro_cfg);
1124 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1128 memset(&lro_cfg, 0, sizeof(lro_cfg));
1129 lro_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1130 lro_cfg.func_id = hinic_global_func_id(hwdev);
1131 lro_cfg.lro_ipv4_en = ipv4_en;
1132 lro_cfg.lro_ipv6_en = ipv6_en;
1133 lro_cfg.lro_max_wqe_num = max_wqe_num;
1135 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_LRO,
1136 &lro_cfg, sizeof(lro_cfg), &lro_cfg,
1138 if (err || !out_size || lro_cfg.mgmt_msg_head.status) {
1139 PMD_DRV_LOG(ERR, "Failed to set lro offload, err: %d, status: 0x%x, out size: 0x%x",
1140 err, lro_cfg.mgmt_msg_head.status, out_size);
1147 int hinic_set_anti_attack(void *hwdev, bool enable)
1149 struct hinic_port_anti_attack_rate rate;
1150 u16 out_size = sizeof(rate);
1154 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1158 memset(&rate, 0, sizeof(rate));
1159 rate.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1160 rate.func_id = hinic_global_func_id(hwdev);
1161 rate.enable = enable;
1162 rate.cir = ANTI_ATTACK_DEFAULT_CIR;
1163 rate.xir = ANTI_ATTACK_DEFAULT_XIR;
1164 rate.cbs = ANTI_ATTACK_DEFAULT_CBS;
1165 rate.xbs = ANTI_ATTACK_DEFAULT_XBS;
1167 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_ANTI_ATTACK_RATE,
1168 &rate, sizeof(rate), &rate,
1170 if (err || !out_size || rate.mgmt_msg_head.status) {
1171 PMD_DRV_LOG(ERR, "can't %s port Anti-Attack rate limit, err: %d, status: 0x%x, out size: 0x%x",
1172 (enable ? "enable" : "disable"), err,
1173 rate.mgmt_msg_head.status, out_size);
1180 /* Set autoneg status and restart port link status */
1181 int hinic_reset_port_link_cfg(void *hwdev)
1183 struct hinic_reset_link_cfg reset_cfg;
1184 u16 out_size = sizeof(reset_cfg);
1187 memset(&reset_cfg, 0, sizeof(reset_cfg));
1188 reset_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1189 reset_cfg.func_id = hinic_global_func_id(hwdev);
1191 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RESET_LINK_CFG,
1192 &reset_cfg, sizeof(reset_cfg),
1193 &reset_cfg, &out_size);
1194 if (err || !out_size || reset_cfg.mgmt_msg_head.status) {
1195 PMD_DRV_LOG(ERR, "Reset port link configure failed, err: %d, status: 0x%x, out size: 0x%x",
1196 err, reset_cfg.mgmt_msg_head.status, out_size);
1204 * hinic_vf_func_init - Register VF to PF.
1207 * The hardware interface of a nic device.
1211 * negative error value otherwise.
1213 int hinic_vf_func_init(struct hinic_hwdev *hwdev)
1217 if (!HINIC_IS_VF(hwdev))
1220 err = hinic_mbox_to_pf(hwdev, HINIC_MOD_L2NIC,
1221 HINIC_PORT_CMD_VF_REGISTER, &state, sizeof(state),
1224 PMD_DRV_LOG(ERR, "Fail to register vf");
1232 * hinic_vf_func_free - Unregister VF from PF.
1235 * The hardware interface of a nic device.
1237 void hinic_vf_func_free(struct hinic_hwdev *hwdev)
1241 if (hinic_func_type(hwdev) != TYPE_VF)
1244 err = hinic_mbox_to_pf(hwdev, HINIC_MOD_L2NIC,
1245 HINIC_PORT_CMD_VF_UNREGISTER, &err, sizeof(err),
1248 PMD_DRV_LOG(ERR, "Fail to unregister VF, err: %d", err);
1251 int hinic_set_fast_recycle_mode(void *hwdev, u8 mode)
1253 struct hinic_fast_recycled_mode fast_recycled_mode;
1254 u16 out_size = sizeof(fast_recycled_mode);
1258 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1262 memset(&fast_recycled_mode, 0, sizeof(fast_recycled_mode));
1263 fast_recycled_mode.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1264 fast_recycled_mode.func_id = hinic_global_func_id(hwdev);
1265 fast_recycled_mode.fast_recycled_mode = mode;
1267 err = hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_COMM,
1268 HINIC_MGMT_CMD_FAST_RECYCLE_MODE_SET,
1269 &fast_recycled_mode,
1270 sizeof(fast_recycled_mode),
1271 &fast_recycled_mode, &out_size, 0);
1272 if (err || fast_recycled_mode.mgmt_msg_head.status || !out_size) {
1274 "Failed to set recycle mode, ret = %d",
1275 fast_recycled_mode.mgmt_msg_head.status);
1282 int hinic_clear_vport_stats(struct hinic_hwdev *hwdev)
1284 struct hinic_clear_vport_stats clear_vport_stats;
1285 u16 out_size = sizeof(clear_vport_stats);
1289 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1293 memset(&clear_vport_stats, 0, sizeof(clear_vport_stats));
1294 clear_vport_stats.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1295 clear_vport_stats.func_id = hinic_global_func_id(hwdev);
1297 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_CLEAN_VPORT_STAT,
1299 sizeof(clear_vport_stats),
1300 &clear_vport_stats, &out_size);
1301 if (err || !out_size || clear_vport_stats.mgmt_msg_head.status) {
1302 PMD_DRV_LOG(ERR, "Failed to clear vport statistics, err: %d, status: 0x%x, out size: 0x%x",
1303 err, clear_vport_stats.mgmt_msg_head.status, out_size);
1310 int hinic_clear_phy_port_stats(struct hinic_hwdev *hwdev)
1312 struct hinic_clear_port_stats clear_phy_port_stats;
1313 u16 out_size = sizeof(clear_phy_port_stats);
1317 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1321 memset(&clear_phy_port_stats, 0, sizeof(clear_phy_port_stats));
1322 clear_phy_port_stats.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1323 clear_phy_port_stats.func_id = hinic_global_func_id(hwdev);
1325 err = l2nic_msg_to_mgmt_sync(hwdev,
1326 HINIC_PORT_CMD_CLEAR_PORT_STATISTICS,
1327 &clear_phy_port_stats,
1328 sizeof(clear_phy_port_stats),
1329 &clear_phy_port_stats, &out_size);
1330 if (err || !out_size || clear_phy_port_stats.mgmt_msg_head.status) {
1331 PMD_DRV_LOG(ERR, "Failed to clear phy port statistics, err: %d, status: 0x%x, out size: 0x%x",
1332 err, clear_phy_port_stats.mgmt_msg_head.status,
1340 int hinic_set_link_status_follow(void *hwdev,
1341 enum hinic_link_follow_status status)
1343 struct hinic_set_link_follow follow;
1344 u16 out_size = sizeof(follow);
1350 if (HINIC_IS_VF((struct hinic_hwdev *)hwdev))
1353 if (status >= HINIC_LINK_FOLLOW_STATUS_MAX) {
1355 "Invalid link follow status: %d", status);
1359 memset(&follow, 0, sizeof(follow));
1360 follow.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1361 follow.func_id = hinic_global_func_id(hwdev);
1362 follow.follow_status = status;
1364 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_LINK_FOLLOW,
1365 &follow, sizeof(follow),
1366 &follow, &out_size);
1367 if ((follow.mgmt_msg_head.status != HINIC_MGMT_CMD_UNSUPPORTED &&
1368 follow.mgmt_msg_head.status) || err || !out_size) {
1370 "Failed to set link status follow phy port status, err: %d, status: 0x%x, out size: 0x%x",
1371 err, follow.mgmt_msg_head.status, out_size);
1375 return follow.mgmt_msg_head.status;
1378 int hinic_get_link_mode(void *hwdev, u32 *supported, u32 *advertised)
1380 struct hinic_link_mode_cmd link_mode;
1381 u16 out_size = sizeof(link_mode);
1384 if (!hwdev || !supported || !advertised)
1387 memset(&link_mode, 0, sizeof(link_mode));
1388 link_mode.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1389 link_mode.func_id = hinic_global_func_id(hwdev);
1391 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_LINK_MODE,
1392 &link_mode, sizeof(link_mode),
1393 &link_mode, &out_size);
1394 if (err || !out_size || link_mode.mgmt_msg_head.status) {
1396 "Failed to get link mode, err: %d, status: 0x%x, out size: 0x%x",
1397 err, link_mode.mgmt_msg_head.status, out_size);
1401 *supported = link_mode.supported;
1402 *advertised = link_mode.advertised;
1408 * hinic_flush_qp_res - Flush tx && rx chip resources in case of set vport
1409 * fake failed when device start.
1412 * The hardware interface of a nic device.
1416 * negative error value otherwise.
1418 int hinic_flush_qp_res(void *hwdev)
1420 struct hinic_clear_qp_resource qp_res;
1421 u16 out_size = sizeof(qp_res);
1424 memset(&qp_res, 0, sizeof(qp_res));
1425 qp_res.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1426 qp_res.func_id = hinic_global_func_id(hwdev);
1428 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_CLEAR_QP_RES,
1429 &qp_res, sizeof(qp_res), &qp_res,
1431 if (err || !out_size || qp_res.mgmt_msg_head.status) {
1432 PMD_DRV_LOG(ERR, "Failed to clear sq resources, err: %d, status: 0x%x, out size: 0x%x",
1433 err, qp_res.mgmt_msg_head.status, out_size);