1 /* 2 * Huawei HiNIC PCI Express Linux driver 3 * Copyright(c) 2017 Huawei Technologies Co., Ltd 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms and conditions of the GNU General Public License, 7 * version 2, as published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * for more details. 13 * 14 */ 15 16 #ifndef HINIC_PORT_H 17 #define HINIC_PORT_H 18 19 #include <linux/types.h> 20 #include <linux/etherdevice.h> 21 #include <linux/bitops.h> 22 23 #include "hinic_dev.h" 24 25 enum hinic_rx_mode { 26 HINIC_RX_MODE_UC = BIT(0), 27 HINIC_RX_MODE_MC = BIT(1), 28 HINIC_RX_MODE_BC = BIT(2), 29 HINIC_RX_MODE_MC_ALL = BIT(3), 30 HINIC_RX_MODE_PROMISC = BIT(4), 31 }; 32 33 enum hinic_port_link_state { 34 HINIC_LINK_STATE_DOWN, 35 HINIC_LINK_STATE_UP, 36 }; 37 38 enum hinic_port_state { 39 HINIC_PORT_DISABLE = 0, 40 HINIC_PORT_ENABLE = 3, 41 }; 42 43 enum hinic_func_port_state { 44 HINIC_FUNC_PORT_DISABLE = 0, 45 HINIC_FUNC_PORT_ENABLE = 2, 46 }; 47 48 enum hinic_autoneg_cap { 49 HINIC_AUTONEG_UNSUPPORTED, 50 HINIC_AUTONEG_SUPPORTED, 51 }; 52 53 enum hinic_autoneg_state { 54 HINIC_AUTONEG_DISABLED, 55 HINIC_AUTONEG_ACTIVE, 56 }; 57 58 enum hinic_duplex { 59 HINIC_DUPLEX_HALF, 60 HINIC_DUPLEX_FULL, 61 }; 62 63 enum hinic_speed { 64 HINIC_SPEED_10MB_LINK = 0, 65 HINIC_SPEED_100MB_LINK, 66 HINIC_SPEED_1000MB_LINK, 67 HINIC_SPEED_10GB_LINK, 68 HINIC_SPEED_25GB_LINK, 69 HINIC_SPEED_40GB_LINK, 70 HINIC_SPEED_100GB_LINK, 71 72 HINIC_SPEED_UNKNOWN = 0xFF, 73 }; 74 75 struct hinic_port_mac_cmd { 76 u8 status; 77 u8 version; 78 u8 rsvd0[6]; 79 80 u16 func_idx; 81 u16 vlan_id; 82 u16 rsvd1; 83 unsigned char mac[ETH_ALEN]; 84 }; 85 86 struct hinic_port_mtu_cmd { 87 u8 status; 88 u8 version; 89 u8 rsvd0[6]; 90 91 u16 func_idx; 92 u16 rsvd1; 93 u32 mtu; 94 }; 95 96 struct hinic_port_vlan_cmd { 97 u8 status; 98 u8 version; 99 u8 rsvd0[6]; 100 101 u16 func_idx; 102 u16 vlan_id; 103 }; 104 105 struct hinic_port_rx_mode_cmd { 106 u8 status; 107 u8 version; 108 u8 rsvd0[6]; 109 110 u16 func_idx; 111 u16 rsvd; 112 u32 rx_mode; 113 }; 114 115 struct hinic_port_link_cmd { 116 u8 status; 117 u8 version; 118 u8 rsvd0[6]; 119 120 u16 func_idx; 121 u8 state; 122 u8 rsvd1; 123 }; 124 125 struct hinic_port_state_cmd { 126 u8 status; 127 u8 version; 128 u8 rsvd0[6]; 129 130 u8 state; 131 u8 rsvd1[3]; 132 }; 133 134 struct hinic_port_link_status { 135 u8 status; 136 u8 version; 137 u8 rsvd0[6]; 138 139 u16 rsvd1; 140 u8 link; 141 u8 rsvd2; 142 }; 143 144 struct hinic_port_func_state_cmd { 145 u8 status; 146 u8 version; 147 u8 rsvd0[6]; 148 149 u16 func_idx; 150 u16 rsvd1; 151 u8 state; 152 u8 rsvd2[3]; 153 }; 154 155 struct hinic_port_cap { 156 u8 status; 157 u8 version; 158 u8 rsvd0[6]; 159 160 u16 func_idx; 161 u16 rsvd1; 162 u8 port_type; 163 u8 autoneg_cap; 164 u8 autoneg_state; 165 u8 duplex; 166 u8 speed; 167 u8 rsvd2[3]; 168 }; 169 170 int hinic_port_add_mac(struct hinic_dev *nic_dev, const u8 *addr, 171 u16 vlan_id); 172 173 int hinic_port_del_mac(struct hinic_dev *nic_dev, const u8 *addr, 174 u16 vlan_id); 175 176 int hinic_port_get_mac(struct hinic_dev *nic_dev, u8 *addr); 177 178 int hinic_port_set_mtu(struct hinic_dev *nic_dev, int new_mtu); 179 180 int hinic_port_add_vlan(struct hinic_dev *nic_dev, u16 vlan_id); 181 182 int hinic_port_del_vlan(struct hinic_dev *nic_dev, u16 vlan_id); 183 184 int hinic_port_set_rx_mode(struct hinic_dev *nic_dev, u32 rx_mode); 185 186 int hinic_port_link_state(struct hinic_dev *nic_dev, 187 enum hinic_port_link_state *link_state); 188 189 int hinic_port_set_state(struct hinic_dev *nic_dev, 190 enum hinic_port_state state); 191 192 int hinic_port_set_func_state(struct hinic_dev *nic_dev, 193 enum hinic_func_port_state state); 194 195 int hinic_port_get_cap(struct hinic_dev *nic_dev, 196 struct hinic_port_cap *port_cap); 197 198 #endif 199