18c2ecf20Sopenharmony_ci/******************************************************************************
28c2ecf20Sopenharmony_ci * This software may be used and distributed according to the terms of
38c2ecf20Sopenharmony_ci * the GNU General Public License (GPL), incorporated herein by reference.
48c2ecf20Sopenharmony_ci * Drivers based on or derived from this code fall under the GPL and must
58c2ecf20Sopenharmony_ci * retain the authorship, copyright and license notice.  This file is not
68c2ecf20Sopenharmony_ci * a complete program and may only be used when the entire operating
78c2ecf20Sopenharmony_ci * system is licensed under the GPL.
88c2ecf20Sopenharmony_ci * See the file COPYING in this distribution for more information.
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * vxge-main.h: Driver for Exar Corp's X3100 Series 10GbE PCIe I/O
118c2ecf20Sopenharmony_ci *              Virtualized Server Adapter.
128c2ecf20Sopenharmony_ci * Copyright(c) 2002-2010 Exar Corp.
138c2ecf20Sopenharmony_ci ******************************************************************************/
148c2ecf20Sopenharmony_ci#ifndef VXGE_MAIN_H
158c2ecf20Sopenharmony_ci#define VXGE_MAIN_H
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include "vxge-traffic.h"
188c2ecf20Sopenharmony_ci#include "vxge-config.h"
198c2ecf20Sopenharmony_ci#include "vxge-version.h"
208c2ecf20Sopenharmony_ci#include <linux/list.h>
218c2ecf20Sopenharmony_ci#include <linux/bitops.h>
228c2ecf20Sopenharmony_ci#include <linux/if_vlan.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define VXGE_DRIVER_NAME		"vxge"
258c2ecf20Sopenharmony_ci#define VXGE_DRIVER_VENDOR		"Neterion, Inc"
268c2ecf20Sopenharmony_ci#define VXGE_DRIVER_FW_VERSION_MAJOR	1
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define DRV_VERSION	VXGE_VERSION_MAJOR"."VXGE_VERSION_MINOR"."\
298c2ecf20Sopenharmony_ci	VXGE_VERSION_FIX"."VXGE_VERSION_BUILD"-"\
308c2ecf20Sopenharmony_ci	VXGE_VERSION_FOR
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_TITAN_WIN		0x5733
338c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_TITAN_UNI		0x5833
348c2ecf20Sopenharmony_ci#define VXGE_HW_TITAN1_PCI_REVISION	1
358c2ecf20Sopenharmony_ci#define VXGE_HW_TITAN1A_PCI_REVISION	2
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define	VXGE_USE_DEFAULT		0xffffffff
388c2ecf20Sopenharmony_ci#define VXGE_HW_VPATH_MSIX_ACTIVE	4
398c2ecf20Sopenharmony_ci#define VXGE_ALARM_MSIX_ID		2
408c2ecf20Sopenharmony_ci#define VXGE_HW_RXSYNC_FREQ_CNT		4
418c2ecf20Sopenharmony_ci#define VXGE_LL_WATCH_DOG_TIMEOUT	(15 * HZ)
428c2ecf20Sopenharmony_ci#define VXGE_LL_RX_COPY_THRESHOLD	256
438c2ecf20Sopenharmony_ci#define VXGE_DEF_FIFO_LENGTH		84
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define NO_STEERING		0
468c2ecf20Sopenharmony_ci#define PORT_STEERING		0x1
478c2ecf20Sopenharmony_ci#define RTH_STEERING		0x2
488c2ecf20Sopenharmony_ci#define RX_TOS_STEERING		0x3
498c2ecf20Sopenharmony_ci#define RX_VLAN_STEERING	0x4
508c2ecf20Sopenharmony_ci#define RTH_BUCKET_SIZE		4
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define	TX_PRIORITY_STEERING	1
538c2ecf20Sopenharmony_ci#define	TX_VLAN_STEERING	2
548c2ecf20Sopenharmony_ci#define	TX_PORT_STEERING	3
558c2ecf20Sopenharmony_ci#define	TX_MULTIQ_STEERING	4
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define VXGE_HW_MAC_ADDR_LEARN_DEFAULT VXGE_HW_RTS_MAC_DISABLE
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define VXGE_TTI_BTIMER_VAL 250000
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define VXGE_TTI_LTIMER_VAL	1000
628c2ecf20Sopenharmony_ci#define VXGE_T1A_TTI_LTIMER_VAL	80
638c2ecf20Sopenharmony_ci#define VXGE_TTI_RTIMER_VAL	0
648c2ecf20Sopenharmony_ci#define VXGE_TTI_RTIMER_ADAPT_VAL	10
658c2ecf20Sopenharmony_ci#define VXGE_T1A_TTI_RTIMER_VAL	400
668c2ecf20Sopenharmony_ci#define VXGE_RTI_BTIMER_VAL	250
678c2ecf20Sopenharmony_ci#define VXGE_RTI_LTIMER_VAL	100
688c2ecf20Sopenharmony_ci#define VXGE_RTI_RTIMER_VAL	0
698c2ecf20Sopenharmony_ci#define VXGE_RTI_RTIMER_ADAPT_VAL	15
708c2ecf20Sopenharmony_ci#define VXGE_FIFO_INDICATE_MAX_PKTS	VXGE_DEF_FIFO_LENGTH
718c2ecf20Sopenharmony_ci#define VXGE_ISR_POLLING_CNT 	8
728c2ecf20Sopenharmony_ci#define VXGE_MAX_CONFIG_DEV	0xFF
738c2ecf20Sopenharmony_ci#define VXGE_EXEC_MODE_DISABLE	0
748c2ecf20Sopenharmony_ci#define VXGE_EXEC_MODE_ENABLE	1
758c2ecf20Sopenharmony_ci#define VXGE_MAX_CONFIG_PORT	1
768c2ecf20Sopenharmony_ci#define VXGE_ALL_VID_DISABLE	0
778c2ecf20Sopenharmony_ci#define VXGE_ALL_VID_ENABLE	1
788c2ecf20Sopenharmony_ci#define VXGE_PAUSE_CTRL_DISABLE	0
798c2ecf20Sopenharmony_ci#define VXGE_PAUSE_CTRL_ENABLE	1
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#define TTI_TX_URANGE_A	5
828c2ecf20Sopenharmony_ci#define TTI_TX_URANGE_B	15
838c2ecf20Sopenharmony_ci#define TTI_TX_URANGE_C	40
848c2ecf20Sopenharmony_ci#define TTI_TX_UFC_A	5
858c2ecf20Sopenharmony_ci#define TTI_TX_UFC_B	40
868c2ecf20Sopenharmony_ci#define TTI_TX_UFC_C	60
878c2ecf20Sopenharmony_ci#define TTI_TX_UFC_D	100
888c2ecf20Sopenharmony_ci#define TTI_T1A_TX_UFC_A	30
898c2ecf20Sopenharmony_ci#define TTI_T1A_TX_UFC_B	80
908c2ecf20Sopenharmony_ci/* Slope - (max_mtu - min_mtu)/(max_mtu_ufc - min_mtu_ufc) */
918c2ecf20Sopenharmony_ci/* Slope - 93 */
928c2ecf20Sopenharmony_ci/* 60 - 9k Mtu, 140 - 1.5k mtu */
938c2ecf20Sopenharmony_ci#define TTI_T1A_TX_UFC_C(mtu)	(60 + ((VXGE_HW_MAX_MTU - mtu) / 93))
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci/* Slope - 37 */
968c2ecf20Sopenharmony_ci/* 100 - 9k Mtu, 300 - 1.5k mtu */
978c2ecf20Sopenharmony_ci#define TTI_T1A_TX_UFC_D(mtu)	(100 + ((VXGE_HW_MAX_MTU - mtu) / 37))
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#define RTI_RX_URANGE_A		5
1018c2ecf20Sopenharmony_ci#define RTI_RX_URANGE_B		15
1028c2ecf20Sopenharmony_ci#define RTI_RX_URANGE_C		40
1038c2ecf20Sopenharmony_ci#define RTI_T1A_RX_URANGE_A	1
1048c2ecf20Sopenharmony_ci#define RTI_T1A_RX_URANGE_B	20
1058c2ecf20Sopenharmony_ci#define RTI_T1A_RX_URANGE_C	50
1068c2ecf20Sopenharmony_ci#define RTI_RX_UFC_A		1
1078c2ecf20Sopenharmony_ci#define RTI_RX_UFC_B		5
1088c2ecf20Sopenharmony_ci#define RTI_RX_UFC_C		10
1098c2ecf20Sopenharmony_ci#define RTI_RX_UFC_D		15
1108c2ecf20Sopenharmony_ci#define RTI_T1A_RX_UFC_B	20
1118c2ecf20Sopenharmony_ci#define RTI_T1A_RX_UFC_C	50
1128c2ecf20Sopenharmony_ci#define RTI_T1A_RX_UFC_D	60
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci/*
1158c2ecf20Sopenharmony_ci * The interrupt rate is maintained at 3k per second with the moderation
1168c2ecf20Sopenharmony_ci * parameters for most traffic but not all. This is the maximum interrupt
1178c2ecf20Sopenharmony_ci * count allowed per function with INTA or per vector in the case of
1188c2ecf20Sopenharmony_ci * MSI-X in a 10 millisecond time period. Enabled only for Titan 1A.
1198c2ecf20Sopenharmony_ci */
1208c2ecf20Sopenharmony_ci#define VXGE_T1A_MAX_INTERRUPT_COUNT	100
1218c2ecf20Sopenharmony_ci#define VXGE_T1A_MAX_TX_INTERRUPT_COUNT	200
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci/* Milli secs timer period */
1248c2ecf20Sopenharmony_ci#define VXGE_TIMER_DELAY		10000
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci#define VXGE_LL_MAX_FRAME_SIZE(dev) ((dev)->mtu + VXGE_HW_MAC_HEADER_MAX_SIZE)
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci#define is_sriov(function_mode) \
1298c2ecf20Sopenharmony_ci	((function_mode == VXGE_HW_FUNCTION_MODE_SRIOV) || \
1308c2ecf20Sopenharmony_ci	(function_mode == VXGE_HW_FUNCTION_MODE_SRIOV_8) || \
1318c2ecf20Sopenharmony_ci	(function_mode == VXGE_HW_FUNCTION_MODE_SRIOV_4))
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_cienum vxge_reset_event {
1348c2ecf20Sopenharmony_ci	/* reset events */
1358c2ecf20Sopenharmony_ci	VXGE_LL_VPATH_RESET	= 0,
1368c2ecf20Sopenharmony_ci	VXGE_LL_DEVICE_RESET	= 1,
1378c2ecf20Sopenharmony_ci	VXGE_LL_FULL_RESET	= 2,
1388c2ecf20Sopenharmony_ci	VXGE_LL_START_RESET	= 3,
1398c2ecf20Sopenharmony_ci	VXGE_LL_COMPL_RESET	= 4
1408c2ecf20Sopenharmony_ci};
1418c2ecf20Sopenharmony_ci/* These flags represent the devices temporary state */
1428c2ecf20Sopenharmony_cienum vxge_device_state_t {
1438c2ecf20Sopenharmony_ci__VXGE_STATE_RESET_CARD = 0,
1448c2ecf20Sopenharmony_ci__VXGE_STATE_CARD_UP
1458c2ecf20Sopenharmony_ci};
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_cienum vxge_mac_addr_state {
1488c2ecf20Sopenharmony_ci	/* mac address states */
1498c2ecf20Sopenharmony_ci	VXGE_LL_MAC_ADDR_IN_LIST        = 0,
1508c2ecf20Sopenharmony_ci	VXGE_LL_MAC_ADDR_IN_DA_TABLE    = 1
1518c2ecf20Sopenharmony_ci};
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistruct vxge_drv_config {
1548c2ecf20Sopenharmony_ci	int config_dev_cnt;
1558c2ecf20Sopenharmony_ci	int total_dev_cnt;
1568c2ecf20Sopenharmony_ci	int g_no_cpus;
1578c2ecf20Sopenharmony_ci	unsigned int vpath_per_dev;
1588c2ecf20Sopenharmony_ci};
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_cistruct macInfo {
1618c2ecf20Sopenharmony_ci	unsigned char macaddr[ETH_ALEN];
1628c2ecf20Sopenharmony_ci	unsigned char macmask[ETH_ALEN];
1638c2ecf20Sopenharmony_ci	unsigned int vpath_no;
1648c2ecf20Sopenharmony_ci	enum vxge_mac_addr_state state;
1658c2ecf20Sopenharmony_ci};
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_cistruct vxge_config {
1688c2ecf20Sopenharmony_ci	int		tx_pause_enable;
1698c2ecf20Sopenharmony_ci	int		rx_pause_enable;
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci#define	NEW_NAPI_WEIGHT	64
1728c2ecf20Sopenharmony_ci	int		napi_weight;
1738c2ecf20Sopenharmony_ci	int		intr_type;
1748c2ecf20Sopenharmony_ci#define INTA	0
1758c2ecf20Sopenharmony_ci#define MSI	1
1768c2ecf20Sopenharmony_ci#define MSI_X	2
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci	int		addr_learn_en;
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci	u32		rth_steering:2,
1818c2ecf20Sopenharmony_ci			rth_algorithm:2,
1828c2ecf20Sopenharmony_ci			rth_hash_type_tcpipv4:1,
1838c2ecf20Sopenharmony_ci			rth_hash_type_ipv4:1,
1848c2ecf20Sopenharmony_ci			rth_hash_type_tcpipv6:1,
1858c2ecf20Sopenharmony_ci			rth_hash_type_ipv6:1,
1868c2ecf20Sopenharmony_ci			rth_hash_type_tcpipv6ex:1,
1878c2ecf20Sopenharmony_ci			rth_hash_type_ipv6ex:1,
1888c2ecf20Sopenharmony_ci			rth_bkt_sz:8;
1898c2ecf20Sopenharmony_ci	int		rth_jhash_golden_ratio;
1908c2ecf20Sopenharmony_ci	int		tx_steering_type;
1918c2ecf20Sopenharmony_ci	int 	fifo_indicate_max_pkts;
1928c2ecf20Sopenharmony_ci	struct vxge_hw_device_hw_info device_hw_info;
1938c2ecf20Sopenharmony_ci};
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_cistruct vxge_msix_entry {
1968c2ecf20Sopenharmony_ci	/* Mimicing the msix_entry struct of Kernel. */
1978c2ecf20Sopenharmony_ci	u16 vector;
1988c2ecf20Sopenharmony_ci	u16 entry;
1998c2ecf20Sopenharmony_ci	u16 in_use;
2008c2ecf20Sopenharmony_ci	void *arg;
2018c2ecf20Sopenharmony_ci};
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci/* Software Statistics */
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_cistruct vxge_sw_stats {
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci	/* Virtual Path */
2088c2ecf20Sopenharmony_ci	unsigned long vpaths_open;
2098c2ecf20Sopenharmony_ci	unsigned long vpath_open_fail;
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci	/* Misc. */
2128c2ecf20Sopenharmony_ci	unsigned long link_up;
2138c2ecf20Sopenharmony_ci	unsigned long link_down;
2148c2ecf20Sopenharmony_ci};
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_cistruct vxge_mac_addrs {
2178c2ecf20Sopenharmony_ci	struct list_head item;
2188c2ecf20Sopenharmony_ci	u64 macaddr;
2198c2ecf20Sopenharmony_ci	u64 macmask;
2208c2ecf20Sopenharmony_ci	enum vxge_mac_addr_state state;
2218c2ecf20Sopenharmony_ci};
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_cistruct vxgedev;
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_cistruct vxge_fifo_stats {
2268c2ecf20Sopenharmony_ci	struct u64_stats_sync	syncp;
2278c2ecf20Sopenharmony_ci	u64 tx_frms;
2288c2ecf20Sopenharmony_ci	u64 tx_bytes;
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci	unsigned long tx_errors;
2318c2ecf20Sopenharmony_ci	unsigned long txd_not_free;
2328c2ecf20Sopenharmony_ci	unsigned long txd_out_of_desc;
2338c2ecf20Sopenharmony_ci	unsigned long pci_map_fail;
2348c2ecf20Sopenharmony_ci};
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_cistruct vxge_fifo {
2378c2ecf20Sopenharmony_ci	struct net_device *ndev;
2388c2ecf20Sopenharmony_ci	struct pci_dev *pdev;
2398c2ecf20Sopenharmony_ci	struct __vxge_hw_fifo *handle;
2408c2ecf20Sopenharmony_ci	struct netdev_queue *txq;
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci	int tx_steering_type;
2438c2ecf20Sopenharmony_ci	int indicate_max_pkts;
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci	/* Adaptive interrupt moderation parameters used in T1A */
2468c2ecf20Sopenharmony_ci	unsigned long interrupt_count;
2478c2ecf20Sopenharmony_ci	unsigned long jiffies;
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci	u32 tx_vector_no;
2508c2ecf20Sopenharmony_ci	/* Tx stats */
2518c2ecf20Sopenharmony_ci	struct vxge_fifo_stats stats;
2528c2ecf20Sopenharmony_ci} ____cacheline_aligned;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_cistruct vxge_ring_stats {
2558c2ecf20Sopenharmony_ci	struct u64_stats_sync syncp;
2568c2ecf20Sopenharmony_ci	u64 rx_frms;
2578c2ecf20Sopenharmony_ci	u64 rx_mcast;
2588c2ecf20Sopenharmony_ci	u64 rx_bytes;
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci	unsigned long rx_errors;
2618c2ecf20Sopenharmony_ci	unsigned long rx_dropped;
2628c2ecf20Sopenharmony_ci	unsigned long prev_rx_frms;
2638c2ecf20Sopenharmony_ci	unsigned long pci_map_fail;
2648c2ecf20Sopenharmony_ci	unsigned long skb_alloc_fail;
2658c2ecf20Sopenharmony_ci};
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_cistruct vxge_ring {
2688c2ecf20Sopenharmony_ci	struct net_device	*ndev;
2698c2ecf20Sopenharmony_ci	struct pci_dev		*pdev;
2708c2ecf20Sopenharmony_ci	struct __vxge_hw_ring	*handle;
2718c2ecf20Sopenharmony_ci	/* The vpath id maintained in the driver -
2728c2ecf20Sopenharmony_ci	 * 0 to 'maximum_vpaths_in_function - 1'
2738c2ecf20Sopenharmony_ci	 */
2748c2ecf20Sopenharmony_ci	int driver_id;
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	/* Adaptive interrupt moderation parameters used in T1A */
2778c2ecf20Sopenharmony_ci	unsigned long interrupt_count;
2788c2ecf20Sopenharmony_ci	unsigned long jiffies;
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci	/* copy of the flag indicating whether rx_hwts is to be used */
2818c2ecf20Sopenharmony_ci	u32 rx_hwts:1;
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci	int pkts_processed;
2848c2ecf20Sopenharmony_ci	int budget;
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci	struct napi_struct napi;
2878c2ecf20Sopenharmony_ci	struct napi_struct *napi_p;
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci#define VXGE_MAX_MAC_ADDR_COUNT		30
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci	int vlan_tag_strip;
2928c2ecf20Sopenharmony_ci	u32 rx_vector_no;
2938c2ecf20Sopenharmony_ci	enum vxge_hw_status last_status;
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ci	/* Rx stats */
2968c2ecf20Sopenharmony_ci	struct vxge_ring_stats stats;
2978c2ecf20Sopenharmony_ci} ____cacheline_aligned;
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_cistruct vxge_vpath {
3008c2ecf20Sopenharmony_ci	struct vxge_fifo fifo;
3018c2ecf20Sopenharmony_ci	struct vxge_ring ring;
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	struct __vxge_hw_vpath_handle *handle;
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	/* Actual vpath id for this vpath in the device - 0 to 16 */
3068c2ecf20Sopenharmony_ci	int device_id;
3078c2ecf20Sopenharmony_ci	int max_mac_addr_cnt;
3088c2ecf20Sopenharmony_ci	int is_configured;
3098c2ecf20Sopenharmony_ci	int is_open;
3108c2ecf20Sopenharmony_ci	struct vxgedev *vdev;
3118c2ecf20Sopenharmony_ci	u8 macaddr[ETH_ALEN];
3128c2ecf20Sopenharmony_ci	u8 macmask[ETH_ALEN];
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_ci#define VXGE_MAX_LEARN_MAC_ADDR_CNT	2048
3158c2ecf20Sopenharmony_ci	/* mac addresses currently programmed into NIC */
3168c2ecf20Sopenharmony_ci	u16 mac_addr_cnt;
3178c2ecf20Sopenharmony_ci	u16 mcast_addr_cnt;
3188c2ecf20Sopenharmony_ci	struct list_head mac_addr_list;
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci	u32 level_err;
3218c2ecf20Sopenharmony_ci	u32 level_trace;
3228c2ecf20Sopenharmony_ci};
3238c2ecf20Sopenharmony_ci#define VXGE_COPY_DEBUG_INFO_TO_LL(vdev, err, trace) {	\
3248c2ecf20Sopenharmony_ci	for (i = 0; i < vdev->no_of_vpath; i++) {		\
3258c2ecf20Sopenharmony_ci		vdev->vpaths[i].level_err = err;		\
3268c2ecf20Sopenharmony_ci		vdev->vpaths[i].level_trace = trace;		\
3278c2ecf20Sopenharmony_ci	}							\
3288c2ecf20Sopenharmony_ci	vdev->level_err = err;					\
3298c2ecf20Sopenharmony_ci	vdev->level_trace = trace;				\
3308c2ecf20Sopenharmony_ci}
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_cistruct vxgedev {
3338c2ecf20Sopenharmony_ci	struct net_device	*ndev;
3348c2ecf20Sopenharmony_ci	struct pci_dev		*pdev;
3358c2ecf20Sopenharmony_ci	struct __vxge_hw_device *devh;
3368c2ecf20Sopenharmony_ci	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
3378c2ecf20Sopenharmony_ci	int vlan_tag_strip;
3388c2ecf20Sopenharmony_ci	struct vxge_config	config;
3398c2ecf20Sopenharmony_ci	unsigned long	state;
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci	/* Indicates which vpath to reset */
3428c2ecf20Sopenharmony_ci	unsigned long  vp_reset;
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci	/* Timer used for polling vpath resets */
3458c2ecf20Sopenharmony_ci	struct timer_list vp_reset_timer;
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci	/* Timer used for polling vpath lockup */
3488c2ecf20Sopenharmony_ci	struct timer_list vp_lockup_timer;
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci	/*
3518c2ecf20Sopenharmony_ci	 * Flags to track whether device is in All Multicast
3528c2ecf20Sopenharmony_ci	 * or in promiscuous mode.
3538c2ecf20Sopenharmony_ci	 */
3548c2ecf20Sopenharmony_ci	u16		all_multi_flg;
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci	/* A flag indicating whether rx_hwts is to be used or not. */
3578c2ecf20Sopenharmony_ci	u32	rx_hwts:1,
3588c2ecf20Sopenharmony_ci		titan1:1;
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci	struct vxge_msix_entry *vxge_entries;
3618c2ecf20Sopenharmony_ci	struct msix_entry *entries;
3628c2ecf20Sopenharmony_ci	/*
3638c2ecf20Sopenharmony_ci	 * 4 for each vpath * 17;
3648c2ecf20Sopenharmony_ci	 * total is 68
3658c2ecf20Sopenharmony_ci	 */
3668c2ecf20Sopenharmony_ci#define	VXGE_MAX_REQUESTED_MSIX	68
3678c2ecf20Sopenharmony_ci#define VXGE_INTR_STRLEN 80
3688c2ecf20Sopenharmony_ci	char desc[VXGE_MAX_REQUESTED_MSIX][VXGE_INTR_STRLEN];
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci	enum vxge_hw_event cric_err_event;
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	int max_vpath_supported;
3738c2ecf20Sopenharmony_ci	int no_of_vpath;
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci	struct napi_struct napi;
3768c2ecf20Sopenharmony_ci	/* A debug option, when enabled and if error condition occurs,
3778c2ecf20Sopenharmony_ci	 * the driver will do following steps:
3788c2ecf20Sopenharmony_ci	 * - mask all interrupts
3798c2ecf20Sopenharmony_ci	 * - Not clear the source of the alarm
3808c2ecf20Sopenharmony_ci	 * - gracefully stop all I/O
3818c2ecf20Sopenharmony_ci	 * A diagnostic dump of register and stats at this point
3828c2ecf20Sopenharmony_ci	 * reveals very useful information.
3838c2ecf20Sopenharmony_ci	 */
3848c2ecf20Sopenharmony_ci	int exec_mode;
3858c2ecf20Sopenharmony_ci	int max_config_port;
3868c2ecf20Sopenharmony_ci	struct vxge_vpath	*vpaths;
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci	struct __vxge_hw_vpath_handle *vp_handles[VXGE_HW_MAX_VIRTUAL_PATHS];
3898c2ecf20Sopenharmony_ci	void __iomem *bar0;
3908c2ecf20Sopenharmony_ci	struct vxge_sw_stats	stats;
3918c2ecf20Sopenharmony_ci	int		mtu;
3928c2ecf20Sopenharmony_ci	/* Below variables are used for vpath selection to transmit a packet */
3938c2ecf20Sopenharmony_ci	u8 		vpath_selector[VXGE_HW_MAX_VIRTUAL_PATHS];
3948c2ecf20Sopenharmony_ci	u64		vpaths_deployed;
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_ci	u32 		intr_cnt;
3978c2ecf20Sopenharmony_ci	u32 		level_err;
3988c2ecf20Sopenharmony_ci	u32 		level_trace;
3998c2ecf20Sopenharmony_ci	char		fw_version[VXGE_HW_FW_STRLEN];
4008c2ecf20Sopenharmony_ci	struct work_struct reset_task;
4018c2ecf20Sopenharmony_ci};
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_cistruct vxge_rx_priv {
4048c2ecf20Sopenharmony_ci	struct sk_buff		*skb;
4058c2ecf20Sopenharmony_ci	unsigned char		*skb_data;
4068c2ecf20Sopenharmony_ci	dma_addr_t		data_dma;
4078c2ecf20Sopenharmony_ci	dma_addr_t		data_size;
4088c2ecf20Sopenharmony_ci};
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_cistruct vxge_tx_priv {
4118c2ecf20Sopenharmony_ci	struct sk_buff		*skb;
4128c2ecf20Sopenharmony_ci	dma_addr_t		dma_buffers[MAX_SKB_FRAGS+1];
4138c2ecf20Sopenharmony_ci};
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci#define VXGE_MODULE_PARAM_INT(p, val) \
4168c2ecf20Sopenharmony_ci	static int p = val; \
4178c2ecf20Sopenharmony_ci	module_param(p, int, 0)
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_cistatic inline
4208c2ecf20Sopenharmony_civoid vxge_os_timer(struct timer_list *timer, void (*func)(struct timer_list *),
4218c2ecf20Sopenharmony_ci		   unsigned long timeout)
4228c2ecf20Sopenharmony_ci{
4238c2ecf20Sopenharmony_ci	timer_setup(timer, func, 0);
4248c2ecf20Sopenharmony_ci	mod_timer(timer, jiffies + timeout);
4258c2ecf20Sopenharmony_ci}
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_civoid vxge_initialize_ethtool_ops(struct net_device *ndev);
4288c2ecf20Sopenharmony_ciint vxge_fw_upgrade(struct vxgedev *vdev, char *fw_name, int override);
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci/* #define VXGE_DEBUG_INIT: debug for initialization functions
4318c2ecf20Sopenharmony_ci * #define VXGE_DEBUG_TX	 : debug transmit related functions
4328c2ecf20Sopenharmony_ci * #define VXGE_DEBUG_RX  : debug recevice related functions
4338c2ecf20Sopenharmony_ci * #define VXGE_DEBUG_MEM : debug memory module
4348c2ecf20Sopenharmony_ci * #define VXGE_DEBUG_LOCK: debug locks
4358c2ecf20Sopenharmony_ci * #define VXGE_DEBUG_SEM : debug semaphore
4368c2ecf20Sopenharmony_ci * #define VXGE_DEBUG_ENTRYEXIT: debug functions by adding entry exit statements
4378c2ecf20Sopenharmony_ci*/
4388c2ecf20Sopenharmony_ci#define VXGE_DEBUG_INIT		0x00000001
4398c2ecf20Sopenharmony_ci#define VXGE_DEBUG_TX		0x00000002
4408c2ecf20Sopenharmony_ci#define VXGE_DEBUG_RX		0x00000004
4418c2ecf20Sopenharmony_ci#define VXGE_DEBUG_MEM		0x00000008
4428c2ecf20Sopenharmony_ci#define VXGE_DEBUG_LOCK		0x00000010
4438c2ecf20Sopenharmony_ci#define VXGE_DEBUG_SEM		0x00000020
4448c2ecf20Sopenharmony_ci#define VXGE_DEBUG_ENTRYEXIT	0x00000040
4458c2ecf20Sopenharmony_ci#define VXGE_DEBUG_INTR		0x00000080
4468c2ecf20Sopenharmony_ci#define VXGE_DEBUG_LL_CONFIG	0x00000100
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ci/* Debug tracing for VXGE driver */
4498c2ecf20Sopenharmony_ci#ifndef VXGE_DEBUG_MASK
4508c2ecf20Sopenharmony_ci#define VXGE_DEBUG_MASK	0x0
4518c2ecf20Sopenharmony_ci#endif
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci#if (VXGE_DEBUG_LL_CONFIG & VXGE_DEBUG_MASK)
4548c2ecf20Sopenharmony_ci#define vxge_debug_ll_config(level, fmt, ...) \
4558c2ecf20Sopenharmony_ci	vxge_debug_ll(level, VXGE_DEBUG_LL_CONFIG, fmt, ##__VA_ARGS__)
4568c2ecf20Sopenharmony_ci#else
4578c2ecf20Sopenharmony_ci#define vxge_debug_ll_config(level, fmt, ...)
4588c2ecf20Sopenharmony_ci#endif
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci#if (VXGE_DEBUG_INIT & VXGE_DEBUG_MASK)
4618c2ecf20Sopenharmony_ci#define vxge_debug_init(level, fmt, ...) \
4628c2ecf20Sopenharmony_ci	vxge_debug_ll(level, VXGE_DEBUG_INIT, fmt, ##__VA_ARGS__)
4638c2ecf20Sopenharmony_ci#else
4648c2ecf20Sopenharmony_ci#define vxge_debug_init(level, fmt, ...)
4658c2ecf20Sopenharmony_ci#endif
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ci#if (VXGE_DEBUG_TX & VXGE_DEBUG_MASK)
4688c2ecf20Sopenharmony_ci#define vxge_debug_tx(level, fmt, ...) \
4698c2ecf20Sopenharmony_ci	vxge_debug_ll(level, VXGE_DEBUG_TX, fmt, ##__VA_ARGS__)
4708c2ecf20Sopenharmony_ci#else
4718c2ecf20Sopenharmony_ci#define vxge_debug_tx(level, fmt, ...)
4728c2ecf20Sopenharmony_ci#endif
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci#if (VXGE_DEBUG_RX & VXGE_DEBUG_MASK)
4758c2ecf20Sopenharmony_ci#define vxge_debug_rx(level, fmt, ...) \
4768c2ecf20Sopenharmony_ci	vxge_debug_ll(level, VXGE_DEBUG_RX, fmt, ##__VA_ARGS__)
4778c2ecf20Sopenharmony_ci#else
4788c2ecf20Sopenharmony_ci#define vxge_debug_rx(level, fmt, ...)
4798c2ecf20Sopenharmony_ci#endif
4808c2ecf20Sopenharmony_ci
4818c2ecf20Sopenharmony_ci#if (VXGE_DEBUG_MEM & VXGE_DEBUG_MASK)
4828c2ecf20Sopenharmony_ci#define vxge_debug_mem(level, fmt, ...) \
4838c2ecf20Sopenharmony_ci	vxge_debug_ll(level, VXGE_DEBUG_MEM, fmt, ##__VA_ARGS__)
4848c2ecf20Sopenharmony_ci#else
4858c2ecf20Sopenharmony_ci#define vxge_debug_mem(level, fmt, ...)
4868c2ecf20Sopenharmony_ci#endif
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ci#if (VXGE_DEBUG_ENTRYEXIT & VXGE_DEBUG_MASK)
4898c2ecf20Sopenharmony_ci#define vxge_debug_entryexit(level, fmt, ...) \
4908c2ecf20Sopenharmony_ci	vxge_debug_ll(level, VXGE_DEBUG_ENTRYEXIT, fmt, ##__VA_ARGS__)
4918c2ecf20Sopenharmony_ci#else
4928c2ecf20Sopenharmony_ci#define vxge_debug_entryexit(level, fmt, ...)
4938c2ecf20Sopenharmony_ci#endif
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_ci#if (VXGE_DEBUG_INTR & VXGE_DEBUG_MASK)
4968c2ecf20Sopenharmony_ci#define vxge_debug_intr(level, fmt, ...) \
4978c2ecf20Sopenharmony_ci	vxge_debug_ll(level, VXGE_DEBUG_INTR, fmt, ##__VA_ARGS__)
4988c2ecf20Sopenharmony_ci#else
4998c2ecf20Sopenharmony_ci#define vxge_debug_intr(level, fmt, ...)
5008c2ecf20Sopenharmony_ci#endif
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_ci#define VXGE_DEVICE_DEBUG_LEVEL_SET(level, mask, vdev) {\
5038c2ecf20Sopenharmony_ci	vxge_hw_device_debug_set((struct __vxge_hw_device  *)vdev->devh, \
5048c2ecf20Sopenharmony_ci		level, mask);\
5058c2ecf20Sopenharmony_ci	VXGE_COPY_DEBUG_INFO_TO_LL(vdev, \
5068c2ecf20Sopenharmony_ci		vxge_hw_device_error_level_get((struct __vxge_hw_device  *) \
5078c2ecf20Sopenharmony_ci			vdev->devh), \
5088c2ecf20Sopenharmony_ci		vxge_hw_device_trace_level_get((struct __vxge_hw_device  *) \
5098c2ecf20Sopenharmony_ci			vdev->devh));\
5108c2ecf20Sopenharmony_ci}
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci#ifdef NETIF_F_GSO
5138c2ecf20Sopenharmony_ci#define vxge_tcp_mss(skb) (skb_shinfo(skb)->gso_size)
5148c2ecf20Sopenharmony_ci#define vxge_udp_mss(skb) (skb_shinfo(skb)->gso_size)
5158c2ecf20Sopenharmony_ci#define vxge_offload_type(skb) (skb_shinfo(skb)->gso_type)
5168c2ecf20Sopenharmony_ci#endif
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci#endif
519