Yuval Mintz | 25c089d | 2015-10-26 11:02:26 +0200 | [diff] [blame] | 1 | /* QLogic qed NIC Driver |
Mintz, Yuval | e8f1cb5 | 2017-01-01 13:57:00 +0200 | [diff] [blame] | 2 | * Copyright (c) 2015-2017 QLogic Corporation |
Yuval Mintz | 25c089d | 2015-10-26 11:02:26 +0200 | [diff] [blame] | 3 | * |
Mintz, Yuval | e8f1cb5 | 2017-01-01 13:57:00 +0200 | [diff] [blame] | 4 | * This software is available to you under a choice of one of two |
| 5 | * licenses. You may choose to be licensed under the terms of the GNU |
| 6 | * General Public License (GPL) Version 2, available from the file |
| 7 | * COPYING in the main directory of this source tree, or the |
| 8 | * OpenIB.org BSD license below: |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or |
| 11 | * without modification, are permitted provided that the following |
| 12 | * conditions are met: |
| 13 | * |
| 14 | * - Redistributions of source code must retain the above |
| 15 | * copyright notice, this list of conditions and the following |
| 16 | * disclaimer. |
| 17 | * |
| 18 | * - Redistributions in binary form must reproduce the above |
| 19 | * copyright notice, this list of conditions and the following |
| 20 | * disclaimer in the documentation and /or other materials |
| 21 | * provided with the distribution. |
| 22 | * |
| 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 27 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 28 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 29 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 30 | * SOFTWARE. |
Yuval Mintz | 25c089d | 2015-10-26 11:02:26 +0200 | [diff] [blame] | 31 | */ |
| 32 | |
| 33 | #ifndef _QED_ETH_IF_H |
| 34 | #define _QED_ETH_IF_H |
| 35 | |
| 36 | #include <linux/list.h> |
| 37 | #include <linux/if_link.h> |
| 38 | #include <linux/qed/eth_common.h> |
| 39 | #include <linux/qed/qed_if.h> |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 40 | #include <linux/qed/qed_iov_if.h> |
Yuval Mintz | 25c089d | 2015-10-26 11:02:26 +0200 | [diff] [blame] | 41 | |
Mintz, Yuval | 3da7a37 | 2016-11-29 16:47:06 +0200 | [diff] [blame] | 42 | struct qed_queue_start_common_params { |
| 43 | /* Should always be relative to entity sending this. */ |
| 44 | u8 vport_id; |
| 45 | u16 queue_id; |
| 46 | |
| 47 | /* Relative, but relevant only for PFs */ |
| 48 | u8 stats_id; |
| 49 | |
| 50 | /* These are always absolute */ |
| 51 | u16 sb; |
| 52 | u8 sb_idx; |
| 53 | }; |
| 54 | |
| 55 | struct qed_rxq_start_ret_params { |
| 56 | void __iomem *p_prod; |
| 57 | void *p_handle; |
| 58 | }; |
| 59 | |
| 60 | struct qed_txq_start_ret_params { |
| 61 | void __iomem *p_doorbell; |
| 62 | void *p_handle; |
| 63 | }; |
| 64 | |
Yuval Mintz | 25c089d | 2015-10-26 11:02:26 +0200 | [diff] [blame] | 65 | struct qed_dev_eth_info { |
| 66 | struct qed_dev_info common; |
| 67 | |
| 68 | u8 num_queues; |
| 69 | u8 num_tc; |
| 70 | |
| 71 | u8 port_mac[ETH_ALEN]; |
Tomer Tayar | 2edbff8 | 2016-10-31 07:14:27 +0200 | [diff] [blame] | 72 | u16 num_vlan_filters; |
Yuval Mintz | 7b7e70f | 2016-10-14 05:19:20 -0400 | [diff] [blame] | 73 | u16 num_mac_filters; |
Yuval Mintz | d8c2c7e | 2016-08-22 13:25:11 +0300 | [diff] [blame] | 74 | |
| 75 | /* Legacy VF - this affects the datapath, so qede has to know */ |
| 76 | bool is_legacy; |
Yuval Mintz | 25c089d | 2015-10-26 11:02:26 +0200 | [diff] [blame] | 77 | }; |
| 78 | |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 79 | struct qed_update_vport_rss_params { |
Mintz, Yuval | f29ffdb | 2017-01-01 13:57:07 +0200 | [diff] [blame] | 80 | void *rss_ind_table[128]; |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 81 | u32 rss_key[10]; |
Sudarsana Reddy Kalluru | 8c5ebd0 | 2016-04-10 12:43:00 +0300 | [diff] [blame] | 82 | u8 rss_caps; |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | struct qed_update_vport_params { |
| 86 | u8 vport_id; |
| 87 | u8 update_vport_active_flg; |
| 88 | u8 vport_active_flg; |
Yuval Mintz | 831bfb0e | 2016-05-11 16:36:25 +0300 | [diff] [blame] | 89 | u8 update_tx_switching_flg; |
| 90 | u8 tx_switching_flg; |
Yuval Mintz | 3f9b4a6 | 2016-02-18 17:00:39 +0200 | [diff] [blame] | 91 | u8 update_accept_any_vlan_flg; |
| 92 | u8 accept_any_vlan; |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 93 | u8 update_rss_flg; |
| 94 | struct qed_update_vport_rss_params rss_params; |
| 95 | }; |
| 96 | |
Manish Chopra | 088c861 | 2016-03-04 12:35:05 -0500 | [diff] [blame] | 97 | struct qed_start_vport_params { |
| 98 | bool remove_inner_vlan; |
Sudarsana Reddy Kalluru | c78c70f | 2017-02-15 10:24:10 +0200 | [diff] [blame] | 99 | bool handle_ptp_pkts; |
Manish Chopra | 088c861 | 2016-03-04 12:35:05 -0500 | [diff] [blame] | 100 | bool gro_enable; |
| 101 | bool drop_ttl0; |
| 102 | u8 vport_id; |
| 103 | u16 mtu; |
Yuval Mintz | a0d26d5 | 2016-06-19 15:18:13 +0300 | [diff] [blame] | 104 | bool clear_stats; |
Manish Chopra | 088c861 | 2016-03-04 12:35:05 -0500 | [diff] [blame] | 105 | }; |
| 106 | |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 107 | enum qed_filter_rx_mode_type { |
| 108 | QED_FILTER_RX_MODE_TYPE_REGULAR, |
| 109 | QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC, |
| 110 | QED_FILTER_RX_MODE_TYPE_PROMISC, |
| 111 | }; |
| 112 | |
| 113 | enum qed_filter_xcast_params_type { |
| 114 | QED_FILTER_XCAST_TYPE_ADD, |
| 115 | QED_FILTER_XCAST_TYPE_DEL, |
| 116 | QED_FILTER_XCAST_TYPE_REPLACE, |
| 117 | }; |
| 118 | |
| 119 | struct qed_filter_ucast_params { |
| 120 | enum qed_filter_xcast_params_type type; |
| 121 | u8 vlan_valid; |
| 122 | u16 vlan; |
| 123 | u8 mac_valid; |
| 124 | unsigned char mac[ETH_ALEN]; |
| 125 | }; |
| 126 | |
| 127 | struct qed_filter_mcast_params { |
| 128 | enum qed_filter_xcast_params_type type; |
| 129 | u8 num; |
| 130 | unsigned char mac[64][ETH_ALEN]; |
| 131 | }; |
| 132 | |
| 133 | union qed_filter_type_params { |
| 134 | enum qed_filter_rx_mode_type accept_flags; |
| 135 | struct qed_filter_ucast_params ucast; |
| 136 | struct qed_filter_mcast_params mcast; |
| 137 | }; |
| 138 | |
| 139 | enum qed_filter_type { |
| 140 | QED_FILTER_TYPE_UCAST, |
| 141 | QED_FILTER_TYPE_MCAST, |
| 142 | QED_FILTER_TYPE_RX_MODE, |
| 143 | QED_MAX_FILTER_TYPES, |
| 144 | }; |
| 145 | |
| 146 | struct qed_filter_params { |
| 147 | enum qed_filter_type type; |
| 148 | union qed_filter_type_params filter; |
| 149 | }; |
| 150 | |
Manish Chopra | 464f664 | 2016-04-14 01:38:29 -0400 | [diff] [blame] | 151 | struct qed_tunn_params { |
| 152 | u16 vxlan_port; |
| 153 | u8 update_vxlan_port; |
| 154 | u16 geneve_port; |
| 155 | u8 update_geneve_port; |
| 156 | }; |
| 157 | |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 158 | struct qed_eth_cb_ops { |
| 159 | struct qed_common_cb_ops common; |
Yuval Mintz | c3aaa40 | 2016-10-14 05:19:17 -0400 | [diff] [blame] | 160 | void (*force_mac) (void *dev, u8 *mac, bool forced); |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 161 | }; |
| 162 | |
Sudarsana Reddy Kalluru | c78c70f | 2017-02-15 10:24:10 +0200 | [diff] [blame] | 163 | #define QED_MAX_PHC_DRIFT_PPB 291666666 |
| 164 | |
| 165 | enum qed_ptp_filter_type { |
| 166 | QED_PTP_FILTER_L2, |
| 167 | QED_PTP_FILTER_IPV4, |
| 168 | QED_PTP_FILTER_IPV4_IPV6, |
| 169 | QED_PTP_FILTER_L2_IPV4_IPV6 |
| 170 | }; |
| 171 | |
Sudarsana Reddy Kalluru | a1d8d8a | 2016-06-08 06:22:11 -0400 | [diff] [blame] | 172 | #ifdef CONFIG_DCB |
| 173 | /* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration |
| 174 | * of dcbnl_rtnl_ops structure. |
| 175 | */ |
| 176 | struct qed_eth_dcbnl_ops { |
| 177 | /* IEEE 802.1Qaz std */ |
| 178 | int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc); |
| 179 | int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc); |
| 180 | int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets); |
| 181 | int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets); |
| 182 | int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets); |
| 183 | int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc); |
| 184 | int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app); |
| 185 | int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app); |
| 186 | |
| 187 | /* CEE std */ |
| 188 | u8 (*getstate)(struct qed_dev *cdev); |
| 189 | u8 (*setstate)(struct qed_dev *cdev, u8 state); |
| 190 | void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type, |
| 191 | u8 *pgid, u8 *bw_pct, u8 *up_map); |
| 192 | void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct); |
| 193 | void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type, |
| 194 | u8 *pgid, u8 *bw_pct, u8 *up_map); |
| 195 | void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct); |
| 196 | void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting); |
| 197 | void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting); |
| 198 | u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap); |
| 199 | int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num); |
| 200 | u8 (*getpfcstate)(struct qed_dev *cdev); |
| 201 | int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id); |
| 202 | u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags); |
| 203 | |
| 204 | /* DCBX configuration */ |
| 205 | u8 (*getdcbx)(struct qed_dev *cdev); |
| 206 | void (*setpgtccfgtx)(struct qed_dev *cdev, int prio, |
| 207 | u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map); |
| 208 | void (*setpgtccfgrx)(struct qed_dev *cdev, int prio, |
| 209 | u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map); |
| 210 | void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct); |
| 211 | void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct); |
| 212 | u8 (*setall)(struct qed_dev *cdev); |
| 213 | int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num); |
| 214 | void (*setpfcstate)(struct qed_dev *cdev, u8 state); |
| 215 | int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up); |
| 216 | u8 (*setdcbx)(struct qed_dev *cdev, u8 state); |
| 217 | u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags); |
| 218 | |
| 219 | /* Peer apps */ |
| 220 | int (*peer_getappinfo)(struct qed_dev *cdev, |
| 221 | struct dcb_peer_app_info *info, |
| 222 | u16 *app_count); |
| 223 | int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table); |
| 224 | |
| 225 | /* CEE peer */ |
| 226 | int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc); |
| 227 | int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg); |
| 228 | }; |
| 229 | #endif |
| 230 | |
Sudarsana Reddy Kalluru | c78c70f | 2017-02-15 10:24:10 +0200 | [diff] [blame] | 231 | struct qed_eth_ptp_ops { |
| 232 | int (*hwtstamp_tx_on)(struct qed_dev *); |
| 233 | int (*cfg_rx_filters)(struct qed_dev *, enum qed_ptp_filter_type); |
| 234 | int (*read_rx_ts)(struct qed_dev *, u64 *); |
| 235 | int (*read_tx_ts)(struct qed_dev *, u64 *); |
| 236 | int (*read_cc)(struct qed_dev *, u64 *); |
| 237 | int (*disable)(struct qed_dev *); |
| 238 | int (*adjfreq)(struct qed_dev *, s32); |
| 239 | int (*enable)(struct qed_dev *); |
| 240 | }; |
| 241 | |
Yuval Mintz | 25c089d | 2015-10-26 11:02:26 +0200 | [diff] [blame] | 242 | struct qed_eth_ops { |
| 243 | const struct qed_common_ops *common; |
Yuval Mintz | 0b55e27 | 2016-05-11 16:36:15 +0300 | [diff] [blame] | 244 | #ifdef CONFIG_QED_SRIOV |
| 245 | const struct qed_iov_hv_ops *iov; |
| 246 | #endif |
Sudarsana Reddy Kalluru | a1d8d8a | 2016-06-08 06:22:11 -0400 | [diff] [blame] | 247 | #ifdef CONFIG_DCB |
| 248 | const struct qed_eth_dcbnl_ops *dcb; |
| 249 | #endif |
Sudarsana Reddy Kalluru | c78c70f | 2017-02-15 10:24:10 +0200 | [diff] [blame] | 250 | const struct qed_eth_ptp_ops *ptp; |
Yuval Mintz | 25c089d | 2015-10-26 11:02:26 +0200 | [diff] [blame] | 251 | |
| 252 | int (*fill_dev_info)(struct qed_dev *cdev, |
| 253 | struct qed_dev_eth_info *info); |
| 254 | |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 255 | void (*register_ops)(struct qed_dev *cdev, |
| 256 | struct qed_eth_cb_ops *ops, |
| 257 | void *cookie); |
| 258 | |
Yuval Mintz | eff1696 | 2016-05-11 16:36:21 +0300 | [diff] [blame] | 259 | bool(*check_mac) (struct qed_dev *cdev, u8 *mac); |
| 260 | |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 261 | int (*vport_start)(struct qed_dev *cdev, |
Manish Chopra | 088c861 | 2016-03-04 12:35:05 -0500 | [diff] [blame] | 262 | struct qed_start_vport_params *params); |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 263 | |
| 264 | int (*vport_stop)(struct qed_dev *cdev, |
| 265 | u8 vport_id); |
| 266 | |
| 267 | int (*vport_update)(struct qed_dev *cdev, |
| 268 | struct qed_update_vport_params *params); |
| 269 | |
| 270 | int (*q_rx_start)(struct qed_dev *cdev, |
Mintz, Yuval | 3da7a37 | 2016-11-29 16:47:06 +0200 | [diff] [blame] | 271 | u8 rss_num, |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 272 | struct qed_queue_start_common_params *params, |
| 273 | u16 bd_max_bytes, |
| 274 | dma_addr_t bd_chain_phys_addr, |
| 275 | dma_addr_t cqe_pbl_addr, |
| 276 | u16 cqe_pbl_size, |
Mintz, Yuval | 3da7a37 | 2016-11-29 16:47:06 +0200 | [diff] [blame] | 277 | struct qed_rxq_start_ret_params *ret_params); |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 278 | |
Mintz, Yuval | 3da7a37 | 2016-11-29 16:47:06 +0200 | [diff] [blame] | 279 | int (*q_rx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle); |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 280 | |
| 281 | int (*q_tx_start)(struct qed_dev *cdev, |
Mintz, Yuval | 3da7a37 | 2016-11-29 16:47:06 +0200 | [diff] [blame] | 282 | u8 rss_num, |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 283 | struct qed_queue_start_common_params *params, |
| 284 | dma_addr_t pbl_addr, |
| 285 | u16 pbl_size, |
Mintz, Yuval | 3da7a37 | 2016-11-29 16:47:06 +0200 | [diff] [blame] | 286 | struct qed_txq_start_ret_params *ret_params); |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 287 | |
Mintz, Yuval | 3da7a37 | 2016-11-29 16:47:06 +0200 | [diff] [blame] | 288 | int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle); |
Manish Chopra | cee4d26 | 2015-10-26 11:02:28 +0200 | [diff] [blame] | 289 | |
| 290 | int (*filter_config)(struct qed_dev *cdev, |
| 291 | struct qed_filter_params *params); |
| 292 | |
| 293 | int (*fastpath_stop)(struct qed_dev *cdev); |
| 294 | |
| 295 | int (*eth_cqe_completion)(struct qed_dev *cdev, |
| 296 | u8 rss_id, |
| 297 | struct eth_slow_path_rx_cqe *cqe); |
Manish Chopra | 9df2ed0 | 2015-10-26 11:02:33 +0200 | [diff] [blame] | 298 | |
| 299 | void (*get_vport_stats)(struct qed_dev *cdev, |
| 300 | struct qed_eth_stats *stats); |
Manish Chopra | 464f664 | 2016-04-14 01:38:29 -0400 | [diff] [blame] | 301 | |
| 302 | int (*tunn_config)(struct qed_dev *cdev, |
| 303 | struct qed_tunn_params *params); |
Yuval Mintz | 25c089d | 2015-10-26 11:02:26 +0200 | [diff] [blame] | 304 | }; |
| 305 | |
Rahul Verma | 9511434 | 2016-04-10 12:42:59 +0300 | [diff] [blame] | 306 | const struct qed_eth_ops *qed_get_eth_ops(void); |
Yuval Mintz | 25c089d | 2015-10-26 11:02:26 +0200 | [diff] [blame] | 307 | void qed_put_eth_ops(void); |
| 308 | |
| 309 | #endif |