aq_nic.h 4.5 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0-only */
2 3
/*
 * aQuantia Corporation Network Driver
4
 * Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved
5 6 7 8 9 10 11 12 13
 */

/* 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"
14
#include "aq_hw.h"
15 16 17

struct aq_ring_s;
struct aq_hw_ops;
18 19
struct aq_fw_s;
struct aq_vec_s;
20
struct aq_ptp_s;
21 22

struct aq_nic_cfg_s {
23
	const struct aq_hw_caps_s *aq_hw_caps;
24
	u64 features;
25 26
	u32 rxds;		/* rx ring size, descriptors # */
	u32 txds;		/* tx ring size, descriptors # */
27 28
	u32 vecs;		/* allocated rx/tx vectors */
	u32 link_irq_vec;
29 30
	u32 irq_type;
	u32 itr;
31 32
	u16 rx_itr;
	u16 tx_itr;
33
	u32 rxpageorder;
34 35 36 37
	u32 num_rss_queues;
	u32 mtu;
	u32 flow_control;
	u32 link_speed_msk;
Y
Yana Esina 已提交
38
	u32 wol;
39 40
	u8 is_vlan_rx_strip;
	u8 is_vlan_tx_insert;
41
	bool is_vlan_force_promisc;
42 43 44 45 46 47 48 49
	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;
50
	u32 eee_speeds;
51 52 53 54 55 56 57 58 59 60
};

#define AQ_NIC_FLAG_STARTED     0x00000004U
#define AQ_NIC_FLAG_STOPPING    0x00000008U
#define AQ_NIC_FLAG_RESETTING   0x00000010U
#define AQ_NIC_FLAG_CLOSING     0x00000020U
#define AQ_NIC_LINK_DOWN        0x04000000U
#define AQ_NIC_FLAG_ERR_UNPLUG  0x40000000U
#define AQ_NIC_FLAG_ERR_HW      0x80000000U

Y
Yana Esina 已提交
61 62
#define AQ_NIC_WOL_ENABLED	BIT(0)

63 64 65
#define AQ_NIC_TCVEC2RING(_NIC_, _TC_, _VEC_) \
	((_TC_) * AQ_CFG_TCS_MAX + (_VEC_))

66 67 68 69
struct aq_hw_rx_fl2 {
	struct aq_rx_filter_vlan aq_vlans[AQ_VLAN_MAX_FILTERS];
};

70 71 72 73 74 75
struct aq_hw_rx_fl3l4 {
	u8   active_ipv4;
	u8   active_ipv6:2;
	u8 is_ipv6;
};

76 77 78
struct aq_hw_rx_fltrs_s {
	struct hlist_head     filter_list;
	u16                   active_filters;
79
	struct aq_hw_rx_fl2   fl2;
80
	struct aq_hw_rx_fl3l4 fl3l4;
81 82
};

83 84 85 86 87 88 89 90 91 92
struct aq_nic_s {
	atomic_t flags;
	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;
93
	const struct aq_hw_ops *aq_hw_ops;
94
	const struct aq_fw_ops *aq_fw_ops;
95 96
	struct aq_nic_cfg_s aq_nic_cfg;
	struct timer_list service_timer;
97
	struct work_struct service_task;
98 99 100 101
	struct timer_list polling_timer;
	struct aq_hw_link_status_s link_status;
	struct {
		u32 count;
102
		u8 ar[AQ_HW_MULTICAST_ADDRESS_MAX][ETH_ALEN];
103
	} mc_list;
104 105
	/* Bitmask of currently assigned vlans from linux */
	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
106 107 108

	struct pci_dev *pdev;
	unsigned int msix_entry_mask;
109
	u32 irqvecs;
110 111
	/* mutex to serialize FW interface access operations */
	struct mutex fwreq_mutex;
112 113
	/* PTP support */
	struct aq_ptp_s *aq_ptp;
114
	struct aq_hw_rx_fltrs_s aq_hw_rx_fltrs;
115 116 117 118 119 120 121
};

static inline struct device *aq_nic_get_dev(struct aq_nic_s *self)
{
	return self->ndev->dev.parent;
}

122
void aq_nic_ndev_init(struct aq_nic_s *self);
123 124 125 126 127
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);
128
void aq_nic_cfg_start(struct aq_nic_s *self);
129 130 131 132 133 134 135 136 137 138
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);
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);
void aq_nic_deinit(struct aq_nic_s *self);
void aq_nic_free_hot_resources(struct aq_nic_s *self);
139
void aq_nic_free_vectors(struct aq_nic_s *self);
140 141 142 143 144
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);
145 146 147 148
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);
149 150 151
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);
int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg);
152
int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self);
153
void aq_nic_shutdown(struct aq_nic_s *self);
154 155

#endif /* AQ_NIC_H */