| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. */ |
| 3 |
|
| 4 |
#ifndef _HINIC3_NIC_CFG_H_ |
| 5 |
#define _HINIC3_NIC_CFG_H_ |
| 6 |
|
| 7 |
#include <linux/types.h> |
| 8 |
|
| 9 |
#include "hinic3_hw_intf.h" |
| 10 |
#include "hinic3_mgmt_interface.h" |
| 11 |
|
| 12 |
struct hinic3_hwdev; |
| 13 |
struct hinic3_nic_dev; |
| 14 |
|
| 15 |
#define HINIC3_MIN_MTU_SIZE 256 |
| 16 |
#define HINIC3_MAX_JUMBO_FRAME_SIZE 9600 |
| 17 |
|
| 18 |
#define HINIC3_VLAN_ID_MASK 0x7FFF |
| 19 |
#define HINIC3_PF_SET_VF_ALREADY 0x4 |
| 20 |
#define HINIC3_MGMT_STATUS_EXIST 0x6 |
| 21 |
|
| 22 |
enum hinic3_nic_event_type { |
| 23 |
HINIC3_NIC_EVENT_LINK_DOWN = 0, |
| 24 |
HINIC3_NIC_EVENT_LINK_UP = 1, |
| 25 |
HINIC3_NIC_EVENT_PORT_MODULE_EVENT = 2, |
| 26 |
}; |
| 27 |
|
| 28 |
struct hinic3_sq_attr { |
| 29 |
u8 dma_attr_off; |
| 30 |
u8 pending_limit; |
| 31 |
u8 coalescing_time; |
| 32 |
u8 intr_en; |
| 33 |
u16 intr_idx; |
| 34 |
u32 l2nic_sqn; |
| 35 |
u64 ci_dma_base; |
| 36 |
}; |
| 37 |
|
| 38 |
#define MAG_CMD_PORT_DISABLE 0x0 |
| 39 |
#define MAG_CMD_TX_ENABLE 0x1 |
| 40 |
#define MAG_CMD_RX_ENABLE 0x2 |
| 41 |
/* the physical port is disabled only when all pf of the port are set to down, |
| 42 |
* if any pf is enabled, the port is enabled |
| 43 |
*/ |
| 44 |
struct mag_cmd_set_port_enable { |
| 45 |
struct mgmt_msg_head head; |
| 46 |
|
| 47 |
u16 function_id; |
| 48 |
u16 rsvd0; |
| 49 |
|
| 50 |
/* bitmap bit0:tx_en bit1:rx_en */ |
| 51 |
u8 state; |
| 52 |
u8 rsvd1[3]; |
| 53 |
}; |
| 54 |
|
| 55 |
enum link_err_type { |
| 56 |
LINK_ERR_MODULE_UNRECOGENIZED, |
| 57 |
LINK_ERR_NUM, |
| 58 |
}; |
| 59 |
|
| 60 |
enum port_module_event_type { |
| 61 |
HINIC3_PORT_MODULE_CABLE_PLUGGED, |
| 62 |
HINIC3_PORT_MODULE_CABLE_UNPLUGGED, |
| 63 |
HINIC3_PORT_MODULE_LINK_ERR, |
| 64 |
HINIC3_PORT_MODULE_MAX_EVENT, |
| 65 |
}; |
| 66 |
|
| 67 |
struct hinic3_port_module_event { |
| 68 |
enum port_module_event_type type; |
| 69 |
enum link_err_type err_type; |
| 70 |
}; |
| 71 |
|
| 72 |
int hinic3_get_nic_feature_from_hw(struct hinic3_nic_dev *nic_dev); |
| 73 |
int hinic3_set_nic_feature_to_hw(struct hinic3_nic_dev *nic_dev); |
| 74 |
bool hinic3_test_support(struct hinic3_nic_dev *nic_dev, |
| 75 |
enum hinic3_nic_feature_cap feature_bits); |
| 76 |
void hinic3_update_nic_feature(struct hinic3_nic_dev *nic_dev, u64 feature_cap); |
| 77 |
|
| 78 |
int hinic3_set_rx_lro_state(struct hinic3_hwdev *hwdev, u8 lro_en, |
| 79 |
u32 lro_timer, u8 lro_max_pkt_len); |
| 80 |
int hinic3_set_rx_vlan_offload(struct hinic3_hwdev *hwdev, u8 en); |
| 81 |
int hinic3_set_vlan_filter(struct hinic3_hwdev *hwdev, u32 vlan_filter_ctrl); |
| 82 |
|
| 83 |
int hinic3_init_function_table(struct hinic3_nic_dev *nic_dev); |
| 84 |
int hinic3_set_port_mtu(struct net_device *netdev, u16 new_mtu); |
| 85 |
|
| 86 |
int hinic3_get_default_mac(struct hinic3_hwdev *hwdev, u8 *mac_addr); |
| 87 |
int hinic3_set_mac(struct hinic3_hwdev *hwdev, const u8 *mac_addr, u16 vlan_id, |
| 88 |
u16 func_id); |
| 89 |
int hinic3_del_mac(struct hinic3_hwdev *hwdev, const u8 *mac_addr, u16 vlan_id, |
| 90 |
u16 func_id); |
| 91 |
int hinic3_update_mac(struct hinic3_hwdev *hwdev, const u8 *old_mac, |
| 92 |
u8 *new_mac, u16 vlan_id, u16 func_id); |
| 93 |
|
| 94 |
int hinic3_set_ci_table(struct hinic3_hwdev *hwdev, |
| 95 |
struct hinic3_sq_attr *attr); |
| 96 |
int hinic3_flush_qps_res(struct hinic3_hwdev *hwdev); |
| 97 |
int hinic3_force_drop_tx_pkt(struct hinic3_hwdev *hwdev); |
| 98 |
int hinic3_set_rx_mode(struct hinic3_hwdev *hwdev, u32 rx_mode); |
| 99 |
|
| 100 |
int hinic3_sync_dcb_state(struct hinic3_hwdev *hwdev, u8 op_code, u8 state); |
| 101 |
int hinic3_set_port_enable(struct hinic3_hwdev *hwdev, bool enable); |
| 102 |
int hinic3_get_link_status(struct hinic3_hwdev *hwdev, bool *link_status_up); |
| 103 |
int hinic3_set_vport_enable(struct hinic3_hwdev *hwdev, u16 func_id, |
| 104 |
bool enable); |
| 105 |
int hinic3_add_vlan(struct hinic3_hwdev *hwdev, u16 vlan_id, u16 func_id); |
| 106 |
int hinic3_del_vlan(struct hinic3_hwdev *hwdev, u16 vlan_id, u16 func_id); |
| 107 |
|
| 108 |
#endif |