xref: /linux/drivers/net/ethernet/aquantia/atlantic/aq_nic.h (revision db5506156443409955d5689d4a2a49b08fb54d86)
197bde5c4SDavid VomLehn /*
297bde5c4SDavid VomLehn  * aQuantia Corporation Network Driver
397bde5c4SDavid VomLehn  * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
497bde5c4SDavid VomLehn  *
597bde5c4SDavid VomLehn  * This program is free software; you can redistribute it and/or modify it
697bde5c4SDavid VomLehn  * under the terms and conditions of the GNU General Public License,
797bde5c4SDavid VomLehn  * version 2, as published by the Free Software Foundation.
897bde5c4SDavid VomLehn  */
997bde5c4SDavid VomLehn 
1097bde5c4SDavid VomLehn /* File aq_nic.h: Declaration of common code for NIC. */
1197bde5c4SDavid VomLehn 
1297bde5c4SDavid VomLehn #ifndef AQ_NIC_H
1397bde5c4SDavid VomLehn #define AQ_NIC_H
1497bde5c4SDavid VomLehn 
1597bde5c4SDavid VomLehn #include "aq_common.h"
1697bde5c4SDavid VomLehn #include "aq_rss.h"
171a713f87SIgor Russkikh #include "aq_hw.h"
1897bde5c4SDavid VomLehn 
1997bde5c4SDavid VomLehn struct aq_ring_s;
2097bde5c4SDavid VomLehn struct aq_pci_func_s;
2197bde5c4SDavid VomLehn struct aq_hw_ops;
22*db550615SIgor Russkikh struct aq_fw_s;
23*db550615SIgor Russkikh struct aq_vec_s;
2497bde5c4SDavid VomLehn 
2597bde5c4SDavid VomLehn #define AQ_NIC_FC_OFF    0U
2697bde5c4SDavid VomLehn #define AQ_NIC_FC_TX     1U
2797bde5c4SDavid VomLehn #define AQ_NIC_FC_RX     2U
2897bde5c4SDavid VomLehn #define AQ_NIC_FC_FULL   3U
2997bde5c4SDavid VomLehn #define AQ_NIC_FC_AUTO   4U
3097bde5c4SDavid VomLehn 
3197bde5c4SDavid VomLehn #define AQ_NIC_RATE_10G        BIT(0)
3297bde5c4SDavid VomLehn #define AQ_NIC_RATE_5G         BIT(1)
3397bde5c4SDavid VomLehn #define AQ_NIC_RATE_5GSR       BIT(2)
3497bde5c4SDavid VomLehn #define AQ_NIC_RATE_2GS        BIT(3)
3597bde5c4SDavid VomLehn #define AQ_NIC_RATE_1G         BIT(4)
3697bde5c4SDavid VomLehn #define AQ_NIC_RATE_100M       BIT(5)
3797bde5c4SDavid VomLehn 
3897bde5c4SDavid VomLehn struct aq_nic_cfg_s {
394cbc9f92SIgor Russkikh 	const struct aq_hw_caps_s *aq_hw_caps;
4097bde5c4SDavid VomLehn 	u64 hw_features;
4197bde5c4SDavid VomLehn 	u32 rxds;		/* rx ring size, descriptors # */
4297bde5c4SDavid VomLehn 	u32 txds;		/* tx ring size, descriptors # */
4397bde5c4SDavid VomLehn 	u32 vecs;		/* vecs==allocated irqs */
4497bde5c4SDavid VomLehn 	u32 irq_type;
4597bde5c4SDavid VomLehn 	u32 itr;
46b82ee71aSIgor Russkikh 	u16 rx_itr;
47b82ee71aSIgor Russkikh 	u16 tx_itr;
4897bde5c4SDavid VomLehn 	u32 num_rss_queues;
4997bde5c4SDavid VomLehn 	u32 mtu;
5097bde5c4SDavid VomLehn 	u32 flow_control;
5197bde5c4SDavid VomLehn 	u32 link_speed_msk;
5297bde5c4SDavid VomLehn 	u32 vlan_id;
5397bde5c4SDavid VomLehn 	u16 is_mc_list_enabled;
5497bde5c4SDavid VomLehn 	u16 mc_list_count;
5597bde5c4SDavid VomLehn 	bool is_autoneg;
5697bde5c4SDavid VomLehn 	bool is_polling;
5797bde5c4SDavid VomLehn 	bool is_rss;
5897bde5c4SDavid VomLehn 	bool is_lro;
5997bde5c4SDavid VomLehn 	u8  tcs;
6097bde5c4SDavid VomLehn 	struct aq_rss_parameters aq_rss;
6197bde5c4SDavid VomLehn };
6297bde5c4SDavid VomLehn 
6397bde5c4SDavid VomLehn #define AQ_NIC_FLAG_STARTED     0x00000004U
6497bde5c4SDavid VomLehn #define AQ_NIC_FLAG_STOPPING    0x00000008U
6597bde5c4SDavid VomLehn #define AQ_NIC_FLAG_RESETTING   0x00000010U
6697bde5c4SDavid VomLehn #define AQ_NIC_FLAG_CLOSING     0x00000020U
6797bde5c4SDavid VomLehn #define AQ_NIC_LINK_DOWN        0x04000000U
6897bde5c4SDavid VomLehn #define AQ_NIC_FLAG_ERR_UNPLUG  0x40000000U
6997bde5c4SDavid VomLehn #define AQ_NIC_FLAG_ERR_HW      0x80000000U
7097bde5c4SDavid VomLehn 
7197bde5c4SDavid VomLehn #define AQ_NIC_TCVEC2RING(_NIC_, _TC_, _VEC_) \
7297bde5c4SDavid VomLehn 	((_TC_) * AQ_CFG_TCS_MAX + (_VEC_))
7397bde5c4SDavid VomLehn 
74*db550615SIgor Russkikh struct aq_nic_s {
75*db550615SIgor Russkikh 	atomic_t flags;
76*db550615SIgor Russkikh 	struct aq_vec_s *aq_vec[AQ_CFG_VECS_MAX];
77*db550615SIgor Russkikh 	struct aq_ring_s *aq_ring_tx[AQ_CFG_VECS_MAX * AQ_CFG_TCS_MAX];
78*db550615SIgor Russkikh 	struct aq_hw_s *aq_hw;
79*db550615SIgor Russkikh 	struct net_device *ndev;
80*db550615SIgor Russkikh 	struct aq_pci_func_s *aq_pci_func;
81*db550615SIgor Russkikh 	unsigned int aq_vecs;
82*db550615SIgor Russkikh 	unsigned int packet_filter;
83*db550615SIgor Russkikh 	unsigned int power_state;
84*db550615SIgor Russkikh 	u8 port;
85*db550615SIgor Russkikh 	struct aq_hw_ops aq_hw_ops;
86*db550615SIgor Russkikh 	struct aq_hw_caps_s aq_hw_caps;
87*db550615SIgor Russkikh 	struct aq_nic_cfg_s aq_nic_cfg;
88*db550615SIgor Russkikh 	struct timer_list service_timer;
89*db550615SIgor Russkikh 	struct timer_list polling_timer;
90*db550615SIgor Russkikh 	struct aq_hw_link_status_s link_status;
91*db550615SIgor Russkikh 	struct {
92*db550615SIgor Russkikh 		u32 count;
93*db550615SIgor Russkikh 		u8 ar[AQ_CFG_MULTICAST_ADDRESS_MAX][ETH_ALEN];
94*db550615SIgor Russkikh 	} mc_list;
95*db550615SIgor Russkikh 
96*db550615SIgor Russkikh 	struct pci_dev *pdev;
97*db550615SIgor Russkikh 	unsigned int msix_entry_mask;
98*db550615SIgor Russkikh };
99*db550615SIgor Russkikh 
100*db550615SIgor Russkikh static inline struct device *aq_nic_get_dev(struct aq_nic_s *self)
101*db550615SIgor Russkikh {
102*db550615SIgor Russkikh 	return self->ndev->dev.parent;
103*db550615SIgor Russkikh }
104*db550615SIgor Russkikh 
1055b97b0d1SIgor Russkikh struct aq_nic_s *aq_nic_alloc_cold(struct pci_dev *pdev,
10697bde5c4SDavid VomLehn 				   struct aq_pci_func_s *aq_pci_func,
10797bde5c4SDavid VomLehn 				   unsigned int port,
10897bde5c4SDavid VomLehn 				   const struct aq_hw_ops *aq_hw_ops);
10997bde5c4SDavid VomLehn int aq_nic_ndev_init(struct aq_nic_s *self);
11097bde5c4SDavid VomLehn struct aq_nic_s *aq_nic_alloc_hot(struct net_device *ndev);
11197bde5c4SDavid VomLehn void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx,
11297bde5c4SDavid VomLehn 			struct aq_ring_s *ring);
11397bde5c4SDavid VomLehn struct device *aq_nic_get_dev(struct aq_nic_s *self);
11497bde5c4SDavid VomLehn struct net_device *aq_nic_get_ndev(struct aq_nic_s *self);
11597bde5c4SDavid VomLehn int aq_nic_init(struct aq_nic_s *self);
11697bde5c4SDavid VomLehn int aq_nic_cfg_start(struct aq_nic_s *self);
11797bde5c4SDavid VomLehn int aq_nic_ndev_register(struct aq_nic_s *self);
11897bde5c4SDavid VomLehn void aq_nic_ndev_free(struct aq_nic_s *self);
11997bde5c4SDavid VomLehn int aq_nic_start(struct aq_nic_s *self);
12097bde5c4SDavid VomLehn int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb);
12197bde5c4SDavid VomLehn int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p);
12297bde5c4SDavid VomLehn int aq_nic_get_regs_count(struct aq_nic_s *self);
12397bde5c4SDavid VomLehn void aq_nic_get_stats(struct aq_nic_s *self, u64 *data);
12497bde5c4SDavid VomLehn int aq_nic_stop(struct aq_nic_s *self);
12597bde5c4SDavid VomLehn void aq_nic_deinit(struct aq_nic_s *self);
12697bde5c4SDavid VomLehn void aq_nic_free_hot_resources(struct aq_nic_s *self);
12797bde5c4SDavid VomLehn int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu);
12897bde5c4SDavid VomLehn int aq_nic_set_mac(struct aq_nic_s *self, struct net_device *ndev);
12997bde5c4SDavid VomLehn int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags);
13097bde5c4SDavid VomLehn int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev);
13197bde5c4SDavid VomLehn unsigned int aq_nic_get_link_speed(struct aq_nic_s *self);
132f8244ab5SPhilippe Reynes void aq_nic_get_link_ksettings(struct aq_nic_s *self,
133f8244ab5SPhilippe Reynes 			       struct ethtool_link_ksettings *cmd);
134f8244ab5SPhilippe Reynes int aq_nic_set_link_ksettings(struct aq_nic_s *self,
135f8244ab5SPhilippe Reynes 			      const struct ethtool_link_ksettings *cmd);
13697bde5c4SDavid VomLehn struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);
13797bde5c4SDavid VomLehn u32 aq_nic_get_fw_version(struct aq_nic_s *self);
13897bde5c4SDavid VomLehn int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg);
139b82ee71aSIgor Russkikh int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self);
14097bde5c4SDavid VomLehn 
14197bde5c4SDavid VomLehn #endif /* AQ_NIC_H */
142