1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 2 /* QLogic qed NIC Driver 3 * Copyright (c) 2015-2017 QLogic Corporation 4 * Copyright (c) 2019-2020 Marvell International Ltd. 5 */ 6 7 #ifndef _QED_ETH_IF_H 8 #define _QED_ETH_IF_H 9 10 #include <linux/list.h> 11 #include <linux/if_link.h> 12 #include <linux/qed/eth_common.h> 13 #include <linux/qed/qed_if.h> 14 #include <linux/qed/qed_iov_if.h> 15 16 /* 64 max queues * (1 rx + 4 tx-cos + 1 xdp) */ 17 #define QED_MIN_L2_CONS (2 + NUM_PHYS_TCS_4PORT_K2) 18 #define QED_MAX_L2_CONS (64 * (QED_MIN_L2_CONS)) 19 20 struct qed_queue_start_common_params { 21 /* Should always be relative to entity sending this. */ 22 u8 vport_id; 23 u16 queue_id; 24 25 /* Relative, but relevant only for PFs */ 26 u8 stats_id; 27 28 struct qed_sb_info *p_sb; 29 u8 sb_idx; 30 31 u8 tc; 32 }; 33 34 struct qed_rxq_start_ret_params { 35 void __iomem *p_prod; 36 void *p_handle; 37 }; 38 39 struct qed_txq_start_ret_params { 40 void __iomem *p_doorbell; 41 void *p_handle; 42 }; 43 44 enum qed_filter_config_mode { 45 QED_FILTER_CONFIG_MODE_DISABLE, 46 QED_FILTER_CONFIG_MODE_5_TUPLE, 47 QED_FILTER_CONFIG_MODE_L4_PORT, 48 QED_FILTER_CONFIG_MODE_IP_DEST, 49 QED_FILTER_CONFIG_MODE_IP_SRC, 50 }; 51 52 struct qed_ntuple_filter_params { 53 /* Physically mapped address containing header of buffer to be used 54 * as filter. 55 */ 56 dma_addr_t addr; 57 58 /* Length of header in bytes */ 59 u16 length; 60 61 /* Relative queue-id to receive classified packet */ 62 #define QED_RFS_NTUPLE_QID_RSS ((u16)-1) 63 u16 qid; 64 65 /* Identifier can either be according to vport-id or vfid */ 66 bool b_is_vf; 67 u8 vport_id; 68 u8 vf_id; 69 70 /* true iff this filter is to be added. Else to be removed */ 71 bool b_is_add; 72 73 /* If flow needs to be dropped */ 74 bool b_is_drop; 75 }; 76 77 struct qed_dev_eth_info { 78 struct qed_dev_info common; 79 80 u8 num_queues; 81 u8 num_tc; 82 83 u8 port_mac[ETH_ALEN]; 84 u16 num_vlan_filters; 85 u16 num_mac_filters; 86 87 /* Legacy VF - this affects the datapath, so qede has to know */ 88 bool is_legacy; 89 90 /* Might depend on available resources [in case of VF] */ 91 bool xdp_supported; 92 }; 93 94 struct qed_update_vport_rss_params { 95 void *rss_ind_table[128]; 96 u32 rss_key[10]; 97 u8 rss_caps; 98 }; 99 100 struct qed_update_vport_params { 101 u8 vport_id; 102 u8 update_vport_active_flg; 103 u8 vport_active_flg; 104 u8 update_tx_switching_flg; 105 u8 tx_switching_flg; 106 u8 update_accept_any_vlan_flg; 107 u8 accept_any_vlan; 108 u8 update_rss_flg; 109 struct qed_update_vport_rss_params rss_params; 110 }; 111 112 struct qed_start_vport_params { 113 bool remove_inner_vlan; 114 bool handle_ptp_pkts; 115 bool gro_enable; 116 bool drop_ttl0; 117 u8 vport_id; 118 u16 mtu; 119 bool clear_stats; 120 }; 121 122 enum qed_filter_rx_mode_type { 123 QED_FILTER_RX_MODE_TYPE_REGULAR, 124 QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC, 125 QED_FILTER_RX_MODE_TYPE_PROMISC, 126 }; 127 128 enum qed_filter_xcast_params_type { 129 QED_FILTER_XCAST_TYPE_ADD, 130 QED_FILTER_XCAST_TYPE_DEL, 131 QED_FILTER_XCAST_TYPE_REPLACE, 132 }; 133 134 struct qed_filter_ucast_params { 135 enum qed_filter_xcast_params_type type; 136 u8 vlan_valid; 137 u16 vlan; 138 u8 mac_valid; 139 unsigned char mac[ETH_ALEN]; 140 }; 141 142 struct qed_filter_mcast_params { 143 enum qed_filter_xcast_params_type type; 144 u8 num; 145 unsigned char mac[64][ETH_ALEN]; 146 }; 147 148 union qed_filter_type_params { 149 enum qed_filter_rx_mode_type accept_flags; 150 struct qed_filter_ucast_params ucast; 151 struct qed_filter_mcast_params mcast; 152 }; 153 154 enum qed_filter_type { 155 QED_FILTER_TYPE_UCAST, 156 QED_FILTER_TYPE_MCAST, 157 QED_FILTER_TYPE_RX_MODE, 158 QED_MAX_FILTER_TYPES, 159 }; 160 161 struct qed_filter_params { 162 enum qed_filter_type type; 163 union qed_filter_type_params filter; 164 }; 165 166 struct qed_tunn_params { 167 u16 vxlan_port; 168 u8 update_vxlan_port; 169 u16 geneve_port; 170 u8 update_geneve_port; 171 }; 172 173 struct qed_eth_cb_ops { 174 struct qed_common_cb_ops common; 175 void (*force_mac) (void *dev, u8 *mac, bool forced); 176 void (*ports_update)(void *dev, u16 vxlan_port, u16 geneve_port); 177 }; 178 179 #define QED_MAX_PHC_DRIFT_PPB 291666666 180 181 enum qed_ptp_filter_type { 182 QED_PTP_FILTER_NONE, 183 QED_PTP_FILTER_ALL, 184 QED_PTP_FILTER_V1_L4_EVENT, 185 QED_PTP_FILTER_V1_L4_GEN, 186 QED_PTP_FILTER_V2_L4_EVENT, 187 QED_PTP_FILTER_V2_L4_GEN, 188 QED_PTP_FILTER_V2_L2_EVENT, 189 QED_PTP_FILTER_V2_L2_GEN, 190 QED_PTP_FILTER_V2_EVENT, 191 QED_PTP_FILTER_V2_GEN 192 }; 193 194 enum qed_ptp_hwtstamp_tx_type { 195 QED_PTP_HWTSTAMP_TX_OFF, 196 QED_PTP_HWTSTAMP_TX_ON, 197 }; 198 199 #ifdef CONFIG_DCB 200 /* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration 201 * of dcbnl_rtnl_ops structure. 202 */ 203 struct qed_eth_dcbnl_ops { 204 /* IEEE 802.1Qaz std */ 205 int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc); 206 int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc); 207 int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets); 208 int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets); 209 int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets); 210 int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc); 211 int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app); 212 int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app); 213 214 /* CEE std */ 215 u8 (*getstate)(struct qed_dev *cdev); 216 u8 (*setstate)(struct qed_dev *cdev, u8 state); 217 void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type, 218 u8 *pgid, u8 *bw_pct, u8 *up_map); 219 void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct); 220 void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type, 221 u8 *pgid, u8 *bw_pct, u8 *up_map); 222 void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct); 223 void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting); 224 void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting); 225 u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap); 226 int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num); 227 u8 (*getpfcstate)(struct qed_dev *cdev); 228 int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id); 229 u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags); 230 231 /* DCBX configuration */ 232 u8 (*getdcbx)(struct qed_dev *cdev); 233 void (*setpgtccfgtx)(struct qed_dev *cdev, int prio, 234 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map); 235 void (*setpgtccfgrx)(struct qed_dev *cdev, int prio, 236 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map); 237 void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct); 238 void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct); 239 u8 (*setall)(struct qed_dev *cdev); 240 int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num); 241 void (*setpfcstate)(struct qed_dev *cdev, u8 state); 242 int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up); 243 u8 (*setdcbx)(struct qed_dev *cdev, u8 state); 244 u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags); 245 246 /* Peer apps */ 247 int (*peer_getappinfo)(struct qed_dev *cdev, 248 struct dcb_peer_app_info *info, 249 u16 *app_count); 250 int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table); 251 252 /* CEE peer */ 253 int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc); 254 int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg); 255 }; 256 #endif 257 258 struct qed_eth_ptp_ops { 259 int (*cfg_filters)(struct qed_dev *, enum qed_ptp_filter_type, 260 enum qed_ptp_hwtstamp_tx_type); 261 int (*read_rx_ts)(struct qed_dev *, u64 *); 262 int (*read_tx_ts)(struct qed_dev *, u64 *); 263 int (*read_cc)(struct qed_dev *, u64 *); 264 int (*disable)(struct qed_dev *); 265 int (*adjfreq)(struct qed_dev *, s32); 266 int (*enable)(struct qed_dev *); 267 }; 268 269 struct qed_eth_ops { 270 const struct qed_common_ops *common; 271 #ifdef CONFIG_QED_SRIOV 272 const struct qed_iov_hv_ops *iov; 273 #endif 274 #ifdef CONFIG_DCB 275 const struct qed_eth_dcbnl_ops *dcb; 276 #endif 277 const struct qed_eth_ptp_ops *ptp; 278 279 int (*fill_dev_info)(struct qed_dev *cdev, 280 struct qed_dev_eth_info *info); 281 282 void (*register_ops)(struct qed_dev *cdev, 283 struct qed_eth_cb_ops *ops, 284 void *cookie); 285 286 bool(*check_mac) (struct qed_dev *cdev, u8 *mac); 287 288 int (*vport_start)(struct qed_dev *cdev, 289 struct qed_start_vport_params *params); 290 291 int (*vport_stop)(struct qed_dev *cdev, 292 u8 vport_id); 293 294 int (*vport_update)(struct qed_dev *cdev, 295 struct qed_update_vport_params *params); 296 297 int (*q_rx_start)(struct qed_dev *cdev, 298 u8 rss_num, 299 struct qed_queue_start_common_params *params, 300 u16 bd_max_bytes, 301 dma_addr_t bd_chain_phys_addr, 302 dma_addr_t cqe_pbl_addr, 303 u16 cqe_pbl_size, 304 struct qed_rxq_start_ret_params *ret_params); 305 306 int (*q_rx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle); 307 308 int (*q_tx_start)(struct qed_dev *cdev, 309 u8 rss_num, 310 struct qed_queue_start_common_params *params, 311 dma_addr_t pbl_addr, 312 u16 pbl_size, 313 struct qed_txq_start_ret_params *ret_params); 314 315 int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle); 316 317 int (*filter_config)(struct qed_dev *cdev, 318 struct qed_filter_params *params); 319 320 int (*fastpath_stop)(struct qed_dev *cdev); 321 322 int (*eth_cqe_completion)(struct qed_dev *cdev, 323 u8 rss_id, 324 struct eth_slow_path_rx_cqe *cqe); 325 326 void (*get_vport_stats)(struct qed_dev *cdev, 327 struct qed_eth_stats *stats); 328 329 int (*tunn_config)(struct qed_dev *cdev, 330 struct qed_tunn_params *params); 331 332 int (*ntuple_filter_config)(struct qed_dev *cdev, 333 void *cookie, 334 struct qed_ntuple_filter_params *params); 335 336 int (*configure_arfs_searcher)(struct qed_dev *cdev, 337 enum qed_filter_config_mode mode); 338 int (*get_coalesce)(struct qed_dev *cdev, u16 *coal, void *handle); 339 int (*req_bulletin_update_mac)(struct qed_dev *cdev, u8 *mac); 340 }; 341 342 const struct qed_eth_ops *qed_get_eth_ops(void); 343 void qed_put_eth_ops(void); 344 345 #endif 346