2018-09-19 17:23:04 -07:00
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2018, Intel Corporation. */
# ifndef _ICE_LIB_H_
# define _ICE_LIB_H_
# include "ice.h"
2020-02-27 10:15:04 -08:00
const char * ice_vsi_type_str ( enum ice_vsi_type vsi_type ) ;
2019-11-06 02:05:39 -08:00
2020-07-09 09:16:03 -07:00
bool ice_pf_state_is_nominal ( struct ice_pf * pf ) ;
2018-09-19 17:23:04 -07:00
void ice_update_eth_stats ( struct ice_vsi * vsi ) ;
2021-03-02 10:15:40 -08:00
int ice_vsi_cfg_single_rxq ( struct ice_vsi * vsi , u16 q_idx ) ;
2021-08-19 13:59:58 +02:00
int ice_vsi_cfg_single_txq ( struct ice_vsi * vsi , struct ice_tx_ring * * tx_rings , u16 q_idx ) ;
2021-03-02 10:15:40 -08:00
2018-09-19 17:23:05 -07:00
int ice_vsi_cfg_rxqs ( struct ice_vsi * vsi ) ;
2018-12-19 10:03:27 -08:00
int ice_vsi_cfg_lan_txqs ( struct ice_vsi * vsi ) ;
2018-09-19 17:23:05 -07:00
void ice_vsi_cfg_msix ( struct ice_vsi * vsi ) ;
2020-05-07 17:41:08 -07:00
int
ice_vsi_add_vlan ( struct ice_vsi * vsi , u16 vid , enum ice_sw_fwd_act_type action ) ;
2018-09-19 17:23:04 -07:00
int ice_vsi_kill_vlan ( struct ice_vsi * vsi , u16 vid ) ;
int ice_vsi_manage_vlan_insertion ( struct ice_vsi * vsi ) ;
int ice_vsi_manage_vlan_stripping ( struct ice_vsi * vsi , bool ena ) ;
2018-09-19 17:23:05 -07:00
2020-01-22 07:21:29 -08:00
int ice_vsi_start_all_rx_rings ( struct ice_vsi * vsi ) ;
2018-09-19 17:23:05 -07:00
2020-01-22 07:21:29 -08:00
int ice_vsi_stop_all_rx_rings ( struct ice_vsi * vsi ) ;
2018-09-19 17:23:05 -07:00
2018-12-19 10:03:27 -08:00
int
ice_vsi_stop_lan_tx_rings ( struct ice_vsi * vsi , enum ice_disq_rst_src rst_src ,
2018-09-19 17:42:55 -07:00
u16 rel_vmvf_num ) ;
2018-09-19 17:23:05 -07:00
2019-11-04 09:38:56 -08:00
int ice_vsi_cfg_xdp_txqs ( struct ice_vsi * vsi ) ;
int ice_vsi_stop_xdp_tx_rings ( struct ice_vsi * vsi ) ;
2020-01-22 07:21:24 -08:00
bool ice_vsi_is_vlan_pruning_ena ( struct ice_vsi * vsi ) ;
2019-02-26 16:35:14 -08:00
int ice_cfg_vlan_pruning ( struct ice_vsi * vsi , bool ena , bool vlan_promisc ) ;
2018-09-19 17:23:06 -07:00
2019-04-16 10:34:55 -07:00
void ice_cfg_sw_lldp ( struct ice_vsi * vsi , bool tx , bool create ) ;
2021-03-25 15:35:07 -07:00
int ice_set_link ( struct ice_vsi * vsi , bool ena ) ;
2019-02-28 15:24:24 -08:00
# ifdef CONFIG_DCB
int ice_vsi_cfg_tc ( struct ice_vsi * vsi , u8 ena_tc ) ;
# endif /* CONFIG_DCB */
2018-09-19 17:23:10 -07:00
struct ice_vsi *
ice_vsi_setup ( struct ice_pf * pf , struct ice_port_info * pi ,
2020-02-27 10:15:04 -08:00
enum ice_vsi_type vsi_type , u16 vf_id ) ;
2018-09-19 17:23:10 -07:00
2019-04-16 10:34:50 -07:00
void ice_napi_del ( struct ice_vsi * vsi ) ;
2018-09-19 17:23:09 -07:00
int ice_vsi_release ( struct ice_vsi * vsi ) ;
2018-09-19 17:23:08 -07:00
void ice_vsi_close ( struct ice_vsi * vsi ) ;
2019-11-06 02:05:27 -08:00
int ice_ena_vsi ( struct ice_vsi * vsi , bool locked ) ;
void ice_dis_vsi ( struct ice_vsi * vsi , bool locked ) ;
2018-09-19 17:23:06 -07:00
int ice_free_res ( struct ice_res_tracker * res , u16 index , u16 id ) ;
int
ice_get_res ( struct ice_pf * pf , struct ice_res_tracker * res , u16 needed , u16 id ) ;
2019-11-08 06:23:29 -08:00
int ice_vsi_rebuild ( struct ice_vsi * vsi , bool init_vsi ) ;
2018-09-19 17:23:09 -07:00
2018-09-19 17:23:11 -07:00
bool ice_is_reset_in_progress ( unsigned long * state ) ;
2021-05-06 08:39:59 -07:00
int ice_wait_for_reset ( struct ice_pf * pf , unsigned long timeout ) ;
2018-09-19 17:23:06 -07:00
2020-05-15 17:54:59 -07:00
void
ice: enable receive hardware timestamping
Add SIOCGHWTSTAMP and SIOCSHWTSTAMP ioctl handlers to respond to
requests to enable timestamping support. If the request is for enabling
Rx timestamps, set a bit in the Rx descriptors to indicate that receive
timestamps should be reported.
Hardware captures receive timestamps in the PHY which only captures part
of the timer, and reports only 40 bits into the Rx descriptor. The upper
32 bits represent the contents of GLTSYN_TIME_L at the point of packet
reception, while the lower 8 bits represent the upper 8 bits of
GLTSYN_TIME_0.
The networking and PTP stack expect 64 bit timestamps in nanoseconds. To
support this, implement some logic to extend the timestamps by using the
full PHC time.
If the Rx timestamp was captured prior to the PHC time, then the real
timestamp is
PHC - (lower_32_bits(PHC) - timestamp)
If the Rx timestamp was captured after the PHC time, then the real
timestamp is
PHC + (timestamp - lower_32_bits(PHC))
These calculations are correct as long as neither the PHC timestamp nor
the Rx timestamps are more than 2^32-1 nanseconds old. Further, we can
detect when the Rx timestamp is before or after the PHC as long as the
PHC timestamp is no more than 2^31-1 nanoseconds old.
In that case, we calculate the delta between the lower 32 bits of the
PHC and the Rx timestamp. If it's larger than 2^31-1 then the Rx
timestamp must have been captured in the past. If it's smaller, then the
Rx timestamp must have been captured after PHC time.
Add an ice_ptp_extend_32b_ts function that relies on a cached copy of
the PHC time and implements this algorithm to calculate the proper upper
32bits of the Rx timestamps.
Cache the PHC time periodically in all of the Rx rings. This enables
each Rx ring to simply call the extension function with a recent copy of
the PHC time. By ensuring that the PHC time is kept up to date
periodically, we ensure this algorithm doesn't use stale data and
produce incorrect results.
To cache the time, introduce a kworker and a kwork item to periodically
store the Rx time. It might seem like we should use the .do_aux_work
interface of the PTP clock. This doesn't work because all PFs must cache
this time, but only one PF owns the PTP clock device.
Thus, the ice driver will manage its own kthread instead of relying on
the PTP do_aux_work handler.
With this change, the driver can now report Rx timestamps on all
incoming packets.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2021-06-09 09:39:52 -07:00
ice_write_qrxflxp_cntxt ( struct ice_hw * hw , u16 pf_q , u32 rxdid , u32 prio ,
bool ena_ts ) ;
2020-05-15 17:54:59 -07:00
2018-09-19 17:23:06 -07:00
void ice_vsi_dis_irq ( struct ice_vsi * vsi ) ;
void ice_vsi_free_irq ( struct ice_vsi * vsi ) ;
void ice_vsi_free_rx_rings ( struct ice_vsi * vsi ) ;
void ice_vsi_free_tx_rings ( struct ice_vsi * vsi ) ;
2021-03-31 14:17:07 -07:00
void ice_vsi_manage_rss_lut ( struct ice_vsi * vsi , bool ena ) ;
2018-09-19 17:23:17 -07:00
2021-08-19 13:59:58 +02:00
void ice_update_tx_ring_stats ( struct ice_tx_ring * ring , u64 pkts , u64 bytes ) ;
2019-11-04 09:38:56 -08:00
2021-08-19 13:59:58 +02:00
void ice_update_rx_ring_stats ( struct ice_rx_ring * ring , u64 pkts , u64 bytes ) ;
2019-11-04 09:38:56 -08:00
2019-11-04 09:38:56 -08:00
void ice_vsi_cfg_frame_size ( struct ice_vsi * vsi ) ;
2020-05-11 18:01:40 -07:00
int ice_status_to_errno ( enum ice_status err ) ;
2021-03-31 14:16:56 -07:00
void ice_write_intrl ( struct ice_q_vector * q_vector , u8 intrl ) ;
void ice_write_itr ( struct ice_ring_container * rc , u16 itr ) ;
ice: Fix issues updating VSI MAC filters
VSI, especially VF could request to add or remove filter for another VSI,
driver should really guide such request and disallow it.
However, instead of returning error for such malicious request, driver
can simply return success.
In addition, we are not tracking number of MAC filters configured per
VF correctly - and this leads to issue updating VF MAC filters whenever
they were removed and re-configured via bringing VF interface down and
up. Also, since VF could send request to update multiple MAC filters at
once, driver should program those filters individually in the switch, in
order to determine which action resulted to error, and communicate
accordingly to the VF.
So, with this changes, we now track number of filters added right from
when VF resources allocation is done, and could properly add filters for
both trusted and non_trusted VFs, without MAC filters mis-match issue in
the switch...
Also refactor code, so that driver can use new function to add or remove
MAC filters.
Signed-off-by: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2019-07-25 02:53:51 -07:00
enum ice_status
ice_vsi_cfg_mac_fltr ( struct ice_vsi * vsi , const u8 * macaddr , bool set ) ;
2019-09-09 06:47:46 -07:00
bool ice_is_safe_mode ( struct ice_pf * pf ) ;
2021-05-20 09:37:49 -05:00
bool ice_is_aux_ena ( struct ice_pf * pf ) ;
2019-12-12 03:12:55 -08:00
bool ice_is_dflt_vsi_in_use ( struct ice_sw * sw ) ;
bool ice_is_vsi_dflt_vsi ( struct ice_sw * sw , struct ice_vsi * vsi ) ;
int ice_set_dflt_vsi ( struct ice_sw * sw , struct ice_vsi * vsi ) ;
int ice_clear_dflt_vsi ( struct ice_sw * sw ) ;
2021-08-19 17:08:52 -07:00
int
ice_vsi_update_security ( struct ice_vsi * vsi , void ( * fill ) ( struct ice_vsi_ctx * ) ) ;
void ice_vsi_ctx_set_antispoof ( struct ice_vsi_ctx * ctx ) ;
void ice_vsi_ctx_clear_antispoof ( struct ice_vsi_ctx * ctx ) ;
void ice_vsi_ctx_set_allow_override ( struct ice_vsi_ctx * ctx ) ;
void ice_vsi_ctx_clear_allow_override ( struct ice_vsi_ctx * ctx ) ;
2021-07-16 15:16:41 -07:00
bool ice_is_feature_supported ( struct ice_pf * pf , enum ice_feature f ) ;
2021-08-17 13:09:18 +02:00
void ice_clear_feature_support ( struct ice_pf * pf , enum ice_feature f ) ;
2021-07-16 15:16:41 -07:00
void ice_init_feature_support ( struct ice_pf * pf ) ;
2018-09-19 17:23:04 -07:00
# endif /* !_ICE_LIB_H_ */