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_update_mac - Update mac address to hardware.
256 * The hardware interface of a nic device.
262 * Set 0 for mac_vlan table initialization.
264 * Global function id of NIC.
268 * negative error value otherwise.
270 int hinic_update_mac(void *hwdev, u8 *old_mac, u8 *new_mac, u16 vlan_id,
273 struct hinic_port_mac_update mac_info;
274 u16 out_size = sizeof(mac_info);
277 if (!hwdev || !old_mac || !new_mac) {
278 PMD_DRV_LOG(ERR, "Hwdev, old_mac or new_mac is NULL");
282 memset(&mac_info, 0, sizeof(mac_info));
283 mac_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
284 mac_info.func_id = func_id;
285 mac_info.vlan_id = vlan_id;
286 memcpy(mac_info.old_mac, old_mac, ETH_ALEN);
287 memcpy(mac_info.new_mac, new_mac, ETH_ALEN);
289 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_UPDATE_MAC,
290 &mac_info, sizeof(mac_info),
291 &mac_info, &out_size);
292 if (err || !out_size ||
293 (mac_info.mgmt_msg_head.status &&
294 mac_info.mgmt_msg_head.status != HINIC_PF_SET_VF_ALREADY)) {
295 PMD_DRV_LOG(ERR, "Failed to update MAC, err: %d, status: 0x%x, out size: 0x%x",
296 err, mac_info.mgmt_msg_head.status, out_size);
299 if (mac_info.mgmt_msg_head.status == HINIC_PF_SET_VF_ALREADY) {
300 PMD_DRV_LOG(WARNING, "PF has already set vf mac, Ignore update operation");
301 return HINIC_PF_SET_VF_ALREADY;
308 * hinic_set_port_mtu - Set MTU to port.
311 * The hardware interface of a nic device.
317 * negative error value otherwise.
319 int hinic_set_port_mtu(void *hwdev, u32 new_mtu)
321 struct hinic_mtu mtu_info;
322 u16 out_size = sizeof(mtu_info);
326 PMD_DRV_LOG(ERR, "Hwdev is NULL");
330 memset(&mtu_info, 0, sizeof(mtu_info));
331 mtu_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
332 mtu_info.func_id = hinic_global_func_id(hwdev);
333 mtu_info.mtu = new_mtu;
335 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_CHANGE_MTU,
336 &mtu_info, sizeof(mtu_info),
337 &mtu_info, &out_size);
338 if (err || !out_size || mtu_info.mgmt_msg_head.status) {
339 PMD_DRV_LOG(ERR, "Failed to set mtu, err: %d, status: 0x%x, out size: 0x%x",
340 err, mtu_info.mgmt_msg_head.status, out_size);
348 * hinic_add_remove_vlan - Add or remove vlan id to vlan elb table.
351 * The hardware interface of a nic device.
355 * Global function id of NIC.
357 * Add or remove operation.
361 * negative error value otherwise.
363 int hinic_add_remove_vlan(void *hwdev, u16 vlan_id, u16 func_id, bool add)
365 struct hinic_vlan_config vlan_info;
366 u16 out_size = sizeof(vlan_info);
371 PMD_DRV_LOG(ERR, "Hwdev is NULL");
375 cmd = add ? HINIC_PORT_CMD_ADD_VLAN : HINIC_PORT_CMD_DEL_VLAN;
377 memset(&vlan_info, 0, sizeof(vlan_info));
378 vlan_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
379 vlan_info.func_id = func_id;
380 vlan_info.vlan_id = vlan_id;
382 err = l2nic_msg_to_mgmt_sync(hwdev, cmd, &vlan_info, sizeof(vlan_info),
383 &vlan_info, &out_size);
384 if (err || !out_size || vlan_info.mgmt_msg_head.status) {
386 "Failed to %s vlan, err: %d, status: 0x%x, out size: 0x%x",
387 add ? "add" : "remove", err,
388 vlan_info.mgmt_msg_head.status, out_size);
396 * hinic_config_vlan_filter - Enable or Disable vlan filter.
399 * The hardware interface of a nic device.
400 * @param vlan_filter_ctrl
405 * negative error value otherwise.
407 int hinic_config_vlan_filter(void *hwdev, u32 vlan_filter_ctrl)
409 struct hinic_hwdev *nic_hwdev = (struct hinic_hwdev *)hwdev;
410 struct hinic_vlan_filter vlan_filter;
411 u16 out_size = sizeof(vlan_filter);
417 memset(&vlan_filter, 0, sizeof(vlan_filter));
418 vlan_filter.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
419 vlan_filter.func_id = hinic_global_func_id(nic_hwdev);
420 vlan_filter.vlan_filter_ctrl = vlan_filter_ctrl;
422 err = l2nic_msg_to_mgmt_sync(nic_hwdev, HINIC_PORT_CMD_SET_VLAN_FILTER,
423 &vlan_filter, sizeof(vlan_filter),
424 &vlan_filter, &out_size);
425 if (vlan_filter.mgmt_msg_head.status == HINIC_MGMT_CMD_UNSUPPORTED) {
426 err = HINIC_MGMT_CMD_UNSUPPORTED;
427 } else if ((err == HINIC_MBOX_VF_CMD_ERROR) &&
428 (HINIC_IS_VF(nic_hwdev))) {
429 err = HINIC_MGMT_CMD_UNSUPPORTED;
430 } else if (err || !out_size || vlan_filter.mgmt_msg_head.status) {
432 "Failed to config vlan filter, vlan_filter_ctrl: 0x%x, err: %d, status: 0x%x, out size: 0x%x",
433 vlan_filter_ctrl, err,
434 vlan_filter.mgmt_msg_head.status, out_size);
442 * hinic_set_rx_vlan_offload - Enable or Disable vlan offload.
445 * The hardware interface of a nic device.
451 * negative error value otherwise.
453 int hinic_set_rx_vlan_offload(void *hwdev, u8 en)
455 struct hinic_vlan_offload vlan_cfg;
456 u16 out_size = sizeof(vlan_cfg);
460 PMD_DRV_LOG(ERR, "Hwdev is NULL");
464 memset(&vlan_cfg, 0, sizeof(vlan_cfg));
465 vlan_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
466 vlan_cfg.func_id = hinic_global_func_id(hwdev);
467 vlan_cfg.vlan_rx_offload = en;
469 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RX_VLAN_OFFLOAD,
470 &vlan_cfg, sizeof(vlan_cfg),
471 &vlan_cfg, &out_size);
472 if (err || !out_size || vlan_cfg.mgmt_msg_head.status) {
474 "Failed to set rx vlan offload, err: %d, status: 0x%x, out size: 0x%x",
475 err, vlan_cfg.mgmt_msg_head.status, out_size);
483 * hinic_get_link_status - Get link status from hardware.
486 * The hardware interface of a nic device.
492 * negative error value otherwise.
494 int hinic_get_link_status(void *hwdev, u8 *link_state)
496 struct hinic_get_link get_link;
497 u16 out_size = sizeof(get_link);
500 if (!hwdev || !link_state) {
501 PMD_DRV_LOG(ERR, "Hwdev or link_state is NULL");
505 memset(&get_link, 0, sizeof(get_link));
506 get_link.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
507 get_link.func_id = hinic_global_func_id(hwdev);
509 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_LINK_STATE,
510 &get_link, sizeof(get_link),
511 &get_link, &out_size);
512 if (err || !out_size || get_link.mgmt_msg_head.status) {
513 PMD_DRV_LOG(ERR, "Failed to get link state, err: %d, status: 0x%x, out size: 0x%x",
514 err, get_link.mgmt_msg_head.status, out_size);
518 *link_state = get_link.link_status;
524 * hinic_set_vport_enable - Notify firmware that driver is ready or not.
527 * The hardware interface of a nic device.
529 * 1: driver is ready; 0: driver is not ok.
533 * negative error value otherwise.
535 int hinic_set_vport_enable(void *hwdev, bool enable)
537 struct hinic_vport_state en_state;
538 u16 out_size = sizeof(en_state);
542 PMD_DRV_LOG(ERR, "Hwdev is NULL");
546 memset(&en_state, 0, sizeof(en_state));
547 en_state.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
548 en_state.func_id = hinic_global_func_id(hwdev);
549 en_state.state = (enable ? 1 : 0);
551 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_VPORT_ENABLE,
552 &en_state, sizeof(en_state),
553 &en_state, &out_size);
554 if (err || !out_size || en_state.mgmt_msg_head.status) {
555 PMD_DRV_LOG(ERR, "Failed to set vport state, err: %d, status: 0x%x, out size: 0x%x",
556 err, en_state.mgmt_msg_head.status, out_size);
564 * hinic_set_port_enable - Open MAG to receive packets.
567 * The hardware interface of a nic device.
569 * 1: open MAG; 0: close MAG.
573 * negative error value otherwise.
575 int hinic_set_port_enable(void *hwdev, bool enable)
577 struct hinic_port_state en_state;
578 u16 out_size = sizeof(en_state);
582 PMD_DRV_LOG(ERR, "Hwdev is NULL");
586 if (HINIC_IS_VF((struct hinic_hwdev *)hwdev))
589 memset(&en_state, 0, sizeof(en_state));
590 en_state.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
591 en_state.state = (enable ? HINIC_PORT_ENABLE : HINIC_PORT_DISABLE);
593 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_PORT_ENABLE,
594 &en_state, sizeof(en_state),
595 &en_state, &out_size);
596 if (err || !out_size || en_state.mgmt_msg_head.status) {
597 PMD_DRV_LOG(ERR, "Failed to set phy port state, err: %d, status: 0x%x, out size: 0x%x",
598 err, en_state.mgmt_msg_head.status, out_size);
605 int hinic_get_port_info(void *hwdev, struct nic_port_info *port_info)
607 struct hinic_port_info port_msg;
608 u16 out_size = sizeof(port_msg);
611 if (!hwdev || !port_info) {
612 PMD_DRV_LOG(ERR, "Hwdev or port_info is NULL");
616 memset(&port_msg, 0, sizeof(port_msg));
617 port_msg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
618 port_msg.func_id = hinic_global_func_id(hwdev);
620 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_PORT_INFO,
621 &port_msg, sizeof(port_msg),
622 &port_msg, &out_size);
623 if (err || !out_size || port_msg.mgmt_msg_head.status) {
625 "Failed to get port info, err: %d, status: 0x%x, out size: 0x%x",
626 err, port_msg.mgmt_msg_head.status, out_size);
630 port_info->autoneg_cap = port_msg.autoneg_cap;
631 port_info->autoneg_state = port_msg.autoneg_state;
632 port_info->duplex = port_msg.duplex;
633 port_info->port_type = port_msg.port_type;
634 port_info->speed = port_msg.speed;
639 int hinic_set_pause_config(void *hwdev, struct nic_pause_config nic_pause)
641 struct hinic_pause_config pause_info;
642 u16 out_size = sizeof(pause_info);
646 PMD_DRV_LOG(ERR, "Hwdev is NULL");
650 memset(&pause_info, 0, sizeof(pause_info));
651 pause_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
652 pause_info.func_id = hinic_global_func_id(hwdev);
653 pause_info.auto_neg = nic_pause.auto_neg;
654 pause_info.rx_pause = nic_pause.rx_pause;
655 pause_info.tx_pause = nic_pause.tx_pause;
657 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_PAUSE_INFO,
658 &pause_info, sizeof(pause_info),
659 &pause_info, &out_size);
660 if (err || !out_size || pause_info.mgmt_msg_head.status) {
661 PMD_DRV_LOG(ERR, "Failed to set pause info, err: %d, status: 0x%x, out size: 0x%x",
662 err, pause_info.mgmt_msg_head.status, out_size);
669 int hinic_get_pause_info(void *hwdev, struct nic_pause_config *nic_pause)
671 struct hinic_pause_config pause_info;
672 u16 out_size = sizeof(pause_info);
675 if (!hwdev || !nic_pause)
678 memset(&pause_info, 0, sizeof(pause_info));
679 pause_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
680 pause_info.func_id = hinic_global_func_id(hwdev);
682 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_PAUSE_INFO,
683 &pause_info, sizeof(pause_info),
684 &pause_info, &out_size);
685 if (err || !out_size || pause_info.mgmt_msg_head.status) {
686 PMD_DRV_LOG(ERR, "Failed to get pause info, err: %d, status: 0x%x, out size: 0x%x\n",
687 err, pause_info.mgmt_msg_head.status, out_size);
691 nic_pause->auto_neg = pause_info.auto_neg;
692 nic_pause->rx_pause = pause_info.rx_pause;
693 nic_pause->tx_pause = pause_info.tx_pause;
698 int hinic_dcb_set_ets(void *hwdev, u8 *up_tc, u8 *pg_bw,
699 u8 *pgid, u8 *up_bw, u8 *prio)
701 struct hinic_up_ets_cfg ets;
702 u16 out_size = sizeof(ets);
707 if (!hwdev || !up_tc || !pg_bw || !pgid || !up_bw || !prio) {
708 PMD_DRV_LOG(ERR, "Hwdev, up_tc, pg_bw, pgid, up_bw or prio is NULL");
712 for (i = 0; i < HINIC_DCB_TC_MAX; i++) {
713 up_bw_t += *(up_bw + i);
714 pg_bw_t += *(pg_bw + i);
716 if (*(up_tc + i) > HINIC_DCB_TC_MAX) {
717 PMD_DRV_LOG(ERR, "Invalid up %d mapping tc: %d", i,
723 if (pg_bw_t != 100 || (up_bw_t % 100) != 0) {
725 "Invalid pg_bw: %d or up_bw: %d", pg_bw_t, up_bw_t);
729 memset(&ets, 0, sizeof(ets));
730 ets.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
731 ets.port_id = 0; /* reserved */
732 memcpy(ets.up_tc, up_tc, HINIC_DCB_TC_MAX);
733 memcpy(ets.pg_bw, pg_bw, HINIC_DCB_UP_MAX);
734 memcpy(ets.pgid, pgid, HINIC_DCB_UP_MAX);
735 memcpy(ets.up_bw, up_bw, HINIC_DCB_UP_MAX);
736 memcpy(ets.prio, prio, HINIC_DCB_UP_MAX);
738 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_ETS,
739 &ets, sizeof(ets), &ets, &out_size);
740 if (err || ets.mgmt_msg_head.status || !out_size) {
742 "Failed to set ets, err: %d, status: 0x%x, out size: 0x%x",
743 err, ets.mgmt_msg_head.status, out_size);
750 int hinic_get_vport_stats(void *hwdev, struct hinic_vport_stats *stats)
752 struct hinic_port_stats_info vport_stats_cmd;
753 struct hinic_cmd_vport_stats vport_stats_rsp;
754 u16 out_size = sizeof(vport_stats_rsp);
757 if (!hwdev || !stats) {
758 PMD_DRV_LOG(ERR, "Hwdev or stats is NULL");
762 memset(&vport_stats_rsp, 0, sizeof(vport_stats_rsp));
763 memset(&vport_stats_cmd, 0, sizeof(vport_stats_cmd));
764 vport_stats_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
765 vport_stats_cmd.stats_version = HINIC_PORT_STATS_VERSION;
766 vport_stats_cmd.func_id = hinic_global_func_id(hwdev);
767 vport_stats_cmd.stats_size = sizeof(vport_stats_rsp);
769 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_VPORT_STAT,
770 &vport_stats_cmd, sizeof(vport_stats_cmd),
771 &vport_stats_rsp, &out_size);
772 if (err || !out_size || vport_stats_rsp.mgmt_msg_head.status) {
774 "Get vport stats from fw failed, err: %d, status: 0x%x, out size: 0x%x",
775 err, vport_stats_rsp.mgmt_msg_head.status, out_size);
779 memcpy(stats, &vport_stats_rsp.stats, sizeof(*stats));
784 int hinic_get_phy_port_stats(void *hwdev, struct hinic_phy_port_stats *stats)
786 struct hinic_port_stats_info port_stats_cmd;
787 struct hinic_port_stats port_stats_rsp;
788 u16 out_size = sizeof(port_stats_rsp);
791 if (!hwdev || !stats) {
792 PMD_DRV_LOG(ERR, "Hwdev or stats is NULL");
796 memset(&port_stats_rsp, 0, sizeof(port_stats_rsp));
797 memset(&port_stats_cmd, 0, sizeof(port_stats_cmd));
798 port_stats_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
799 port_stats_cmd.stats_version = HINIC_PORT_STATS_VERSION;
800 port_stats_cmd.stats_size = sizeof(port_stats_rsp);
802 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_PORT_STATISTICS,
803 &port_stats_cmd, sizeof(port_stats_cmd),
804 &port_stats_rsp, &out_size);
805 if (err || !out_size || port_stats_rsp.mgmt_msg_head.status) {
807 "Failed to get port statistics, err: %d, status: 0x%x, out size: 0x%x",
808 err, port_stats_rsp.mgmt_msg_head.status, out_size);
812 memcpy(stats, &port_stats_rsp.stats, sizeof(*stats));
817 int hinic_set_rss_type(void *hwdev, u32 tmpl_idx, struct nic_rss_type rss_type)
819 struct nic_rss_context_tbl *ctx_tbl;
820 struct hinic_cmd_buf *cmd_buf;
826 PMD_DRV_LOG(ERR, "Hwdev is NULL");
830 cmd_buf = hinic_alloc_cmd_buf(hwdev);
832 PMD_DRV_LOG(ERR, "Failed to allocate cmd buf");
836 ctx |= HINIC_RSS_TYPE_SET(1, VALID) |
837 HINIC_RSS_TYPE_SET(rss_type.ipv4, IPV4) |
838 HINIC_RSS_TYPE_SET(rss_type.ipv6, IPV6) |
839 HINIC_RSS_TYPE_SET(rss_type.ipv6_ext, IPV6_EXT) |
840 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv4, TCP_IPV4) |
841 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6, TCP_IPV6) |
842 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6_ext, TCP_IPV6_EXT) |
843 HINIC_RSS_TYPE_SET(rss_type.udp_ipv4, UDP_IPV4) |
844 HINIC_RSS_TYPE_SET(rss_type.udp_ipv6, UDP_IPV6);
846 cmd_buf->size = sizeof(struct nic_rss_context_tbl);
848 ctx_tbl = (struct nic_rss_context_tbl *)cmd_buf->buf;
849 ctx_tbl->group_index = cpu_to_be32(tmpl_idx);
851 ctx_tbl->size = sizeof(u32);
852 ctx_tbl->size = cpu_to_be32(ctx_tbl->size);
854 ctx_tbl->ctx = cpu_to_be32(ctx);
856 /* cfg the rss context table by command queue */
857 err = hinic_cmdq_direct_resp(hwdev, HINIC_ACK_TYPE_CMDQ,
859 HINIC_UCODE_CMD_SET_RSS_CONTEXT_TABLE,
860 cmd_buf, &out_param, 0);
862 hinic_free_cmd_buf(hwdev, cmd_buf);
864 if (err || out_param != 0) {
865 PMD_DRV_LOG(ERR, "Failed to set rss context table");
872 int hinic_get_rss_type(void *hwdev, u32 tmpl_idx, struct nic_rss_type *rss_type)
874 struct hinic_rss_context_table ctx_tbl;
875 u16 out_size = sizeof(ctx_tbl);
878 if (!hwdev || !rss_type) {
879 PMD_DRV_LOG(ERR, "Hwdev or rss_type is NULL");
883 ctx_tbl.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
884 ctx_tbl.func_id = hinic_global_func_id(hwdev);
885 ctx_tbl.template_id = (u8)tmpl_idx;
887 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_RSS_CTX_TBL,
888 &ctx_tbl, sizeof(ctx_tbl),
889 &ctx_tbl, &out_size);
890 if (err || !out_size || ctx_tbl.mgmt_msg_head.status) {
892 "Failed to get hash type, err: %d, status: 0x%x, out size: 0x%x",
893 err, ctx_tbl.mgmt_msg_head.status, out_size);
897 rss_type->ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV4);
898 rss_type->ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6);
899 rss_type->ipv6_ext = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6_EXT);
900 rss_type->tcp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV4);
901 rss_type->tcp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV6);
902 rss_type->tcp_ipv6_ext =
903 HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV6_EXT);
904 rss_type->udp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV4);
905 rss_type->udp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV6);
910 int hinic_rss_set_template_tbl(void *hwdev, u32 tmpl_idx, u8 *temp)
912 struct hinic_rss_template_key temp_key;
913 u16 out_size = sizeof(temp_key);
916 if (!hwdev || !temp) {
917 PMD_DRV_LOG(ERR, "Hwdev or temp is NULL");
921 memset(&temp_key, 0, sizeof(temp_key));
922 temp_key.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
923 temp_key.func_id = hinic_global_func_id(hwdev);
924 temp_key.template_id = (u8)tmpl_idx;
925 memcpy(temp_key.key, temp, HINIC_RSS_KEY_SIZE);
927 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RSS_TEMPLATE_TBL,
928 &temp_key, sizeof(temp_key),
929 &temp_key, &out_size);
930 if (err || !out_size || temp_key.mgmt_msg_head.status) {
932 "Failed to set hash key, err: %d, status: 0x%x, out size: 0x%x",
933 err, temp_key.mgmt_msg_head.status, out_size);
940 int hinic_rss_get_template_tbl(void *hwdev, u32 tmpl_idx, u8 *temp)
942 struct hinic_rss_template_key temp_key;
943 u16 out_size = sizeof(temp_key);
946 if (!hwdev || !temp) {
947 PMD_DRV_LOG(ERR, "Hwdev or temp is NULL");
951 memset(&temp_key, 0, sizeof(temp_key));
952 temp_key.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
953 temp_key.func_id = hinic_global_func_id(hwdev);
954 temp_key.template_id = (u8)tmpl_idx;
956 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_RSS_TEMPLATE_TBL,
957 &temp_key, sizeof(temp_key),
958 &temp_key, &out_size);
959 if (err || !out_size || temp_key.mgmt_msg_head.status) {
960 PMD_DRV_LOG(ERR, "Failed to get hash key, err: %d, status: 0x%x, out size: 0x%x",
961 err, temp_key.mgmt_msg_head.status, out_size);
965 memcpy(temp, temp_key.key, HINIC_RSS_KEY_SIZE);
971 * hinic_rss_set_hash_engine - Init rss hash function.
974 * The hardware interface of a nic device.
976 * Index of rss template from NIC.
978 * Hash function, such as Toeplitz or XOR.
982 * negative error value otherwise.
984 int hinic_rss_set_hash_engine(void *hwdev, u8 tmpl_idx, u8 type)
986 struct hinic_rss_engine_type hash_type;
987 u16 out_size = sizeof(hash_type);
991 PMD_DRV_LOG(ERR, "Hwdev is NULL");
995 memset(&hash_type, 0, sizeof(hash_type));
996 hash_type.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
997 hash_type.func_id = hinic_global_func_id(hwdev);
998 hash_type.hash_engine = type;
999 hash_type.template_id = tmpl_idx;
1001 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RSS_HASH_ENGINE,
1002 &hash_type, sizeof(hash_type),
1003 &hash_type, &out_size);
1004 if (err || !out_size || hash_type.mgmt_msg_head.status) {
1005 PMD_DRV_LOG(ERR, "Failed to get hash engine, err: %d, status: 0x%x, out size: 0x%x",
1006 err, hash_type.mgmt_msg_head.status, out_size);
1013 int hinic_rss_set_indir_tbl(void *hwdev, u32 tmpl_idx, u32 *indir_table)
1015 struct nic_rss_indirect_tbl *indir_tbl;
1016 struct hinic_cmd_buf *cmd_buf;
1023 if (!hwdev || !indir_table) {
1024 PMD_DRV_LOG(ERR, "Hwdev or indir_table is NULL");
1028 cmd_buf = hinic_alloc_cmd_buf(hwdev);
1030 PMD_DRV_LOG(ERR, "Failed to allocate cmd buf");
1034 cmd_buf->size = sizeof(struct nic_rss_indirect_tbl);
1035 indir_tbl = cmd_buf->buf;
1036 indir_tbl->group_index = cpu_to_be32(tmpl_idx);
1038 for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++) {
1039 indir_tbl->entry[i] = (u8)(*(indir_table + i));
1041 if (0x3 == (i & 0x3)) {
1042 temp = (u32 *)&indir_tbl->entry[i - 3];
1043 *temp = cpu_to_be32(*temp);
1047 /* configure the rss indirect table by command queue */
1048 indir_size = HINIC_RSS_INDIR_SIZE / 2;
1049 indir_tbl->offset = 0;
1050 indir_tbl->size = cpu_to_be32(indir_size);
1052 err = hinic_cmdq_direct_resp(hwdev, HINIC_ACK_TYPE_CMDQ,
1054 HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE,
1055 cmd_buf, &out_param, 0);
1056 if (err || out_param != 0) {
1057 PMD_DRV_LOG(ERR, "Failed to set rss indir table");
1062 indir_tbl->offset = cpu_to_be32(indir_size);
1063 indir_tbl->size = cpu_to_be32(indir_size);
1064 memcpy(indir_tbl->entry, &indir_tbl->entry[indir_size], indir_size);
1066 err = hinic_cmdq_direct_resp(hwdev, HINIC_ACK_TYPE_CMDQ,
1068 HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE,
1069 cmd_buf, &out_param, 0);
1070 if (err || out_param != 0) {
1071 PMD_DRV_LOG(ERR, "Failed to set rss indir table");
1076 hinic_free_cmd_buf(hwdev, cmd_buf);
1081 int hinic_rss_get_indir_tbl(void *hwdev, u32 tmpl_idx, u32 *indir_table)
1083 struct hinic_rss_indir_table rss_cfg;
1084 u16 out_size = sizeof(rss_cfg);
1087 if (!hwdev || !indir_table) {
1088 PMD_DRV_LOG(ERR, "Hwdev or indir_table is NULL");
1092 memset(&rss_cfg, 0, sizeof(rss_cfg));
1093 rss_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1094 rss_cfg.func_id = hinic_global_func_id(hwdev);
1095 rss_cfg.template_id = (u8)tmpl_idx;
1097 err = l2nic_msg_to_mgmt_sync(hwdev,
1098 HINIC_PORT_CMD_GET_RSS_TEMPLATE_INDIR_TBL,
1099 &rss_cfg, sizeof(rss_cfg), &rss_cfg,
1101 if (err || !out_size || rss_cfg.mgmt_msg_head.status) {
1102 PMD_DRV_LOG(ERR, "Failed to get indir table, err: %d, status: 0x%x, out size: 0x%x",
1103 err, rss_cfg.mgmt_msg_head.status, out_size);
1107 hinic_be32_to_cpu(rss_cfg.indir, HINIC_RSS_INDIR_SIZE);
1108 for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++)
1109 indir_table[i] = rss_cfg.indir[i];
1114 int hinic_rss_cfg(void *hwdev, u8 rss_en, u8 tmpl_idx, u8 tc_num, u8 *prio_tc)
1116 struct hinic_rss_config rss_cfg;
1117 u16 out_size = sizeof(rss_cfg);
1120 /* micro code required: number of TC should be power of 2 */
1121 if (!hwdev || !prio_tc || (tc_num & (tc_num - 1))) {
1122 PMD_DRV_LOG(ERR, "Hwdev or prio_tc is NULL, or tc_num: %u Not power of 2",
1127 memset(&rss_cfg, 0, sizeof(rss_cfg));
1128 rss_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1129 rss_cfg.func_id = hinic_global_func_id(hwdev);
1130 rss_cfg.rss_en = rss_en;
1131 rss_cfg.template_id = tmpl_idx;
1132 rss_cfg.rq_priority_number = tc_num ? (u8)ilog2(tc_num) : 0;
1134 memcpy(rss_cfg.prio_tc, prio_tc, HINIC_DCB_UP_MAX);
1136 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RSS_CFG,
1137 &rss_cfg, sizeof(rss_cfg), &rss_cfg,
1139 if (err || !out_size || rss_cfg.mgmt_msg_head.status) {
1140 PMD_DRV_LOG(ERR, "Failed to set rss cfg, err: %d, status: 0x%x, out size: 0x%x",
1141 err, rss_cfg.mgmt_msg_head.status, out_size);
1149 * hinic_rss_template_alloc - Get rss template id from the chip,
1150 * all functions share 96 templates.
1153 * The hardware interface of a nic device.
1155 * Index of rss template from chip.
1159 * negative error value otherwise.
1161 int hinic_rss_template_alloc(void *hwdev, u8 *tmpl_idx)
1163 struct hinic_rss_template_mgmt template_mgmt;
1164 u16 out_size = sizeof(template_mgmt);
1167 if (!hwdev || !tmpl_idx) {
1168 PMD_DRV_LOG(ERR, "Hwdev or tmpl_idx is NULL");
1172 memset(&template_mgmt, 0, sizeof(template_mgmt));
1173 template_mgmt.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1174 template_mgmt.func_id = hinic_global_func_id(hwdev);
1175 template_mgmt.cmd = NIC_RSS_CMD_TEMP_ALLOC;
1177 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR,
1178 &template_mgmt, sizeof(template_mgmt),
1179 &template_mgmt, &out_size);
1180 if (err || !out_size || template_mgmt.mgmt_msg_head.status) {
1181 PMD_DRV_LOG(ERR, "Failed to alloc rss template, err: %d, status: 0x%x, out size: 0x%x",
1182 err, template_mgmt.mgmt_msg_head.status, out_size);
1186 *tmpl_idx = template_mgmt.template_id;
1192 * hinic_rss_template_free - Free rss template id to the chip.
1195 * The hardware interface of a nic device.
1197 * Index of rss template from chip.
1201 * negative error value otherwise.
1203 int hinic_rss_template_free(void *hwdev, u8 tmpl_idx)
1205 struct hinic_rss_template_mgmt template_mgmt;
1206 u16 out_size = sizeof(template_mgmt);
1210 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1214 memset(&template_mgmt, 0, sizeof(template_mgmt));
1215 template_mgmt.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1216 template_mgmt.func_id = hinic_global_func_id(hwdev);
1217 template_mgmt.template_id = tmpl_idx;
1218 template_mgmt.cmd = NIC_RSS_CMD_TEMP_FREE;
1220 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR,
1221 &template_mgmt, sizeof(template_mgmt),
1222 &template_mgmt, &out_size);
1223 if (err || !out_size || template_mgmt.mgmt_msg_head.status) {
1224 PMD_DRV_LOG(ERR, "Failed to free rss template, err: %d, status: 0x%x, out size: 0x%x",
1225 err, template_mgmt.mgmt_msg_head.status, out_size);
1233 * hinic_set_rx_vhd_mode - Change rx buffer size after initialization.
1236 * The hardware interface of a nic device.
1240 * receive buffer size.
1244 * negative error value otherwise.
1246 int hinic_set_rx_vhd_mode(void *hwdev, u16 vhd_mode, u16 rx_buf_sz)
1248 struct hinic_set_vhd_mode vhd_mode_cfg;
1249 u16 out_size = sizeof(vhd_mode_cfg);
1253 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1257 memset(&vhd_mode_cfg, 0, sizeof(vhd_mode_cfg));
1259 vhd_mode_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1260 vhd_mode_cfg.func_id = hinic_global_func_id(hwdev);
1261 vhd_mode_cfg.vhd_type = vhd_mode;
1262 vhd_mode_cfg.rx_wqe_buffer_size = rx_buf_sz;
1264 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_VHD_CFG,
1265 &vhd_mode_cfg, sizeof(vhd_mode_cfg),
1266 &vhd_mode_cfg, &out_size);
1267 if (err || !out_size || vhd_mode_cfg.mgmt_msg_head.status) {
1269 "Failed to set vhd mode, err: %d, status: 0x%x, out size: 0x%x",
1270 err, vhd_mode_cfg.mgmt_msg_head.status, out_size);
1277 int hinic_set_rx_mode(void *hwdev, u32 enable)
1279 struct hinic_rx_mode_config rx_mode_cfg;
1280 u16 out_size = sizeof(rx_mode_cfg);
1284 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1288 memset(&rx_mode_cfg, 0, sizeof(rx_mode_cfg));
1289 rx_mode_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1290 rx_mode_cfg.func_id = hinic_global_func_id(hwdev);
1291 rx_mode_cfg.rx_mode = enable;
1293 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RX_MODE,
1294 &rx_mode_cfg, sizeof(rx_mode_cfg),
1295 &rx_mode_cfg, &out_size);
1296 if (err || !out_size || rx_mode_cfg.mgmt_msg_head.status) {
1297 PMD_DRV_LOG(ERR, "Failed to set rx mode, err: %d, status: 0x%x, out size: 0x%x",
1298 err, rx_mode_cfg.mgmt_msg_head.status, out_size);
1306 * hinic_get_mgmt_version - Get mgmt module version from chip.
1309 * The hardware interface of a nic device.
1315 * negative error value otherwise.
1317 int hinic_get_mgmt_version(void *hwdev, char *fw)
1319 struct hinic_version_info fw_ver;
1320 u16 out_size = sizeof(fw_ver);
1323 if (!hwdev || !fw) {
1324 PMD_DRV_LOG(ERR, "Hwdev or fw is NULL");
1328 memset(&fw_ver, 0, sizeof(fw_ver));
1329 fw_ver.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1331 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_MGMT_VERSION,
1332 &fw_ver, sizeof(fw_ver), &fw_ver,
1334 if (err || !out_size || fw_ver.mgmt_msg_head.status) {
1335 PMD_DRV_LOG(ERR, "Failed to get mgmt version, err: %d, status: 0x%x, out size: 0x%x\n",
1336 err, fw_ver.mgmt_msg_head.status, out_size);
1340 snprintf(fw, HINIC_MGMT_VERSION_MAX_LEN, "%s", fw_ver.ver);
1345 int hinic_set_rx_csum_offload(void *hwdev, u32 en)
1347 struct hinic_checksum_offload rx_csum_cfg;
1348 u16 out_size = sizeof(rx_csum_cfg);
1352 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1356 memset(&rx_csum_cfg, 0, sizeof(rx_csum_cfg));
1357 rx_csum_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1358 rx_csum_cfg.func_id = hinic_global_func_id(hwdev);
1359 rx_csum_cfg.rx_csum_offload = en;
1361 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RX_CSUM,
1362 &rx_csum_cfg, sizeof(rx_csum_cfg),
1363 &rx_csum_cfg, &out_size);
1364 if (err || !out_size || rx_csum_cfg.mgmt_msg_head.status) {
1366 "Failed to set rx csum offload, err: %d, status: 0x%x, out size: 0x%x",
1367 err, rx_csum_cfg.mgmt_msg_head.status, out_size);
1374 int hinic_set_rx_lro(void *hwdev, u8 ipv4_en, u8 ipv6_en, u8 max_wqe_num)
1376 struct hinic_lro_config lro_cfg;
1377 u16 out_size = sizeof(lro_cfg);
1381 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1385 memset(&lro_cfg, 0, sizeof(lro_cfg));
1386 lro_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1387 lro_cfg.func_id = hinic_global_func_id(hwdev);
1388 lro_cfg.lro_ipv4_en = ipv4_en;
1389 lro_cfg.lro_ipv6_en = ipv6_en;
1390 lro_cfg.lro_max_wqe_num = max_wqe_num;
1392 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_LRO,
1393 &lro_cfg, sizeof(lro_cfg), &lro_cfg,
1395 if (err || !out_size || lro_cfg.mgmt_msg_head.status) {
1396 PMD_DRV_LOG(ERR, "Failed to set lro offload, err: %d, status: 0x%x, out size: 0x%x",
1397 err, lro_cfg.mgmt_msg_head.status, out_size);
1404 int hinic_set_anti_attack(void *hwdev, bool enable)
1406 struct hinic_port_anti_attack_rate rate;
1407 u16 out_size = sizeof(rate);
1411 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1415 memset(&rate, 0, sizeof(rate));
1416 rate.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1417 rate.func_id = hinic_global_func_id(hwdev);
1418 rate.enable = enable;
1419 rate.cir = ANTI_ATTACK_DEFAULT_CIR;
1420 rate.xir = ANTI_ATTACK_DEFAULT_XIR;
1421 rate.cbs = ANTI_ATTACK_DEFAULT_CBS;
1422 rate.xbs = ANTI_ATTACK_DEFAULT_XBS;
1424 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_ANTI_ATTACK_RATE,
1425 &rate, sizeof(rate), &rate, &out_size);
1426 if (err || !out_size || rate.mgmt_msg_head.status) {
1427 PMD_DRV_LOG(ERR, "Can't %s port Anti-Attack rate limit, err: %d, status: 0x%x, out size: 0x%x",
1428 (enable ? "enable" : "disable"), err,
1429 rate.mgmt_msg_head.status, out_size);
1436 /* Set autoneg status and restart port link status */
1437 int hinic_reset_port_link_cfg(void *hwdev)
1439 struct hinic_reset_link_cfg reset_cfg;
1440 u16 out_size = sizeof(reset_cfg);
1443 memset(&reset_cfg, 0, sizeof(reset_cfg));
1444 reset_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1445 reset_cfg.func_id = hinic_global_func_id(hwdev);
1447 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RESET_LINK_CFG,
1448 &reset_cfg, sizeof(reset_cfg),
1449 &reset_cfg, &out_size);
1450 if (err || !out_size || reset_cfg.mgmt_msg_head.status) {
1451 PMD_DRV_LOG(ERR, "Reset port link configure failed, err: %d, status: 0x%x, out size: 0x%x",
1452 err, reset_cfg.mgmt_msg_head.status, out_size);
1460 * hinic_vf_func_init - Register VF to PF.
1463 * The hardware interface of a nic device.
1467 * negative error value otherwise.
1469 int hinic_vf_func_init(struct hinic_hwdev *hwdev)
1473 if (!HINIC_IS_VF(hwdev))
1476 err = hinic_mbox_to_pf(hwdev, HINIC_MOD_L2NIC,
1477 HINIC_PORT_CMD_VF_REGISTER, &state, sizeof(state),
1480 PMD_DRV_LOG(ERR, "Fail to register vf");
1488 * hinic_vf_func_free - Unregister VF from PF.
1491 * The hardware interface of a nic device.
1493 void hinic_vf_func_free(struct hinic_hwdev *hwdev)
1497 if (hinic_func_type(hwdev) != TYPE_VF)
1500 err = hinic_mbox_to_pf(hwdev, HINIC_MOD_L2NIC,
1501 HINIC_PORT_CMD_VF_UNREGISTER, &err, sizeof(err),
1504 PMD_DRV_LOG(ERR, "Fail to unregister VF, err: %d", err);
1507 int hinic_set_fast_recycle_mode(void *hwdev, u8 mode)
1509 struct hinic_fast_recycled_mode fast_recycled_mode;
1510 u16 out_size = sizeof(fast_recycled_mode);
1514 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1518 memset(&fast_recycled_mode, 0, sizeof(fast_recycled_mode));
1519 fast_recycled_mode.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1520 fast_recycled_mode.func_id = hinic_global_func_id(hwdev);
1521 fast_recycled_mode.fast_recycled_mode = mode;
1523 err = hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_COMM,
1524 HINIC_MGMT_CMD_FAST_RECYCLE_MODE_SET,
1525 &fast_recycled_mode,
1526 sizeof(fast_recycled_mode),
1527 &fast_recycled_mode, &out_size, 0);
1528 if (err || fast_recycled_mode.mgmt_msg_head.status || !out_size) {
1529 PMD_DRV_LOG(ERR, "Failed to set recycle mode, err: %d, status: 0x%x, out size: 0x%x",
1530 err, fast_recycled_mode.mgmt_msg_head.status, out_size);
1537 int hinic_clear_vport_stats(struct hinic_hwdev *hwdev)
1539 struct hinic_clear_vport_stats clear_vport_stats;
1540 u16 out_size = sizeof(clear_vport_stats);
1544 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1548 memset(&clear_vport_stats, 0, sizeof(clear_vport_stats));
1549 clear_vport_stats.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1550 clear_vport_stats.func_id = hinic_global_func_id(hwdev);
1552 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_CLEAN_VPORT_STAT,
1554 sizeof(clear_vport_stats),
1555 &clear_vport_stats, &out_size);
1556 if (err || !out_size || clear_vport_stats.mgmt_msg_head.status) {
1557 PMD_DRV_LOG(ERR, "Failed to clear vport statistics, err: %d, status: 0x%x, out size: 0x%x",
1558 err, clear_vport_stats.mgmt_msg_head.status, out_size);
1565 int hinic_clear_phy_port_stats(struct hinic_hwdev *hwdev)
1567 struct hinic_clear_port_stats clear_phy_port_stats;
1568 u16 out_size = sizeof(clear_phy_port_stats);
1572 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1576 memset(&clear_phy_port_stats, 0, sizeof(clear_phy_port_stats));
1577 clear_phy_port_stats.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1578 clear_phy_port_stats.func_id = hinic_global_func_id(hwdev);
1580 err = l2nic_msg_to_mgmt_sync(hwdev,
1581 HINIC_PORT_CMD_CLEAR_PORT_STATISTICS,
1582 &clear_phy_port_stats,
1583 sizeof(clear_phy_port_stats),
1584 &clear_phy_port_stats, &out_size);
1585 if (err || !out_size || clear_phy_port_stats.mgmt_msg_head.status) {
1586 PMD_DRV_LOG(ERR, "Failed to clear phy port statistics, err: %d, status: 0x%x, out size: 0x%x",
1587 err, clear_phy_port_stats.mgmt_msg_head.status,
1595 int hinic_set_link_status_follow(void *hwdev,
1596 enum hinic_link_follow_status status)
1598 struct hinic_set_link_follow follow;
1599 u16 out_size = sizeof(follow);
1605 if (HINIC_IS_VF((struct hinic_hwdev *)hwdev))
1608 if (status >= HINIC_LINK_FOLLOW_STATUS_MAX) {
1609 PMD_DRV_LOG(ERR, "Invalid link follow status: %d", status);
1613 memset(&follow, 0, sizeof(follow));
1614 follow.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1615 follow.func_id = hinic_global_func_id(hwdev);
1616 follow.follow_status = status;
1618 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_LINK_FOLLOW,
1619 &follow, sizeof(follow),
1620 &follow, &out_size);
1621 if ((follow.mgmt_msg_head.status != HINIC_MGMT_CMD_UNSUPPORTED &&
1622 follow.mgmt_msg_head.status) || err || !out_size) {
1624 "Failed to set link status follow phy port status, err: %d, status: 0x%x, out size: 0x%x",
1625 err, follow.mgmt_msg_head.status, out_size);
1629 return follow.mgmt_msg_head.status;
1632 int hinic_get_link_mode(void *hwdev, u32 *supported, u32 *advertised)
1634 struct hinic_link_mode_cmd link_mode;
1635 u16 out_size = sizeof(link_mode);
1638 if (!hwdev || !supported || !advertised)
1641 memset(&link_mode, 0, sizeof(link_mode));
1642 link_mode.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1643 link_mode.func_id = hinic_global_func_id(hwdev);
1645 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_LINK_MODE,
1646 &link_mode, sizeof(link_mode),
1647 &link_mode, &out_size);
1648 if (err || !out_size || link_mode.mgmt_msg_head.status) {
1650 "Failed to get link mode, err: %d, status: 0x%x, out size: 0x%x",
1651 err, link_mode.mgmt_msg_head.status, out_size);
1655 *supported = link_mode.supported;
1656 *advertised = link_mode.advertised;
1662 * hinic_set_xsfp_tx_status - Enable or disable the fiber in
1663 * tx direction when set link up or down.
1666 * The hardware interface of a nic device.
1668 * Enable or Disable.
1672 * negative error value otherwise.
1674 int hinic_set_xsfp_tx_status(void *hwdev, bool enable)
1676 struct hinic_set_xsfp_status xsfp_status;
1677 u16 out_size = sizeof(struct hinic_set_xsfp_status);
1680 memset(&xsfp_status, 0, sizeof(xsfp_status));
1681 xsfp_status.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1682 xsfp_status.port_id = hinic_global_func_id(hwdev);
1683 xsfp_status.xsfp_tx_dis = ((enable == 0) ? 1 : 0);
1685 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_XSFP_STATUS,
1686 &xsfp_status, sizeof(struct hinic_set_xsfp_status),
1687 &xsfp_status, &out_size);
1688 if (err || !out_size || xsfp_status.mgmt_msg_head.status) {
1690 "Failed to %s port xsfp status, err: %d, status: 0x%x, out size: 0x%x\n",
1691 enable ? "Disable" : "Enable", err,
1692 xsfp_status.mgmt_msg_head.status, out_size);
1700 * hinic_flush_qp_res - Flush tx && rx chip resources in case of set vport
1701 * fake failed when device start.
1704 * The hardware interface of a nic device.
1708 * negative error value otherwise.
1710 int hinic_flush_qp_res(void *hwdev)
1712 struct hinic_clear_qp_resource qp_res;
1713 u16 out_size = sizeof(qp_res);
1716 memset(&qp_res, 0, sizeof(qp_res));
1717 qp_res.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1718 qp_res.func_id = hinic_global_func_id(hwdev);
1720 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_CLEAR_QP_RES,
1721 &qp_res, sizeof(qp_res), &qp_res,
1723 if (err || !out_size || qp_res.mgmt_msg_head.status) {
1724 PMD_DRV_LOG(ERR, "Failed to clear sq resources, err: %d, status: 0x%x, out size: 0x%x",
1725 err, qp_res.mgmt_msg_head.status, out_size);
1733 * hinic_vf_get_default_cos - Get default cos of VF.
1736 * The hardware interface of a nic device.
1742 * negative error value otherwise.
1744 int hinic_vf_get_default_cos(struct hinic_hwdev *hwdev, u8 *cos_id)
1746 struct hinic_vf_default_cos vf_cos;
1747 u16 out_size = sizeof(vf_cos);
1750 memset(&vf_cos, 0, sizeof(vf_cos));
1751 vf_cos.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1753 err = hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_L2NIC,
1754 HINIC_PORT_CMD_GET_VF_COS, &vf_cos,
1755 sizeof(vf_cos), &vf_cos, &out_size, 0);
1756 if (err || !out_size || vf_cos.mgmt_msg_head.status) {
1757 PMD_DRV_LOG(ERR, "Get VF default cos failed, err: %d, status: 0x%x, out size: 0x%x",
1758 err, vf_cos.mgmt_msg_head.status, out_size);
1761 *cos_id = vf_cos.state.default_cos;
1767 * hinic_set_fdir_filter - Set fdir filter for control path
1768 * packet to notify firmware.
1771 * The hardware interface of a nic device.
1772 * @param filter_type
1773 * Packet type to filter.
1776 * @param type_enable
1777 * The status of pkt type filter.
1779 * Fdir function Enable or Disable.
1782 * negative error value otherwise.
1784 int hinic_set_fdir_filter(void *hwdev, u8 filter_type, u8 qid, u8 type_enable,
1787 struct hinic_port_qfilter_info port_filer_cmd;
1788 u16 out_size = sizeof(port_filer_cmd);
1794 memset(&port_filer_cmd, 0, sizeof(port_filer_cmd));
1795 port_filer_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1796 port_filer_cmd.func_id = hinic_global_func_id(hwdev);
1797 port_filer_cmd.filter_enable = (u8)enable;
1798 port_filer_cmd.filter_type = filter_type;
1799 port_filer_cmd.qid = qid;
1800 port_filer_cmd.filter_type_enable = type_enable;
1801 port_filer_cmd.fdir_flag = 0;
1803 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_Q_FILTER,
1804 &port_filer_cmd, sizeof(port_filer_cmd),
1805 &port_filer_cmd, &out_size);
1806 if (err || !out_size || port_filer_cmd.mgmt_msg_head.status) {
1807 PMD_DRV_LOG(ERR, "Set port Q filter failed, err: %d, status: 0x%x, out size: 0x%x, type: 0x%x,"
1808 " enable: 0x%x, qid: 0x%x, filter_type_enable: 0x%x\n",
1809 err, port_filer_cmd.mgmt_msg_head.status, out_size,
1810 filter_type, enable, qid, type_enable);
1818 * hinic_set_normal_filter - Set fdir filter for IO path packet.
1821 * The hardware interface of a nic device.
1824 * @param normal_type_enable
1825 * IO path packet function Enable or Disable
1827 * IO path packet filter key value, such as DIP from pkt.
1829 * Fdir function Enable or Disable.
1831 * Filter flag, such as dip or others.
1834 * negative error value otherwise.
1836 int hinic_set_normal_filter(void *hwdev, u8 qid, u8 normal_type_enable,
1837 u32 key, bool enable, u8 flag)
1839 struct hinic_port_qfilter_info port_filer_cmd;
1840 u16 out_size = sizeof(port_filer_cmd);
1846 memset(&port_filer_cmd, 0, sizeof(port_filer_cmd));
1847 port_filer_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1848 port_filer_cmd.func_id = hinic_global_func_id(hwdev);
1849 port_filer_cmd.filter_enable = (u8)enable;
1850 port_filer_cmd.qid = qid;
1851 port_filer_cmd.normal_type_enable = normal_type_enable;
1852 port_filer_cmd.fdir_flag = flag; /* fdir flag: support dip */
1853 port_filer_cmd.key = key;
1855 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_Q_FILTER,
1856 &port_filer_cmd, sizeof(port_filer_cmd),
1857 &port_filer_cmd, &out_size);
1858 if (err || !out_size || port_filer_cmd.mgmt_msg_head.status) {
1859 PMD_DRV_LOG(ERR, "Set normal filter failed, err: %d, status: 0x%x, out size: 0x%x, fdir_flag: 0x%x,"
1860 " enable: 0x%x, qid: 0x%x, normal_type_enable: 0x%x, key:0x%x\n",
1861 err, port_filer_cmd.mgmt_msg_head.status, out_size,
1862 flag, enable, qid, normal_type_enable, key);
1870 * hinic_set_fdir_tcam - Set fdir filter for control packet
1871 * by tcam table to notify hardware.
1874 * The hardware interface of a nic device.
1877 * @param filter_rule
1878 * TCAM rule for control packet, such as lacp or bgp.
1879 * @param filter_action
1880 * TCAM action for control packet, such as accept or drop.
1883 * negative error value otherwise.
1885 int hinic_set_fdir_tcam(void *hwdev, u16 type_mask,
1886 struct tag_pa_rule *filter_rule,
1887 struct tag_pa_action *filter_action)
1889 struct hinic_fdir_tcam_info port_tcam_cmd;
1890 u16 out_size = sizeof(port_tcam_cmd);
1896 memset(&port_tcam_cmd, 0, sizeof(port_tcam_cmd));
1897 port_tcam_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1898 port_tcam_cmd.tcam_index = type_mask;
1899 port_tcam_cmd.flag = TCAM_SET;
1900 memcpy((void *)&port_tcam_cmd.filter_rule,
1901 (void *)filter_rule, sizeof(struct tag_pa_rule));
1902 memcpy((void *)&port_tcam_cmd.filter_action,
1903 (void *)filter_action, sizeof(struct tag_pa_action));
1905 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_TCAM_FILTER,
1906 &port_tcam_cmd, sizeof(port_tcam_cmd),
1907 &port_tcam_cmd, &out_size);
1908 if (err || !out_size || port_tcam_cmd.mgmt_msg_head.status) {
1909 PMD_DRV_LOG(ERR, "Set tcam table failed, err: %d, status: 0x%x, out size: 0x%x",
1910 err, port_tcam_cmd.mgmt_msg_head.status, out_size);
1918 * hinic_clear_fdir_tcam - Clear fdir filter TCAM table for control packet.
1921 * The hardware interface of a nic device.
1926 * negative error value otherwise.
1928 int hinic_clear_fdir_tcam(void *hwdev, u16 type_mask)
1930 struct hinic_fdir_tcam_info port_tcam_cmd;
1931 u16 out_size = sizeof(port_tcam_cmd);
1937 memset(&port_tcam_cmd, 0, sizeof(port_tcam_cmd));
1938 port_tcam_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1939 port_tcam_cmd.tcam_index = type_mask;
1940 port_tcam_cmd.flag = TCAM_CLEAR;
1942 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_TCAM_FILTER,
1943 &port_tcam_cmd, sizeof(port_tcam_cmd),
1944 &port_tcam_cmd, &out_size);
1945 if (err || !out_size || port_tcam_cmd.mgmt_msg_head.status) {
1946 PMD_DRV_LOG(ERR, "Clear tcam table failed, err: %d, status: 0x%x, out size: 0x%x",
1947 err, port_tcam_cmd.mgmt_msg_head.status, out_size);
1954 int hinic_add_tcam_rule(void *hwdev, struct tag_tcam_cfg_rule *tcam_rule)
1956 u16 out_size = sizeof(struct tag_fdir_add_rule_cmd);
1957 struct tag_fdir_add_rule_cmd tcam_cmd;
1961 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1965 if (tcam_rule->index >= HINIC_MAX_TCAM_RULES_NUM) {
1966 PMD_DRV_LOG(ERR, "Tcam rules num to add is invalid");
1970 memset(&tcam_cmd, 0, sizeof(struct tag_fdir_add_rule_cmd));
1971 tcam_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
1972 memcpy((void *)&tcam_cmd.rule, (void *)tcam_rule,
1973 sizeof(struct tag_tcam_cfg_rule));
1975 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_UP_TC_ADD_FLOW,
1976 &tcam_cmd, sizeof(tcam_cmd),
1977 &tcam_cmd, &out_size);
1978 if (err || tcam_cmd.mgmt_msg_head.status || !out_size) {
1980 "Add tcam rule failed, err: %d, status: 0x%x, out size: 0x%x",
1981 err, tcam_cmd.mgmt_msg_head.status, out_size);
1988 int hinic_del_tcam_rule(void *hwdev, u32 index)
1990 u16 out_size = sizeof(struct tag_fdir_del_rule_cmd);
1991 struct tag_fdir_del_rule_cmd tcam_cmd;
1995 PMD_DRV_LOG(ERR, "Hwdev is NULL");
1999 if (index >= HINIC_MAX_TCAM_RULES_NUM) {
2000 PMD_DRV_LOG(ERR, "Tcam rules num to del is invalid");
2004 memset(&tcam_cmd, 0, sizeof(struct tag_fdir_del_rule_cmd));
2005 tcam_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
2006 tcam_cmd.index_start = index;
2007 tcam_cmd.index_num = 1;
2009 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_UP_TC_DEL_FLOW,
2010 &tcam_cmd, sizeof(tcam_cmd),
2011 &tcam_cmd, &out_size);
2012 if (err || tcam_cmd.mgmt_msg_head.status || !out_size) {
2014 "Del tcam rule failed, err: %d, status: 0x%x, out size: 0x%x",
2015 err, tcam_cmd.mgmt_msg_head.status, out_size);
2022 static int hinic_mgmt_tcam_block(void *hwdev, u8 alloc_en,
2023 u8 block_type, u16 *index)
2025 struct hinic_cmd_ctrl_tcam_block tcam_block_info;
2026 u16 out_size = sizeof(struct hinic_cmd_ctrl_tcam_block);
2027 struct hinic_hwdev *nic_hwdev = (struct hinic_hwdev *)hwdev;
2031 PMD_DRV_LOG(ERR, "Hwdev is NULL");
2035 memset(&tcam_block_info, 0, sizeof(struct hinic_cmd_ctrl_tcam_block));
2036 tcam_block_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
2037 tcam_block_info.func_id = hinic_global_func_id(hwdev);
2038 tcam_block_info.alloc_en = alloc_en;
2039 tcam_block_info.tcam_type = block_type;
2040 tcam_block_info.tcam_block_index = *index;
2042 err = l2nic_msg_to_mgmt_sync(hwdev,
2043 HINIC_PORT_CMD_UP_TC_CTRL_TCAM_BLOCK,
2044 &tcam_block_info, sizeof(tcam_block_info),
2045 &tcam_block_info, &out_size);
2046 if (tcam_block_info.mgmt_msg_head.status ==
2047 HINIC_MGMT_CMD_UNSUPPORTED) {
2048 err = HINIC_MGMT_CMD_UNSUPPORTED;
2049 PMD_DRV_LOG(INFO, "Firmware/uP doesn't support alloc or del tcam block");
2051 } else if ((err == HINIC_MBOX_VF_CMD_ERROR) &&
2052 (HINIC_IS_VF(nic_hwdev))) {
2053 err = HINIC_MGMT_CMD_UNSUPPORTED;
2054 PMD_DRV_LOG(INFO, "VF doesn't support alloc and del tcam block.");
2056 } else if (err || (!out_size) || tcam_block_info.mgmt_msg_head.status) {
2058 "Set tcam block failed, err: %d, status: 0x%x, out size: 0x%x",
2059 err, tcam_block_info.mgmt_msg_head.status, out_size);
2064 *index = tcam_block_info.tcam_block_index;
2069 int hinic_alloc_tcam_block(void *hwdev, u8 block_type, u16 *index)
2071 return hinic_mgmt_tcam_block(hwdev, HINIC_TCAM_BLOCK_ENABLE,
2075 int hinic_free_tcam_block(void *hwdev, u8 block_type, u16 *index)
2077 return hinic_mgmt_tcam_block(hwdev, HINIC_TCAM_BLOCK_DISABLE,
2081 int hinic_flush_tcam_rule(void *hwdev)
2083 struct hinic_cmd_flush_tcam_rules tcam_flush;
2084 u16 out_size = sizeof(struct hinic_cmd_flush_tcam_rules);
2085 struct hinic_hwdev *nic_hwdev = (struct hinic_hwdev *)hwdev;
2089 PMD_DRV_LOG(ERR, "Hwdev is NULL");
2093 memset(&tcam_flush, 0, sizeof(struct hinic_cmd_flush_tcam_rules));
2094 tcam_flush.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
2095 tcam_flush.func_id = hinic_global_func_id(hwdev);
2097 err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_UP_TC_FLUSH_TCAM,
2098 &tcam_flush, sizeof(struct hinic_cmd_flush_tcam_rules),
2099 &tcam_flush, &out_size);
2100 if (tcam_flush.mgmt_msg_head.status == HINIC_MGMT_CMD_UNSUPPORTED) {
2101 err = HINIC_MGMT_CMD_UNSUPPORTED;
2102 PMD_DRV_LOG(INFO, "Firmware/uP doesn't support flush tcam fdir");
2103 } else if ((err == HINIC_MBOX_VF_CMD_ERROR) &&
2104 (HINIC_IS_VF(nic_hwdev))) {
2105 err = HINIC_MGMT_CMD_UNSUPPORTED;
2106 PMD_DRV_LOG(INFO, "VF doesn't support flush tcam fdir");
2107 } else if (err || (!out_size) || tcam_flush.mgmt_msg_head.status) {
2109 "Flush tcam fdir rules failed, err: %d, status: 0x%x, out size: 0x%x",
2110 err, tcam_flush.mgmt_msg_head.status, out_size);