Yuval Mintz | dacd88d | 2016-05-11 16:36:16 +0300 | [diff] [blame] | 1 | /* QLogic qed NIC Driver |
| 2 | * Copyright (c) 2015 QLogic Corporation |
| 3 | * |
| 4 | * This software is available under the terms of the GNU General Public License |
| 5 | * (GPL) Version 2, available from the file COPYING in the main directory of |
| 6 | * this source tree. |
| 7 | */ |
| 8 | #ifndef _QED_L2_H |
| 9 | #define _QED_L2_H |
| 10 | #include <linux/types.h> |
| 11 | #include <linux/io.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/slab.h> |
| 14 | #include <linux/qed/qed_eth_if.h> |
| 15 | #include "qed.h" |
| 16 | #include "qed_hw.h" |
| 17 | #include "qed_sp.h" |
| 18 | |
| 19 | enum qed_filter_opcode { |
| 20 | QED_FILTER_ADD, |
| 21 | QED_FILTER_REMOVE, |
| 22 | QED_FILTER_MOVE, |
| 23 | QED_FILTER_REPLACE, /* Delete all MACs and add new one instead */ |
| 24 | QED_FILTER_FLUSH, /* Removes all filters */ |
| 25 | }; |
| 26 | |
| 27 | enum qed_filter_ucast_type { |
| 28 | QED_FILTER_MAC, |
| 29 | QED_FILTER_VLAN, |
| 30 | QED_FILTER_MAC_VLAN, |
| 31 | QED_FILTER_INNER_MAC, |
| 32 | QED_FILTER_INNER_VLAN, |
| 33 | QED_FILTER_INNER_PAIR, |
| 34 | QED_FILTER_INNER_MAC_VNI_PAIR, |
| 35 | QED_FILTER_MAC_VNI_PAIR, |
| 36 | QED_FILTER_VNI, |
| 37 | }; |
| 38 | |
| 39 | struct qed_filter_ucast { |
| 40 | enum qed_filter_opcode opcode; |
| 41 | enum qed_filter_ucast_type type; |
| 42 | u8 is_rx_filter; |
| 43 | u8 is_tx_filter; |
| 44 | u8 vport_to_add_to; |
| 45 | u8 vport_to_remove_from; |
| 46 | unsigned char mac[ETH_ALEN]; |
| 47 | u8 assert_on_error; |
| 48 | u16 vlan; |
| 49 | u32 vni; |
| 50 | }; |
| 51 | |
| 52 | struct qed_filter_mcast { |
| 53 | /* MOVE is not supported for multicast */ |
| 54 | enum qed_filter_opcode opcode; |
| 55 | u8 vport_to_add_to; |
| 56 | u8 vport_to_remove_from; |
| 57 | u8 num_mc_addrs; |
| 58 | #define QED_MAX_MC_ADDRS 64 |
| 59 | unsigned char mac[QED_MAX_MC_ADDRS][ETH_ALEN]; |
| 60 | }; |
| 61 | |
| 62 | int qed_sp_eth_rx_queue_stop(struct qed_hwfn *p_hwfn, |
| 63 | u16 rx_queue_id, |
| 64 | bool eq_completion_only, bool cqe_completion); |
| 65 | |
| 66 | int qed_sp_eth_tx_queue_stop(struct qed_hwfn *p_hwfn, u16 tx_queue_id); |
| 67 | |
| 68 | enum qed_tpa_mode { |
| 69 | QED_TPA_MODE_NONE, |
| 70 | QED_TPA_MODE_UNUSED, |
| 71 | QED_TPA_MODE_GRO, |
| 72 | QED_TPA_MODE_MAX |
| 73 | }; |
| 74 | |
| 75 | struct qed_sp_vport_start_params { |
| 76 | enum qed_tpa_mode tpa_mode; |
| 77 | bool remove_inner_vlan; |
| 78 | bool drop_ttl0; |
| 79 | u8 max_buffers_per_cqe; |
| 80 | u32 concrete_fid; |
| 81 | u16 opaque_fid; |
| 82 | u8 vport_id; |
| 83 | u16 mtu; |
| 84 | }; |
| 85 | |
| 86 | int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn, |
| 87 | struct qed_sp_vport_start_params *p_params); |
| 88 | |
| 89 | struct qed_rss_params { |
| 90 | u8 update_rss_config; |
| 91 | u8 rss_enable; |
| 92 | u8 rss_eng_id; |
| 93 | u8 update_rss_capabilities; |
| 94 | u8 update_rss_ind_table; |
| 95 | u8 update_rss_key; |
| 96 | u8 rss_caps; |
| 97 | u8 rss_table_size_log; |
| 98 | u16 rss_ind_table[QED_RSS_IND_TABLE_SIZE]; |
| 99 | u32 rss_key[QED_RSS_KEY_SIZE]; |
| 100 | }; |
| 101 | |
| 102 | struct qed_filter_accept_flags { |
| 103 | u8 update_rx_mode_config; |
| 104 | u8 update_tx_mode_config; |
| 105 | u8 rx_accept_filter; |
| 106 | u8 tx_accept_filter; |
| 107 | #define QED_ACCEPT_NONE 0x01 |
| 108 | #define QED_ACCEPT_UCAST_MATCHED 0x02 |
| 109 | #define QED_ACCEPT_UCAST_UNMATCHED 0x04 |
| 110 | #define QED_ACCEPT_MCAST_MATCHED 0x08 |
| 111 | #define QED_ACCEPT_MCAST_UNMATCHED 0x10 |
| 112 | #define QED_ACCEPT_BCAST 0x20 |
| 113 | }; |
| 114 | |
| 115 | struct qed_sp_vport_update_params { |
| 116 | u16 opaque_fid; |
| 117 | u8 vport_id; |
| 118 | u8 update_vport_active_rx_flg; |
| 119 | u8 vport_active_rx_flg; |
| 120 | u8 update_vport_active_tx_flg; |
| 121 | u8 vport_active_tx_flg; |
| 122 | u8 update_approx_mcast_flg; |
| 123 | u8 update_accept_any_vlan_flg; |
| 124 | u8 accept_any_vlan; |
| 125 | unsigned long bins[8]; |
| 126 | struct qed_rss_params *rss_params; |
| 127 | struct qed_filter_accept_flags accept_flags; |
| 128 | }; |
| 129 | |
| 130 | int qed_sp_vport_update(struct qed_hwfn *p_hwfn, |
| 131 | struct qed_sp_vport_update_params *p_params, |
| 132 | enum spq_mode comp_mode, |
| 133 | struct qed_spq_comp_cb *p_comp_data); |
| 134 | |
| 135 | /** |
| 136 | * @brief qed_sp_vport_stop - |
| 137 | * |
| 138 | * This ramrod closes a VPort after all its RX and TX queues are terminated. |
| 139 | * An Assert is generated if any queues are left open. |
| 140 | * |
| 141 | * @param p_hwfn |
| 142 | * @param opaque_fid |
| 143 | * @param vport_id VPort ID |
| 144 | * |
| 145 | * @return int |
| 146 | */ |
| 147 | int qed_sp_vport_stop(struct qed_hwfn *p_hwfn, u16 opaque_fid, u8 vport_id); |
| 148 | |
| 149 | int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn, |
| 150 | u16 opaque_fid, |
| 151 | struct qed_filter_ucast *p_filter_cmd, |
| 152 | enum spq_mode comp_mode, |
| 153 | struct qed_spq_comp_cb *p_comp_data); |
| 154 | |
| 155 | int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn, |
| 156 | struct qed_sp_vport_start_params *p_params); |
| 157 | |
| 158 | int qed_sp_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn, |
| 159 | u16 opaque_fid, |
| 160 | u32 cid, |
| 161 | struct qed_queue_start_common_params *params, |
| 162 | u8 stats_id, |
| 163 | u16 bd_max_bytes, |
| 164 | dma_addr_t bd_chain_phys_addr, |
| 165 | dma_addr_t cqe_pbl_addr, u16 cqe_pbl_size); |
| 166 | |
| 167 | int qed_sp_eth_txq_start_ramrod(struct qed_hwfn *p_hwfn, |
| 168 | u16 opaque_fid, |
| 169 | u32 cid, |
| 170 | struct qed_queue_start_common_params *p_params, |
| 171 | u8 stats_id, |
| 172 | dma_addr_t pbl_addr, |
| 173 | u16 pbl_size, |
| 174 | union qed_qm_pq_params *p_pq_params); |
| 175 | |
| 176 | u8 qed_mcast_bin_from_mac(u8 *mac); |
| 177 | |
| 178 | #endif /* _QED_L2_H */ |