1*493d26c5SEd Maste /* 2*493d26c5SEd Maste * aQuantia Corporation Network Driver 3*493d26c5SEd Maste * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved 4*493d26c5SEd Maste * 5*493d26c5SEd Maste * Redistribution and use in source and binary forms, with or without 6*493d26c5SEd Maste * modification, are permitted provided that the following conditions 7*493d26c5SEd Maste * are met: 8*493d26c5SEd Maste * 9*493d26c5SEd Maste * (1) Redistributions of source code must retain the above 10*493d26c5SEd Maste * copyright notice, this list of conditions and the following 11*493d26c5SEd Maste * disclaimer. 12*493d26c5SEd Maste * 13*493d26c5SEd Maste * (2) Redistributions in binary form must reproduce the above 14*493d26c5SEd Maste * copyright notice, this list of conditions and the following 15*493d26c5SEd Maste * disclaimer in the documentation and/or other materials provided 16*493d26c5SEd Maste * with the distribution. 17*493d26c5SEd Maste * 18*493d26c5SEd Maste * (3)The name of the author may not be used to endorse or promote 19*493d26c5SEd Maste * products derived from this software without specific prior 20*493d26c5SEd Maste * written permission. 21*493d26c5SEd Maste * 22*493d26c5SEd Maste * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 23*493d26c5SEd Maste * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24*493d26c5SEd Maste * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25*493d26c5SEd Maste * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 26*493d26c5SEd Maste * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27*493d26c5SEd Maste * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 28*493d26c5SEd Maste * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29*493d26c5SEd Maste * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30*493d26c5SEd Maste * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31*493d26c5SEd Maste * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32*493d26c5SEd Maste * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33*493d26c5SEd Maste */ 34*493d26c5SEd Maste 35*493d26c5SEd Maste #ifndef _AQ_DEVICE_H_ 36*493d26c5SEd Maste #define _AQ_DEVICE_H_ 37*493d26c5SEd Maste 38*493d26c5SEd Maste #include "aq_hw.h" 39*493d26c5SEd Maste 40*493d26c5SEd Maste enum aq_media_type { 41*493d26c5SEd Maste AQ_MEDIA_TYPE_UNKNOWN = 0, 42*493d26c5SEd Maste AQ_MEDIA_TYPE_FIBRE, 43*493d26c5SEd Maste AQ_MEDIA_TYPE_TP, 44*493d26c5SEd Maste }; 45*493d26c5SEd Maste 46*493d26c5SEd Maste #define AQ_LINK_UNKNOWN 0x00000000 47*493d26c5SEd Maste #define AQ_LINK_100M 0x00000001 48*493d26c5SEd Maste #define AQ_LINK_1G 0x00000002 49*493d26c5SEd Maste #define AQ_LINK_2G5 0x00000004 50*493d26c5SEd Maste #define AQ_LINK_5G 0x00000008 51*493d26c5SEd Maste #define AQ_LINK_10G 0x00000010 52*493d26c5SEd Maste 53*493d26c5SEd Maste #define AQ_LINK_ALL (AQ_LINK_100M | AQ_LINK_1G | AQ_LINK_2G5 | AQ_LINK_5G | \ 54*493d26c5SEd Maste AQ_LINK_10G ) 55*493d26c5SEd Maste 56*493d26c5SEd Maste struct aq_stats_s { 57*493d26c5SEd Maste u64 prc; 58*493d26c5SEd Maste u64 uprc; 59*493d26c5SEd Maste u64 mprc; 60*493d26c5SEd Maste u64 bprc; 61*493d26c5SEd Maste u64 cprc; 62*493d26c5SEd Maste u64 erpr; 63*493d26c5SEd Maste u64 dpc; 64*493d26c5SEd Maste u64 brc; 65*493d26c5SEd Maste u64 ubrc; 66*493d26c5SEd Maste u64 mbrc; 67*493d26c5SEd Maste u64 bbrc; 68*493d26c5SEd Maste 69*493d26c5SEd Maste u64 ptc; 70*493d26c5SEd Maste u64 uptc; 71*493d26c5SEd Maste u64 mptc; 72*493d26c5SEd Maste u64 bptc; 73*493d26c5SEd Maste u64 erpt; 74*493d26c5SEd Maste u64 btc; 75*493d26c5SEd Maste u64 ubtc; 76*493d26c5SEd Maste u64 mbtc; 77*493d26c5SEd Maste u64 bbtc; 78*493d26c5SEd Maste }; 79*493d26c5SEd Maste 80*493d26c5SEd Maste enum aq_dev_state_e { 81*493d26c5SEd Maste AQ_DEV_STATE_UNLOAD, 82*493d26c5SEd Maste AQ_DEV_STATE_PCI_STOP, 83*493d26c5SEd Maste AQ_DEV_STATE_DOWN, 84*493d26c5SEd Maste AQ_DEV_STATE_UP, 85*493d26c5SEd Maste }; 86*493d26c5SEd Maste 87*493d26c5SEd Maste struct aq_rx_filters { 88*493d26c5SEd Maste unsigned int rule_cnt; 89*493d26c5SEd Maste struct aq_rx_filter_vlan vlan_filters[AQ_HW_VLAN_MAX_FILTERS]; 90*493d26c5SEd Maste struct aq_rx_filter_l2 etype_filters[AQ_HW_ETYPE_MAX_FILTERS]; 91*493d26c5SEd Maste }; 92*493d26c5SEd Maste 93*493d26c5SEd Maste struct aq_vlan_tag { 94*493d26c5SEd Maste SLIST_ENTRY(aq_vlan_tag) next; 95*493d26c5SEd Maste uint16_t tag; 96*493d26c5SEd Maste }; 97*493d26c5SEd Maste 98*493d26c5SEd Maste struct aq_dev { 99*493d26c5SEd Maste device_t dev; 100*493d26c5SEd Maste if_ctx_t ctx; 101*493d26c5SEd Maste if_softc_ctx_t scctx; 102*493d26c5SEd Maste if_shared_ctx_t sctx; 103*493d26c5SEd Maste struct ifmedia * media; 104*493d26c5SEd Maste 105*493d26c5SEd Maste struct aq_hw hw; 106*493d26c5SEd Maste 107*493d26c5SEd Maste enum aq_media_type media_type; 108*493d26c5SEd Maste uint32_t link_speeds; 109*493d26c5SEd Maste uint32_t chip_features; 110*493d26c5SEd Maste uint32_t mbox_addr; 111*493d26c5SEd Maste uint8_t mac_addr[ETHER_ADDR_LEN]; 112*493d26c5SEd Maste uint64_t admin_ticks; 113*493d26c5SEd Maste struct if_irq irq; 114*493d26c5SEd Maste int msix; 115*493d26c5SEd Maste 116*493d26c5SEd Maste int mmio_rid; 117*493d26c5SEd Maste struct resource * mmio_res; 118*493d26c5SEd Maste bus_space_tag_t mmio_tag; 119*493d26c5SEd Maste bus_space_handle_t mmio_handle; 120*493d26c5SEd Maste bus_size_t mmio_size; 121*493d26c5SEd Maste 122*493d26c5SEd Maste struct aq_ring *tx_rings[HW_ATL_B0_RINGS_MAX]; 123*493d26c5SEd Maste struct aq_ring *rx_rings[HW_ATL_B0_RINGS_MAX]; 124*493d26c5SEd Maste uint32_t tx_rings_count; 125*493d26c5SEd Maste uint32_t rx_rings_count; 126*493d26c5SEd Maste bool linkup; 127*493d26c5SEd Maste int media_active; 128*493d26c5SEd Maste 129*493d26c5SEd Maste struct aq_hw_stats_s last_stats; 130*493d26c5SEd Maste struct aq_stats_s curr_stats; 131*493d26c5SEd Maste 132*493d26c5SEd Maste bitstr_t *vlan_tags; 133*493d26c5SEd Maste int mcnt; 134*493d26c5SEd Maste 135*493d26c5SEd Maste uint8_t rss_key[HW_ATL_RSS_HASHKEY_SIZE]; 136*493d26c5SEd Maste uint8_t rss_table[HW_ATL_RSS_INDIRECTION_TABLE_MAX]; 137*493d26c5SEd Maste }; 138*493d26c5SEd Maste 139*493d26c5SEd Maste typedef struct aq_dev aq_dev_t; 140*493d26c5SEd Maste 141*493d26c5SEd Maste int aq_update_hw_stats(aq_dev_t *aq_dev); 142*493d26c5SEd Maste void aq_initmedia(aq_dev_t *aq_dev); 143*493d26c5SEd Maste int aq_linkstat_isr(void *arg); 144*493d26c5SEd Maste int aq_isr_rx(void *arg); 145*493d26c5SEd Maste void aq_mediastatus_update(aq_dev_t *aq_dev, u32 link_speed, const struct aq_hw_fc_info *fc_neg); 146*493d26c5SEd Maste void aq_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr); 147*493d26c5SEd Maste int aq_mediachange(struct ifnet *ifp); 148*493d26c5SEd Maste void aq_if_update_admin_status(if_ctx_t ctx); 149*493d26c5SEd Maste 150*493d26c5SEd Maste #endif 151