152fa7bf9SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2f844a0eaSJeff Kirsher /* 32732ba56SRasesh Mody * Linux network driver for QLogic BR-series Converged Network Adapter. 4f844a0eaSJeff Kirsher */ 5f844a0eaSJeff Kirsher /* 62732ba56SRasesh Mody * Copyright (c) 2005-2014 Brocade Communications Systems, Inc. 72732ba56SRasesh Mody * Copyright (c) 2014-2015 QLogic Corporation 8f844a0eaSJeff Kirsher * All rights reserved 92732ba56SRasesh Mody * www.qlogic.com 10f844a0eaSJeff Kirsher */ 11f844a0eaSJeff Kirsher #ifndef __BNAD_H__ 12f844a0eaSJeff Kirsher #define __BNAD_H__ 13f844a0eaSJeff Kirsher 14f844a0eaSJeff Kirsher #include <linux/rtnetlink.h> 15f844a0eaSJeff Kirsher #include <linux/workqueue.h> 16f844a0eaSJeff Kirsher #include <linux/ipv6.h> 17f844a0eaSJeff Kirsher #include <linux/etherdevice.h> 18f844a0eaSJeff Kirsher #include <linux/mutex.h> 19f844a0eaSJeff Kirsher #include <linux/firmware.h> 20f844a0eaSJeff Kirsher #include <linux/if_vlan.h> 21f844a0eaSJeff Kirsher 22f844a0eaSJeff Kirsher /* Fix for IA64 */ 23f844a0eaSJeff Kirsher #include <asm/checksum.h> 24f844a0eaSJeff Kirsher #include <net/ip6_checksum.h> 25f844a0eaSJeff Kirsher 26f844a0eaSJeff Kirsher #include <net/ip.h> 27f844a0eaSJeff Kirsher #include <net/tcp.h> 28f844a0eaSJeff Kirsher 29f844a0eaSJeff Kirsher #include "bna.h" 30f844a0eaSJeff Kirsher 31f844a0eaSJeff Kirsher #define BNAD_TXQ_DEPTH 2048 32f844a0eaSJeff Kirsher #define BNAD_RXQ_DEPTH 2048 33f844a0eaSJeff Kirsher 34772b5235SRasesh Mody #define BNAD_MAX_TX 1 35f844a0eaSJeff Kirsher #define BNAD_MAX_TXQ_PER_TX 8 /* 8 priority queues */ 36f844a0eaSJeff Kirsher #define BNAD_TXQ_NUM 1 37f844a0eaSJeff Kirsher 38772b5235SRasesh Mody #define BNAD_MAX_RX 1 39772b5235SRasesh Mody #define BNAD_MAX_RXP_PER_RX 16 40078086f3SRasesh Mody #define BNAD_MAX_RXQ_PER_RXP 2 41f844a0eaSJeff Kirsher 42f844a0eaSJeff Kirsher /* 43f844a0eaSJeff Kirsher * Control structure pointed to ccb->ctrl, which 44f844a0eaSJeff Kirsher * determines the NAPI / LRO behavior CCB 45f844a0eaSJeff Kirsher * There is 1:1 corres. between ccb & ctrl 46f844a0eaSJeff Kirsher */ 47f844a0eaSJeff Kirsher struct bnad_rx_ctrl { 48f844a0eaSJeff Kirsher struct bna_ccb *ccb; 492be67144SRasesh Mody struct bnad *bnad; 50f844a0eaSJeff Kirsher unsigned long flags; 51f844a0eaSJeff Kirsher struct napi_struct napi; 52271e8b79SRasesh Mody u64 rx_intr_ctr; 53271e8b79SRasesh Mody u64 rx_poll_ctr; 54271e8b79SRasesh Mody u64 rx_schedule; 55271e8b79SRasesh Mody u64 rx_keep_poll; 56271e8b79SRasesh Mody u64 rx_complete; 57f844a0eaSJeff Kirsher }; 58f844a0eaSJeff Kirsher 59f844a0eaSJeff Kirsher #define BNAD_RXMODE_PROMISC_DEFAULT BNA_RXMODE_PROMISC 60f844a0eaSJeff Kirsher 61f844a0eaSJeff Kirsher /* 62f844a0eaSJeff Kirsher * GLOBAL #defines (CONSTANTS) 63f844a0eaSJeff Kirsher */ 64f844a0eaSJeff Kirsher #define BNAD_NAME "bna" 65f844a0eaSJeff Kirsher #define BNAD_NAME_LEN 64 66f844a0eaSJeff Kirsher 67f844a0eaSJeff Kirsher #define BNAD_MAILBOX_MSIX_INDEX 0 68f844a0eaSJeff Kirsher #define BNAD_MAILBOX_MSIX_VECTORS 1 69f844a0eaSJeff Kirsher #define BNAD_INTX_TX_IB_BITMASK 0x1 70f844a0eaSJeff Kirsher #define BNAD_INTX_RX_IB_BITMASK 0x2 71f844a0eaSJeff Kirsher 72f844a0eaSJeff Kirsher #define BNAD_STATS_TIMER_FREQ 1000 /* in msecs */ 73f844a0eaSJeff Kirsher #define BNAD_DIM_TIMER_FREQ 1000 /* in msecs */ 74f844a0eaSJeff Kirsher 75078086f3SRasesh Mody #define BNAD_IOCETH_TIMEOUT 10000 76078086f3SRasesh Mody 775216562aSRasesh Mody #define BNAD_MIN_Q_DEPTH 512 7866f9513aSRasesh Mody #define BNAD_MAX_RXQ_DEPTH 16384 795216562aSRasesh Mody #define BNAD_MAX_TXQ_DEPTH 2048 8041eb5ba4SRasesh Mody 81f844a0eaSJeff Kirsher #define BNAD_JUMBO_MTU 9000 82f844a0eaSJeff Kirsher 83f844a0eaSJeff Kirsher #define BNAD_NETIF_WAKE_THRESHOLD 8 84f844a0eaSJeff Kirsher 85f844a0eaSJeff Kirsher #define BNAD_RXQ_REFILL_THRESHOLD_SHIFT 3 86f844a0eaSJeff Kirsher 87f844a0eaSJeff Kirsher /* Bit positions for tcb->flags */ 88f844a0eaSJeff Kirsher #define BNAD_TXQ_FREE_SENT 0 89f844a0eaSJeff Kirsher #define BNAD_TXQ_TX_STARTED 1 90f844a0eaSJeff Kirsher 91f844a0eaSJeff Kirsher /* Bit positions for rcb->flags */ 925216562aSRasesh Mody #define BNAD_RXQ_STARTED 0 935216562aSRasesh Mody #define BNAD_RXQ_POST_OK 1 94f844a0eaSJeff Kirsher 95078086f3SRasesh Mody /* Resource limits */ 96078086f3SRasesh Mody #define BNAD_NUM_TXQ (bnad->num_tx * bnad->num_txq_per_tx) 97078086f3SRasesh Mody #define BNAD_NUM_RXP (bnad->num_rx * bnad->num_rxp_per_rx) 98078086f3SRasesh Mody 99e29aa339SRasesh Mody #define BNAD_FRAME_SIZE(_mtu) \ 100e29aa339SRasesh Mody (ETH_HLEN + VLAN_HLEN + (_mtu) + ETH_FCS_LEN) 101e29aa339SRasesh Mody 102f844a0eaSJeff Kirsher /* 103f844a0eaSJeff Kirsher * DATA STRUCTURES 104f844a0eaSJeff Kirsher */ 105f844a0eaSJeff Kirsher 106f844a0eaSJeff Kirsher /* enums */ 107f844a0eaSJeff Kirsher enum bnad_intr_source { 108f844a0eaSJeff Kirsher BNAD_INTR_TX = 1, 109f844a0eaSJeff Kirsher BNAD_INTR_RX = 2 110f844a0eaSJeff Kirsher }; 111f844a0eaSJeff Kirsher 112f844a0eaSJeff Kirsher enum bnad_link_state { 113f844a0eaSJeff Kirsher BNAD_LS_DOWN = 0, 114f844a0eaSJeff Kirsher BNAD_LS_UP = 1 115f844a0eaSJeff Kirsher }; 116f844a0eaSJeff Kirsher 11772a9730bSKrishna Gudipati struct bnad_iocmd_comp { 11872a9730bSKrishna Gudipati struct bnad *bnad; 11972a9730bSKrishna Gudipati struct completion comp; 12072a9730bSKrishna Gudipati int comp_status; 12172a9730bSKrishna Gudipati }; 12272a9730bSKrishna Gudipati 123f844a0eaSJeff Kirsher struct bnad_completion { 124f844a0eaSJeff Kirsher struct completion ioc_comp; 125f844a0eaSJeff Kirsher struct completion ucast_comp; 126f844a0eaSJeff Kirsher struct completion mcast_comp; 127f844a0eaSJeff Kirsher struct completion tx_comp; 128f844a0eaSJeff Kirsher struct completion rx_comp; 129f844a0eaSJeff Kirsher struct completion stats_comp; 130078086f3SRasesh Mody struct completion enet_comp; 131078086f3SRasesh Mody struct completion mtu_comp; 132f844a0eaSJeff Kirsher 133f844a0eaSJeff Kirsher u8 ioc_comp_status; 134f844a0eaSJeff Kirsher u8 ucast_comp_status; 135f844a0eaSJeff Kirsher u8 mcast_comp_status; 136f844a0eaSJeff Kirsher u8 tx_comp_status; 137f844a0eaSJeff Kirsher u8 rx_comp_status; 138f844a0eaSJeff Kirsher u8 stats_comp_status; 139f844a0eaSJeff Kirsher u8 port_comp_status; 140078086f3SRasesh Mody u8 mtu_comp_status; 141f844a0eaSJeff Kirsher }; 142f844a0eaSJeff Kirsher 143f844a0eaSJeff Kirsher /* Tx Rx Control Stats */ 144f844a0eaSJeff Kirsher struct bnad_drv_stats { 145f844a0eaSJeff Kirsher u64 netif_queue_stop; 146f844a0eaSJeff Kirsher u64 netif_queue_wakeup; 147f844a0eaSJeff Kirsher u64 netif_queue_stopped; 148f844a0eaSJeff Kirsher u64 tso4; 149f844a0eaSJeff Kirsher u64 tso6; 150f844a0eaSJeff Kirsher u64 tso_err; 151f844a0eaSJeff Kirsher u64 tcpcsum_offload; 152f844a0eaSJeff Kirsher u64 udpcsum_offload; 153f844a0eaSJeff Kirsher u64 csum_help; 154271e8b79SRasesh Mody u64 tx_skb_too_short; 155271e8b79SRasesh Mody u64 tx_skb_stopping; 156271e8b79SRasesh Mody u64 tx_skb_max_vectors; 157271e8b79SRasesh Mody u64 tx_skb_mss_too_long; 158271e8b79SRasesh Mody u64 tx_skb_tso_too_short; 159271e8b79SRasesh Mody u64 tx_skb_tso_prepare; 160271e8b79SRasesh Mody u64 tx_skb_non_tso_too_long; 161271e8b79SRasesh Mody u64 tx_skb_tcp_hdr; 162271e8b79SRasesh Mody u64 tx_skb_udp_hdr; 163271e8b79SRasesh Mody u64 tx_skb_csum_err; 164271e8b79SRasesh Mody u64 tx_skb_headlen_too_long; 165271e8b79SRasesh Mody u64 tx_skb_headlen_zero; 166271e8b79SRasesh Mody u64 tx_skb_frag_zero; 167271e8b79SRasesh Mody u64 tx_skb_len_mismatch; 168ba5ca784SIvan Vecera u64 tx_skb_map_failed; 169f844a0eaSJeff Kirsher 170f844a0eaSJeff Kirsher u64 hw_stats_updates; 171f844a0eaSJeff Kirsher u64 netif_rx_dropped; 172f844a0eaSJeff Kirsher 173f844a0eaSJeff Kirsher u64 link_toggle; 174078086f3SRasesh Mody u64 cee_toggle; 175f844a0eaSJeff Kirsher 176f844a0eaSJeff Kirsher u64 rxp_info_alloc_failed; 177f844a0eaSJeff Kirsher u64 mbox_intr_disabled; 178f844a0eaSJeff Kirsher u64 mbox_intr_enabled; 179f844a0eaSJeff Kirsher u64 tx_unmap_q_alloc_failed; 180f844a0eaSJeff Kirsher u64 rx_unmap_q_alloc_failed; 181f844a0eaSJeff Kirsher 182f844a0eaSJeff Kirsher u64 rxbuf_alloc_failed; 183ba5ca784SIvan Vecera u64 rxbuf_map_failed; 184f844a0eaSJeff Kirsher }; 185f844a0eaSJeff Kirsher 186f844a0eaSJeff Kirsher /* Complete driver stats */ 187f844a0eaSJeff Kirsher struct bnad_stats { 188f844a0eaSJeff Kirsher struct bnad_drv_stats drv_stats; 189f844a0eaSJeff Kirsher struct bna_stats *bna_stats; 190f844a0eaSJeff Kirsher }; 191f844a0eaSJeff Kirsher 192f844a0eaSJeff Kirsher /* Tx / Rx Resources */ 193f844a0eaSJeff Kirsher struct bnad_tx_res_info { 194f844a0eaSJeff Kirsher struct bna_res_info res_info[BNA_TX_RES_T_MAX]; 195f844a0eaSJeff Kirsher }; 196f844a0eaSJeff Kirsher 197f844a0eaSJeff Kirsher struct bnad_rx_res_info { 198f844a0eaSJeff Kirsher struct bna_res_info res_info[BNA_RX_RES_T_MAX]; 199f844a0eaSJeff Kirsher }; 200f844a0eaSJeff Kirsher 201f844a0eaSJeff Kirsher struct bnad_tx_info { 202f844a0eaSJeff Kirsher struct bna_tx *tx; /* 1:1 between tx_info & tx */ 203f844a0eaSJeff Kirsher struct bna_tcb *tcb[BNAD_MAX_TXQ_PER_TX]; 204078086f3SRasesh Mody u32 tx_id; 20501b54b14SJing Huang struct delayed_work tx_cleanup_work; 206f844a0eaSJeff Kirsher } ____cacheline_aligned; 207f844a0eaSJeff Kirsher 208f844a0eaSJeff Kirsher struct bnad_rx_info { 209f844a0eaSJeff Kirsher struct bna_rx *rx; /* 1:1 between rx_info & rx */ 210f844a0eaSJeff Kirsher 211772b5235SRasesh Mody struct bnad_rx_ctrl rx_ctrl[BNAD_MAX_RXP_PER_RX]; 212078086f3SRasesh Mody u32 rx_id; 21301b54b14SJing Huang struct work_struct rx_cleanup_work; 214f844a0eaSJeff Kirsher } ____cacheline_aligned; 215f844a0eaSJeff Kirsher 2165216562aSRasesh Mody struct bnad_tx_vector { 217f844a0eaSJeff Kirsher DEFINE_DMA_UNMAP_ADDR(dma_addr); 21824f5d33dSRasesh Mody DEFINE_DMA_UNMAP_LEN(dma_len); 219f844a0eaSJeff Kirsher }; 220f844a0eaSJeff Kirsher 2215216562aSRasesh Mody struct bnad_tx_unmap { 2225216562aSRasesh Mody struct sk_buff *skb; 2235216562aSRasesh Mody u32 nvecs; 2245216562aSRasesh Mody struct bnad_tx_vector vectors[BFI_TX_MAX_VECTORS_PER_WI]; 2255216562aSRasesh Mody }; 2265216562aSRasesh Mody 2275216562aSRasesh Mody struct bnad_rx_vector { 2285216562aSRasesh Mody DEFINE_DMA_UNMAP_ADDR(dma_addr); 2295216562aSRasesh Mody u32 len; 2305216562aSRasesh Mody }; 2315216562aSRasesh Mody 2325216562aSRasesh Mody struct bnad_rx_unmap { 23330f9fc94SRasesh Mody struct page *page; 2345216562aSRasesh Mody struct sk_buff *skb; 2355216562aSRasesh Mody struct bnad_rx_vector vector; 23666f9513aSRasesh Mody u32 page_offset; 237f844a0eaSJeff Kirsher }; 238f844a0eaSJeff Kirsher 23930f9fc94SRasesh Mody enum bnad_rxbuf_type { 24030f9fc94SRasesh Mody BNAD_RXBUF_NONE = 0, 241e29aa339SRasesh Mody BNAD_RXBUF_SK_BUFF = 1, 24230f9fc94SRasesh Mody BNAD_RXBUF_PAGE = 2, 243e29aa339SRasesh Mody BNAD_RXBUF_MULTI_BUFF = 3 24430f9fc94SRasesh Mody }; 24530f9fc94SRasesh Mody 246e29aa339SRasesh Mody #define BNAD_RXBUF_IS_SK_BUFF(_type) ((_type) == BNAD_RXBUF_SK_BUFF) 247e29aa339SRasesh Mody #define BNAD_RXBUF_IS_MULTI_BUFF(_type) ((_type) == BNAD_RXBUF_MULTI_BUFF) 24830f9fc94SRasesh Mody 24930f9fc94SRasesh Mody struct bnad_rx_unmap_q { 25030f9fc94SRasesh Mody int reuse_pi; 25130f9fc94SRasesh Mody int alloc_order; 25230f9fc94SRasesh Mody u32 map_size; 25330f9fc94SRasesh Mody enum bnad_rxbuf_type type; 254*8f5c69f9SGustavo A. R. Silva struct bnad_rx_unmap unmap[] ____cacheline_aligned; 25530f9fc94SRasesh Mody }; 25630f9fc94SRasesh Mody 257e29aa339SRasesh Mody #define BNAD_PCI_DEV_IS_CAT2(_bnad) \ 258e29aa339SRasesh Mody ((_bnad)->pcidev->device == BFA_PCI_DEVICE_ID_CT2) 259e29aa339SRasesh Mody 260f844a0eaSJeff Kirsher /* Bit mask values for bnad->cfg_flags */ 261f844a0eaSJeff Kirsher #define BNAD_CF_DIM_ENABLED 0x01 /* DIM */ 262f844a0eaSJeff Kirsher #define BNAD_CF_PROMISC 0x02 263f844a0eaSJeff Kirsher #define BNAD_CF_ALLMULTI 0x04 264fe1624cfSRasesh Mody #define BNAD_CF_DEFAULT 0x08 265fe1624cfSRasesh Mody #define BNAD_CF_MSIX 0x10 /* If in MSIx mode */ 266f844a0eaSJeff Kirsher 267f844a0eaSJeff Kirsher /* Defines for run_flags bit-mask */ 268f844a0eaSJeff Kirsher /* Set, tested & cleared using xxx_bit() functions */ 269f844a0eaSJeff Kirsher /* Values indicated bit positions */ 270078086f3SRasesh Mody #define BNAD_RF_CEE_RUNNING 0 271078086f3SRasesh Mody #define BNAD_RF_MTU_SET 1 272f844a0eaSJeff Kirsher #define BNAD_RF_MBOX_IRQ_DISABLED 2 273078086f3SRasesh Mody #define BNAD_RF_NETDEV_REGISTERED 3 274f844a0eaSJeff Kirsher #define BNAD_RF_DIM_TIMER_RUNNING 4 275f844a0eaSJeff Kirsher #define BNAD_RF_STATS_TIMER_RUNNING 5 276078086f3SRasesh Mody #define BNAD_RF_TX_PRIO_SET 6 277078086f3SRasesh Mody 278f844a0eaSJeff Kirsher struct bnad { 279f844a0eaSJeff Kirsher struct net_device *netdev; 28072a9730bSKrishna Gudipati u32 id; 281f844a0eaSJeff Kirsher 282f844a0eaSJeff Kirsher /* Data path */ 283772b5235SRasesh Mody struct bnad_tx_info tx_info[BNAD_MAX_TX]; 284772b5235SRasesh Mody struct bnad_rx_info rx_info[BNAD_MAX_RX]; 285f844a0eaSJeff Kirsher 286f844a0eaSJeff Kirsher unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 287f844a0eaSJeff Kirsher /* 288f844a0eaSJeff Kirsher * These q numbers are global only because 289f844a0eaSJeff Kirsher * they are used to calculate MSIx vectors. 290f844a0eaSJeff Kirsher * Actually the exact # of queues are per Tx/Rx 291f844a0eaSJeff Kirsher * object. 292f844a0eaSJeff Kirsher */ 293f844a0eaSJeff Kirsher u32 num_tx; 294f844a0eaSJeff Kirsher u32 num_rx; 295f844a0eaSJeff Kirsher u32 num_txq_per_tx; 296f844a0eaSJeff Kirsher u32 num_rxp_per_rx; 297f844a0eaSJeff Kirsher 298f844a0eaSJeff Kirsher u32 txq_depth; 299f844a0eaSJeff Kirsher u32 rxq_depth; 300f844a0eaSJeff Kirsher 301f844a0eaSJeff Kirsher u8 tx_coalescing_timeo; 302f844a0eaSJeff Kirsher u8 rx_coalescing_timeo; 303f844a0eaSJeff Kirsher 3045e46631fSRasesh Mody struct bna_rx_config rx_config[BNAD_MAX_RX] ____cacheline_aligned; 3055e46631fSRasesh Mody struct bna_tx_config tx_config[BNAD_MAX_TX] ____cacheline_aligned; 306f844a0eaSJeff Kirsher 307f844a0eaSJeff Kirsher void __iomem *bar0; /* BAR0 address */ 308f844a0eaSJeff Kirsher 309f844a0eaSJeff Kirsher struct bna bna; 310f844a0eaSJeff Kirsher 311f844a0eaSJeff Kirsher u32 cfg_flags; 312f844a0eaSJeff Kirsher unsigned long run_flags; 313f844a0eaSJeff Kirsher 314f844a0eaSJeff Kirsher struct pci_dev *pcidev; 315f844a0eaSJeff Kirsher u64 mmio_start; 316f844a0eaSJeff Kirsher u64 mmio_len; 317f844a0eaSJeff Kirsher 318f844a0eaSJeff Kirsher u32 msix_num; 319f844a0eaSJeff Kirsher struct msix_entry *msix_table; 320f844a0eaSJeff Kirsher 321f844a0eaSJeff Kirsher struct mutex conf_mutex; 322f844a0eaSJeff Kirsher spinlock_t bna_lock ____cacheline_aligned; 323f844a0eaSJeff Kirsher 324f844a0eaSJeff Kirsher /* Timers */ 325f844a0eaSJeff Kirsher struct timer_list ioc_timer; 326f844a0eaSJeff Kirsher struct timer_list dim_timer; 327f844a0eaSJeff Kirsher struct timer_list stats_timer; 328f844a0eaSJeff Kirsher 329f844a0eaSJeff Kirsher /* Control path resources, memory & irq */ 330f844a0eaSJeff Kirsher struct bna_res_info res_info[BNA_RES_T_MAX]; 331078086f3SRasesh Mody struct bna_res_info mod_res_info[BNA_MOD_RES_T_MAX]; 332772b5235SRasesh Mody struct bnad_tx_res_info tx_res_info[BNAD_MAX_TX]; 333772b5235SRasesh Mody struct bnad_rx_res_info rx_res_info[BNAD_MAX_RX]; 334f844a0eaSJeff Kirsher 335f844a0eaSJeff Kirsher struct bnad_completion bnad_completions; 336f844a0eaSJeff Kirsher 337f844a0eaSJeff Kirsher /* Burnt in MAC address */ 338d6b30598SIvan Vecera u8 perm_addr[ETH_ALEN]; 339f844a0eaSJeff Kirsher 34001b54b14SJing Huang struct workqueue_struct *work_q; 341f844a0eaSJeff Kirsher 342f844a0eaSJeff Kirsher /* Statistics */ 343f844a0eaSJeff Kirsher struct bnad_stats stats; 344f844a0eaSJeff Kirsher 345f844a0eaSJeff Kirsher struct bnad_diag *diag; 346f844a0eaSJeff Kirsher 347f844a0eaSJeff Kirsher char adapter_name[BNAD_NAME_LEN]; 348f844a0eaSJeff Kirsher char port_name[BNAD_NAME_LEN]; 349f844a0eaSJeff Kirsher char mbox_irq_name[BNAD_NAME_LEN]; 35001b54b14SJing Huang char wq_name[BNAD_NAME_LEN]; 3517afc5dbdSKrishna Gudipati 3527afc5dbdSKrishna Gudipati /* debugfs specific data */ 3537afc5dbdSKrishna Gudipati char *regdata; 3547afc5dbdSKrishna Gudipati u32 reglen; 3557afc5dbdSKrishna Gudipati struct dentry *bnad_dentry_files[5]; 3567afc5dbdSKrishna Gudipati struct dentry *port_debugfs_root; 3577afc5dbdSKrishna Gudipati }; 3587afc5dbdSKrishna Gudipati 3597afc5dbdSKrishna Gudipati struct bnad_drvinfo { 3607afc5dbdSKrishna Gudipati struct bfa_ioc_attr ioc_attr; 3617afc5dbdSKrishna Gudipati struct bfa_cee_attr cee_attr; 3627afc5dbdSKrishna Gudipati struct bfa_flash_attr flash_attr; 3637afc5dbdSKrishna Gudipati u32 cee_status; 3647afc5dbdSKrishna Gudipati u32 flash_status; 365f844a0eaSJeff Kirsher }; 366f844a0eaSJeff Kirsher 367f844a0eaSJeff Kirsher /* 368f844a0eaSJeff Kirsher * EXTERN VARIABLES 369f844a0eaSJeff Kirsher */ 370e1e0918fSstephen hemminger extern const struct firmware *bfi_fw; 371f844a0eaSJeff Kirsher 372f844a0eaSJeff Kirsher /* 373f844a0eaSJeff Kirsher * EXTERN PROTOTYPES 374f844a0eaSJeff Kirsher */ 37549ca19bdSJoe Perches u32 *cna_get_firmware_buf(struct pci_dev *pdev); 376f844a0eaSJeff Kirsher /* Netdev entry point prototypes */ 37749ca19bdSJoe Perches void bnad_set_rx_mode(struct net_device *netdev); 37849ca19bdSJoe Perches struct net_device_stats *bnad_get_netdev_stats(struct net_device *netdev); 379558caad7SIvan Vecera int bnad_mac_addr_set_locked(struct bnad *bnad, const u8 *mac_addr); 38049ca19bdSJoe Perches int bnad_enable_default_bcast(struct bnad *bnad); 38149ca19bdSJoe Perches void bnad_restore_vlans(struct bnad *bnad, u32 rx_id); 38249ca19bdSJoe Perches void bnad_set_ethtool_ops(struct net_device *netdev); 38349ca19bdSJoe Perches void bnad_cb_completion(void *arg, enum bfa_status status); 384f844a0eaSJeff Kirsher 385f844a0eaSJeff Kirsher /* Configuration & setup */ 38649ca19bdSJoe Perches void bnad_tx_coalescing_timeo_set(struct bnad *bnad); 38749ca19bdSJoe Perches void bnad_rx_coalescing_timeo_set(struct bnad *bnad); 388f844a0eaSJeff Kirsher 38949ca19bdSJoe Perches int bnad_setup_rx(struct bnad *bnad, u32 rx_id); 39049ca19bdSJoe Perches int bnad_setup_tx(struct bnad *bnad, u32 tx_id); 39149ca19bdSJoe Perches void bnad_destroy_tx(struct bnad *bnad, u32 tx_id); 39249ca19bdSJoe Perches void bnad_destroy_rx(struct bnad *bnad, u32 rx_id); 393f844a0eaSJeff Kirsher 394f844a0eaSJeff Kirsher /* Timer start/stop protos */ 39549ca19bdSJoe Perches void bnad_dim_timer_start(struct bnad *bnad); 396f844a0eaSJeff Kirsher 397f844a0eaSJeff Kirsher /* Statistics */ 39849ca19bdSJoe Perches void bnad_netdev_qstats_fill(struct bnad *bnad, 399f844a0eaSJeff Kirsher struct rtnl_link_stats64 *stats); 40049ca19bdSJoe Perches void bnad_netdev_hwstats_fill(struct bnad *bnad, 401f844a0eaSJeff Kirsher struct rtnl_link_stats64 *stats); 402f844a0eaSJeff Kirsher 4037afc5dbdSKrishna Gudipati /* Debugfs */ 4047afc5dbdSKrishna Gudipati void bnad_debugfs_init(struct bnad *bnad); 4057afc5dbdSKrishna Gudipati void bnad_debugfs_uninit(struct bnad *bnad); 4067afc5dbdSKrishna Gudipati 4071aa8b471SBen Hutchings /* MACROS */ 408f844a0eaSJeff Kirsher /* To set & get the stats counters */ 409f844a0eaSJeff Kirsher #define BNAD_UPDATE_CTR(_bnad, _ctr) \ 410f844a0eaSJeff Kirsher (((_bnad)->stats.drv_stats._ctr)++) 411f844a0eaSJeff Kirsher 412f844a0eaSJeff Kirsher #define BNAD_GET_CTR(_bnad, _ctr) ((_bnad)->stats.drv_stats._ctr) 413f844a0eaSJeff Kirsher 414f844a0eaSJeff Kirsher #define bnad_enable_rx_irq_unsafe(_ccb) \ 415f844a0eaSJeff Kirsher { \ 416271e8b79SRasesh Mody if (likely(test_bit(BNAD_RXQ_STARTED, &(_ccb)->rcb[0]->flags))) {\ 417f844a0eaSJeff Kirsher bna_ib_coalescing_timer_set((_ccb)->i_dbell, \ 418f844a0eaSJeff Kirsher (_ccb)->rx_coalescing_timeo); \ 419f844a0eaSJeff Kirsher bna_ib_ack((_ccb)->i_dbell, 0); \ 420f844a0eaSJeff Kirsher } \ 421f844a0eaSJeff Kirsher } 422f844a0eaSJeff Kirsher 423f844a0eaSJeff Kirsher #endif /* __BNAD_H__ */ 424