David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 1 | /* |
| 2 | * aQuantia Corporation Network Driver |
| 3 | * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms and conditions of the GNU General Public License, |
| 7 | * version 2, as published by the Free Software Foundation. |
| 8 | */ |
| 9 | |
| 10 | /* File aq_nic.h: Declaration of common code for NIC. */ |
| 11 | |
| 12 | #ifndef AQ_NIC_H |
| 13 | #define AQ_NIC_H |
| 14 | |
| 15 | #include "aq_common.h" |
| 16 | #include "aq_rss.h" |
Igor Russkikh | 1a713f8 | 2018-01-15 16:41:15 +0300 | [diff] [blame] | 17 | #include "aq_hw.h" |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 18 | |
| 19 | struct aq_ring_s; |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 20 | struct aq_hw_ops; |
Igor Russkikh | db55061 | 2018-01-15 16:41:19 +0300 | [diff] [blame] | 21 | struct aq_fw_s; |
| 22 | struct aq_vec_s; |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 23 | |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 24 | struct aq_nic_cfg_s { |
Igor Russkikh | 4cbc9f9 | 2018-01-15 16:41:17 +0300 | [diff] [blame] | 25 | const struct aq_hw_caps_s *aq_hw_caps; |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 26 | u64 hw_features; |
| 27 | u32 rxds; /* rx ring size, descriptors # */ |
| 28 | u32 txds; /* tx ring size, descriptors # */ |
| 29 | u32 vecs; /* vecs==allocated irqs */ |
| 30 | u32 irq_type; |
| 31 | u32 itr; |
Igor Russkikh | b82ee71 | 2017-10-19 18:23:58 +0300 | [diff] [blame] | 32 | u16 rx_itr; |
| 33 | u16 tx_itr; |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 34 | u32 num_rss_queues; |
| 35 | u32 mtu; |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 36 | u32 flow_control; |
| 37 | u32 link_speed_msk; |
| 38 | u32 vlan_id; |
| 39 | u16 is_mc_list_enabled; |
| 40 | u16 mc_list_count; |
| 41 | bool is_autoneg; |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 42 | bool is_polling; |
| 43 | bool is_rss; |
| 44 | bool is_lro; |
| 45 | u8 tcs; |
| 46 | struct aq_rss_parameters aq_rss; |
| 47 | }; |
| 48 | |
| 49 | #define AQ_NIC_FLAG_STARTED 0x00000004U |
| 50 | #define AQ_NIC_FLAG_STOPPING 0x00000008U |
| 51 | #define AQ_NIC_FLAG_RESETTING 0x00000010U |
| 52 | #define AQ_NIC_FLAG_CLOSING 0x00000020U |
| 53 | #define AQ_NIC_LINK_DOWN 0x04000000U |
| 54 | #define AQ_NIC_FLAG_ERR_UNPLUG 0x40000000U |
| 55 | #define AQ_NIC_FLAG_ERR_HW 0x80000000U |
| 56 | |
| 57 | #define AQ_NIC_TCVEC2RING(_NIC_, _TC_, _VEC_) \ |
| 58 | ((_TC_) * AQ_CFG_TCS_MAX + (_VEC_)) |
| 59 | |
Igor Russkikh | db55061 | 2018-01-15 16:41:19 +0300 | [diff] [blame] | 60 | struct aq_nic_s { |
| 61 | atomic_t flags; |
| 62 | struct aq_vec_s *aq_vec[AQ_CFG_VECS_MAX]; |
| 63 | struct aq_ring_s *aq_ring_tx[AQ_CFG_VECS_MAX * AQ_CFG_TCS_MAX]; |
| 64 | struct aq_hw_s *aq_hw; |
| 65 | struct net_device *ndev; |
Igor Russkikh | db55061 | 2018-01-15 16:41:19 +0300 | [diff] [blame] | 66 | unsigned int aq_vecs; |
| 67 | unsigned int packet_filter; |
| 68 | unsigned int power_state; |
| 69 | u8 port; |
Igor Russkikh | 8fcb98f4 | 2018-01-19 17:03:20 +0300 | [diff] [blame] | 70 | const struct aq_hw_ops *aq_hw_ops; |
Igor Russkikh | 0c58c35 | 2018-01-19 17:03:24 +0300 | [diff] [blame] | 71 | const struct aq_fw_ops *aq_fw_ops; |
Igor Russkikh | db55061 | 2018-01-15 16:41:19 +0300 | [diff] [blame] | 72 | struct aq_nic_cfg_s aq_nic_cfg; |
| 73 | struct timer_list service_timer; |
| 74 | struct timer_list polling_timer; |
| 75 | struct aq_hw_link_status_s link_status; |
| 76 | struct { |
| 77 | u32 count; |
| 78 | u8 ar[AQ_CFG_MULTICAST_ADDRESS_MAX][ETH_ALEN]; |
| 79 | } mc_list; |
| 80 | |
| 81 | struct pci_dev *pdev; |
| 82 | unsigned int msix_entry_mask; |
Igor Russkikh | a09bd81 | 2018-05-07 16:10:39 +0300 | [diff] [blame] | 83 | u32 irqvecs; |
Igor Russkikh | db55061 | 2018-01-15 16:41:19 +0300 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | static inline struct device *aq_nic_get_dev(struct aq_nic_s *self) |
| 87 | { |
| 88 | return self->ndev->dev.parent; |
| 89 | } |
| 90 | |
Igor Russkikh | 23ee07a | 2018-01-19 17:03:21 +0300 | [diff] [blame] | 91 | void aq_nic_ndev_init(struct aq_nic_s *self); |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 92 | struct aq_nic_s *aq_nic_alloc_hot(struct net_device *ndev); |
| 93 | void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx, |
| 94 | struct aq_ring_s *ring); |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 95 | struct net_device *aq_nic_get_ndev(struct aq_nic_s *self); |
| 96 | int aq_nic_init(struct aq_nic_s *self); |
Igor Russkikh | 23ee07a | 2018-01-19 17:03:21 +0300 | [diff] [blame] | 97 | void aq_nic_cfg_start(struct aq_nic_s *self); |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 98 | int aq_nic_ndev_register(struct aq_nic_s *self); |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 99 | void aq_nic_ndev_free(struct aq_nic_s *self); |
| 100 | int aq_nic_start(struct aq_nic_s *self); |
| 101 | int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb); |
| 102 | int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p); |
| 103 | int aq_nic_get_regs_count(struct aq_nic_s *self); |
| 104 | void aq_nic_get_stats(struct aq_nic_s *self, u64 *data); |
| 105 | int aq_nic_stop(struct aq_nic_s *self); |
| 106 | void aq_nic_deinit(struct aq_nic_s *self); |
| 107 | void aq_nic_free_hot_resources(struct aq_nic_s *self); |
Igor Russkikh | 23ee07a | 2018-01-19 17:03:21 +0300 | [diff] [blame] | 108 | void aq_nic_free_vectors(struct aq_nic_s *self); |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 109 | int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu); |
| 110 | int aq_nic_set_mac(struct aq_nic_s *self, struct net_device *ndev); |
| 111 | int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags); |
| 112 | int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev); |
| 113 | unsigned int aq_nic_get_link_speed(struct aq_nic_s *self); |
Philippe Reynes | f8244ab | 2017-01-30 23:04:42 +0100 | [diff] [blame] | 114 | void aq_nic_get_link_ksettings(struct aq_nic_s *self, |
| 115 | struct ethtool_link_ksettings *cmd); |
| 116 | int aq_nic_set_link_ksettings(struct aq_nic_s *self, |
| 117 | const struct ethtool_link_ksettings *cmd); |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 118 | struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self); |
| 119 | u32 aq_nic_get_fw_version(struct aq_nic_s *self); |
| 120 | int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg); |
Igor Russkikh | b82ee71 | 2017-10-19 18:23:58 +0300 | [diff] [blame] | 121 | int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self); |
Igor Russkikh | 90869dd | 2018-03-20 14:40:36 +0300 | [diff] [blame] | 122 | void aq_nic_shutdown(struct aq_nic_s *self); |
David VomLehn | 97bde5c | 2017-01-23 22:09:12 -0800 | [diff] [blame] | 123 | |
| 124 | #endif /* AQ_NIC_H */ |