2019-06-01 10:08:37 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2017-01-23 22:09:12 -08:00
/*
* aQuantia Corporation Network Driver
2019-10-22 09:53:22 +00:00
* Copyright ( C ) 2014 - 2019 aQuantia Corporation . All rights reserved
2017-01-23 22:09:12 -08:00
*/
/* File aq_nic.h: Declaration of common code for NIC. */
# ifndef AQ_NIC_H
# define AQ_NIC_H
# include "aq_common.h"
# include "aq_rss.h"
2018-01-15 16:41:15 +03:00
# include "aq_hw.h"
2017-01-23 22:09:12 -08:00
struct aq_ring_s ;
struct aq_hw_ops ;
2018-01-15 16:41:19 +03:00
struct aq_fw_s ;
struct aq_vec_s ;
2019-10-22 09:53:22 +00:00
struct aq_ptp_s ;
2019-10-22 09:53:38 +00:00
enum aq_rx_filter_type ;
2017-01-23 22:09:12 -08:00
struct aq_nic_cfg_s {
2018-01-15 16:41:17 +03:00
const struct aq_hw_caps_s * aq_hw_caps ;
2018-11-09 11:54:03 +00:00
u64 features ;
2017-01-23 22:09:12 -08:00
u32 rxds ; /* rx ring size, descriptors # */
u32 txds ; /* tx ring size, descriptors # */
2019-04-29 10:04:40 +00:00
u32 vecs ; /* allocated rx/tx vectors */
u32 link_irq_vec ;
2017-01-23 22:09:12 -08:00
u32 irq_type ;
u32 itr ;
2017-10-19 18:23:58 +03:00
u16 rx_itr ;
u16 tx_itr ;
2019-03-23 15:23:32 +00:00
u32 rxpageorder ;
2017-01-23 22:09:12 -08:00
u32 num_rss_queues ;
u32 mtu ;
u32 flow_control ;
u32 link_speed_msk ;
2018-09-10 12:39:29 +03:00
u32 wol ;
2019-06-26 12:35:44 +00:00
u8 is_vlan_rx_strip ;
u8 is_vlan_tx_insert ;
2019-06-22 08:46:37 +00:00
bool is_vlan_force_promisc ;
2017-01-23 22:09:12 -08:00
u16 is_mc_list_enabled ;
u16 mc_list_count ;
bool is_autoneg ;
bool is_polling ;
bool is_rss ;
bool is_lro ;
u8 tcs ;
struct aq_rss_parameters aq_rss ;
2018-09-10 12:39:31 +03:00
u32 eee_speeds ;
2017-01-23 22:09:12 -08:00
} ;
# define AQ_NIC_FLAG_STARTED 0x00000004U
# define AQ_NIC_FLAG_STOPPING 0x00000008U
# define AQ_NIC_FLAG_RESETTING 0x00000010U
# define AQ_NIC_FLAG_CLOSING 0x00000020U
2019-10-22 09:53:35 +00:00
# define AQ_NIC_PTP_DPATH_UP 0x02000000U
2017-01-23 22:09:12 -08:00
# define AQ_NIC_LINK_DOWN 0x04000000U
# define AQ_NIC_FLAG_ERR_UNPLUG 0x40000000U
# define AQ_NIC_FLAG_ERR_HW 0x80000000U
2019-11-07 22:41:50 +00:00
# define AQ_NIC_WOL_MODES (WAKE_MAGIC |\
WAKE_PHY )
2018-09-10 12:39:29 +03:00
2017-01-23 22:09:12 -08:00
# define AQ_NIC_TCVEC2RING(_NIC_, _TC_, _VEC_) \
( ( _TC_ ) * AQ_CFG_TCS_MAX + ( _VEC_ ) )
2018-11-12 15:46:05 +00:00
struct aq_hw_rx_fl2 {
struct aq_rx_filter_vlan aq_vlans [ AQ_VLAN_MAX_FILTERS ] ;
} ;
2018-11-12 15:46:02 +00:00
struct aq_hw_rx_fl3l4 {
u8 active_ipv4 ;
u8 active_ipv6 : 2 ;
u8 is_ipv6 ;
2019-10-22 09:53:38 +00:00
u8 reserved_count ;
2018-11-12 15:46:02 +00:00
} ;
2018-11-12 15:46:00 +00:00
struct aq_hw_rx_fltrs_s {
struct hlist_head filter_list ;
u16 active_filters ;
2018-11-12 15:46:05 +00:00
struct aq_hw_rx_fl2 fl2 ;
2018-11-12 15:46:02 +00:00
struct aq_hw_rx_fl3l4 fl3l4 ;
2019-10-22 09:53:38 +00:00
/*filter ether type */
u8 fet_reserved_count ;
2018-11-12 15:46:00 +00:00
} ;
2018-01-15 16:41:19 +03:00
struct aq_nic_s {
atomic_t flags ;
2019-11-07 22:41:54 +00:00
u32 msg_enable ;
2018-01-15 16:41:19 +03:00
struct aq_vec_s * aq_vec [ AQ_CFG_VECS_MAX ] ;
struct aq_ring_s * aq_ring_tx [ AQ_CFG_VECS_MAX * AQ_CFG_TCS_MAX ] ;
struct aq_hw_s * aq_hw ;
struct net_device * ndev ;
unsigned int aq_vecs ;
unsigned int packet_filter ;
unsigned int power_state ;
u8 port ;
2018-01-19 17:03:20 +03:00
const struct aq_hw_ops * aq_hw_ops ;
2018-01-19 17:03:24 +03:00
const struct aq_fw_ops * aq_fw_ops ;
2018-01-15 16:41:19 +03:00
struct aq_nic_cfg_s aq_nic_cfg ;
struct timer_list service_timer ;
2019-04-29 10:05:00 +00:00
struct work_struct service_task ;
2018-01-15 16:41:19 +03:00
struct timer_list polling_timer ;
struct aq_hw_link_status_s link_status ;
struct {
u32 count ;
2018-07-05 17:01:09 +03:00
u8 ar [ AQ_HW_MULTICAST_ADDRESS_MAX ] [ ETH_ALEN ] ;
2018-01-15 16:41:19 +03:00
} mc_list ;
2018-11-12 15:46:09 +00:00
/* Bitmask of currently assigned vlans from linux */
unsigned long active_vlans [ BITS_TO_LONGS ( VLAN_N_VID ) ] ;
2018-01-15 16:41:19 +03:00
struct pci_dev * pdev ;
unsigned int msix_entry_mask ;
2018-05-07 16:10:39 +03:00
u32 irqvecs ;
2019-04-29 10:04:57 +00:00
/* mutex to serialize FW interface access operations */
struct mutex fwreq_mutex ;
2019-10-22 09:53:22 +00:00
/* PTP support */
struct aq_ptp_s * aq_ptp ;
2018-11-12 15:46:00 +00:00
struct aq_hw_rx_fltrs_s aq_hw_rx_fltrs ;
2018-01-15 16:41:19 +03:00
} ;
static inline struct device * aq_nic_get_dev ( struct aq_nic_s * self )
{
return self - > ndev - > dev . parent ;
}
2018-01-19 17:03:21 +03:00
void aq_nic_ndev_init ( struct aq_nic_s * self ) ;
2017-01-23 22:09:12 -08:00
struct aq_nic_s * aq_nic_alloc_hot ( struct net_device * ndev ) ;
void aq_nic_set_tx_ring ( struct aq_nic_s * self , unsigned int idx ,
struct aq_ring_s * ring ) ;
struct net_device * aq_nic_get_ndev ( struct aq_nic_s * self ) ;
int aq_nic_init ( struct aq_nic_s * self ) ;
2018-01-19 17:03:21 +03:00
void aq_nic_cfg_start ( struct aq_nic_s * self ) ;
2017-01-23 22:09:12 -08:00
int aq_nic_ndev_register ( struct aq_nic_s * self ) ;
void aq_nic_ndev_free ( struct aq_nic_s * self ) ;
int aq_nic_start ( struct aq_nic_s * self ) ;
2019-10-22 09:53:35 +00:00
unsigned int aq_nic_map_skb ( struct aq_nic_s * self , struct sk_buff * skb ,
struct aq_ring_s * ring ) ;
2017-01-23 22:09:12 -08:00
int aq_nic_xmit ( struct aq_nic_s * self , struct sk_buff * skb ) ;
int aq_nic_get_regs ( struct aq_nic_s * self , struct ethtool_regs * regs , void * p ) ;
int aq_nic_get_regs_count ( struct aq_nic_s * self ) ;
void aq_nic_get_stats ( struct aq_nic_s * self , u64 * data ) ;
int aq_nic_stop ( struct aq_nic_s * self ) ;
2019-11-07 22:41:50 +00:00
void aq_nic_deinit ( struct aq_nic_s * self , bool link_down ) ;
void aq_nic_set_power ( struct aq_nic_s * self ) ;
2017-01-23 22:09:12 -08:00
void aq_nic_free_hot_resources ( struct aq_nic_s * self ) ;
2018-01-19 17:03:21 +03:00
void aq_nic_free_vectors ( struct aq_nic_s * self ) ;
2017-01-23 22:09:12 -08:00
int aq_nic_set_mtu ( struct aq_nic_s * self , int new_mtu ) ;
int aq_nic_set_mac ( struct aq_nic_s * self , struct net_device * ndev ) ;
int aq_nic_set_packet_filter ( struct aq_nic_s * self , unsigned int flags ) ;
int aq_nic_set_multicast_list ( struct aq_nic_s * self , struct net_device * ndev ) ;
unsigned int aq_nic_get_link_speed ( struct aq_nic_s * self ) ;
2017-01-30 23:04:42 +01:00
void aq_nic_get_link_ksettings ( struct aq_nic_s * self ,
struct ethtool_link_ksettings * cmd ) ;
int aq_nic_set_link_ksettings ( struct aq_nic_s * self ,
const struct ethtool_link_ksettings * cmd ) ;
2017-01-23 22:09:12 -08:00
struct aq_nic_cfg_s * aq_nic_get_cfg ( struct aq_nic_s * self ) ;
u32 aq_nic_get_fw_version ( struct aq_nic_s * self ) ;
2017-10-19 18:23:58 +03:00
int aq_nic_update_interrupt_moderation_settings ( struct aq_nic_s * self ) ;
2018-03-20 14:40:36 +03:00
void aq_nic_shutdown ( struct aq_nic_s * self ) ;
2019-10-22 09:53:38 +00:00
u8 aq_nic_reserve_filter ( struct aq_nic_s * self , enum aq_rx_filter_type type ) ;
void aq_nic_release_filter ( struct aq_nic_s * self , enum aq_rx_filter_type type ,
u32 location ) ;
2017-01-23 22:09:12 -08:00
# endif /* AQ_NIC_H */