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" 17 18 struct aq_ring_s; 19 struct aq_pci_func_s; 20 struct aq_hw_ops; 21 22 #define AQ_NIC_FC_OFF 0U 23 #define AQ_NIC_FC_TX 1U 24 #define AQ_NIC_FC_RX 2U 25 #define AQ_NIC_FC_FULL 3U 26 #define AQ_NIC_FC_AUTO 4U 27 28 #define AQ_NIC_RATE_10G BIT(0) 29 #define AQ_NIC_RATE_5G BIT(1) 30 #define AQ_NIC_RATE_5GSR BIT(2) 31 #define AQ_NIC_RATE_2GS BIT(3) 32 #define AQ_NIC_RATE_1G BIT(4) 33 #define AQ_NIC_RATE_100M BIT(5) 34 35 struct aq_nic_cfg_s { 36 struct aq_hw_caps_s *aq_hw_caps; 37 u64 hw_features; 38 u32 rxds; /* rx ring size, descriptors # */ 39 u32 txds; /* tx ring size, descriptors # */ 40 u32 vecs; /* vecs==allocated irqs */ 41 u32 irq_type; 42 u32 itr; 43 u16 rx_itr; 44 u16 tx_itr; 45 u32 num_rss_queues; 46 u32 mtu; 47 u32 ucp_0x364; 48 u32 flow_control; 49 u32 link_speed_msk; 50 u32 vlan_id; 51 u16 is_mc_list_enabled; 52 u16 mc_list_count; 53 bool is_autoneg; 54 bool is_polling; 55 bool is_rss; 56 bool is_lro; 57 u8 tcs; 58 struct aq_rss_parameters aq_rss; 59 }; 60 61 #define AQ_NIC_FLAG_STARTED 0x00000004U 62 #define AQ_NIC_FLAG_STOPPING 0x00000008U 63 #define AQ_NIC_FLAG_RESETTING 0x00000010U 64 #define AQ_NIC_FLAG_CLOSING 0x00000020U 65 #define AQ_NIC_LINK_DOWN 0x04000000U 66 #define AQ_NIC_FLAG_ERR_UNPLUG 0x40000000U 67 #define AQ_NIC_FLAG_ERR_HW 0x80000000U 68 69 #define AQ_NIC_TCVEC2RING(_NIC_, _TC_, _VEC_) \ 70 ((_TC_) * AQ_CFG_TCS_MAX + (_VEC_)) 71 72 struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops, 73 const struct ethtool_ops *et_ops, 74 struct device *dev, 75 struct aq_pci_func_s *aq_pci_func, 76 unsigned int port, 77 const struct aq_hw_ops *aq_hw_ops); 78 int aq_nic_ndev_init(struct aq_nic_s *self); 79 struct aq_nic_s *aq_nic_alloc_hot(struct net_device *ndev); 80 void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx, 81 struct aq_ring_s *ring); 82 struct device *aq_nic_get_dev(struct aq_nic_s *self); 83 struct net_device *aq_nic_get_ndev(struct aq_nic_s *self); 84 int aq_nic_init(struct aq_nic_s *self); 85 int aq_nic_cfg_start(struct aq_nic_s *self); 86 int aq_nic_ndev_register(struct aq_nic_s *self); 87 void aq_nic_ndev_free(struct aq_nic_s *self); 88 int aq_nic_start(struct aq_nic_s *self); 89 int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb); 90 int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p); 91 int aq_nic_get_regs_count(struct aq_nic_s *self); 92 void aq_nic_get_stats(struct aq_nic_s *self, u64 *data); 93 int aq_nic_stop(struct aq_nic_s *self); 94 void aq_nic_deinit(struct aq_nic_s *self); 95 void aq_nic_free_hot_resources(struct aq_nic_s *self); 96 int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu); 97 int aq_nic_set_mac(struct aq_nic_s *self, struct net_device *ndev); 98 int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags); 99 int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev); 100 unsigned int aq_nic_get_link_speed(struct aq_nic_s *self); 101 void aq_nic_get_link_ksettings(struct aq_nic_s *self, 102 struct ethtool_link_ksettings *cmd); 103 int aq_nic_set_link_ksettings(struct aq_nic_s *self, 104 const struct ethtool_link_ksettings *cmd); 105 struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self); 106 u32 aq_nic_get_fw_version(struct aq_nic_s *self); 107 int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg); 108 int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self); 109 110 #endif /* AQ_NIC_H */ 111