12f345d8eSLuigi Rizzo /*-
27282444bSPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause
37282444bSPedro F. Giffuni *
4291a1934SXin LI * Copyright (C) 2013 Emulex
52f345d8eSLuigi Rizzo * All rights reserved.
62f345d8eSLuigi Rizzo *
72f345d8eSLuigi Rizzo * Redistribution and use in source and binary forms, with or without
82f345d8eSLuigi Rizzo * modification, are permitted provided that the following conditions are met:
92f345d8eSLuigi Rizzo *
102f345d8eSLuigi Rizzo * 1. Redistributions of source code must retain the above copyright notice,
112f345d8eSLuigi Rizzo * this list of conditions and the following disclaimer.
122f345d8eSLuigi Rizzo *
132f345d8eSLuigi Rizzo * 2. Redistributions in binary form must reproduce the above copyright
142f345d8eSLuigi Rizzo * notice, this list of conditions and the following disclaimer in the
152f345d8eSLuigi Rizzo * documentation and/or other materials provided with the distribution.
162f345d8eSLuigi Rizzo *
172f345d8eSLuigi Rizzo * 3. Neither the name of the Emulex Corporation nor the names of its
182f345d8eSLuigi Rizzo * contributors may be used to endorse or promote products derived from
192f345d8eSLuigi Rizzo * this software without specific prior written permission.
202f345d8eSLuigi Rizzo *
212f345d8eSLuigi Rizzo * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
222f345d8eSLuigi Rizzo * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
232f345d8eSLuigi Rizzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
242f345d8eSLuigi Rizzo * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
252f345d8eSLuigi Rizzo * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
262f345d8eSLuigi Rizzo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
272f345d8eSLuigi Rizzo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
282f345d8eSLuigi Rizzo * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
292f345d8eSLuigi Rizzo * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
302f345d8eSLuigi Rizzo * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
312f345d8eSLuigi Rizzo * POSSIBILITY OF SUCH DAMAGE.
322f345d8eSLuigi Rizzo *
332f345d8eSLuigi Rizzo * Contact Information:
342f345d8eSLuigi Rizzo * freebsd-drivers@emulex.com
352f345d8eSLuigi Rizzo *
362f345d8eSLuigi Rizzo * Emulex
372f345d8eSLuigi Rizzo * 3333 Susan Street
382f345d8eSLuigi Rizzo * Costa Mesa, CA 92626
392f345d8eSLuigi Rizzo */
402f345d8eSLuigi Rizzo
412f345d8eSLuigi Rizzo
422f345d8eSLuigi Rizzo #include <sys/param.h>
432f345d8eSLuigi Rizzo #include <sys/endian.h>
44e363f832SMichael Tuexen #include <sys/epoch.h>
45c3322cb9SGleb Smirnoff #include <sys/eventhandler.h>
468ec07310SGleb Smirnoff #include <sys/malloc.h>
472f345d8eSLuigi Rizzo #include <sys/module.h>
482f345d8eSLuigi Rizzo #include <sys/kernel.h>
492f345d8eSLuigi Rizzo #include <sys/bus.h>
502f345d8eSLuigi Rizzo #include <sys/mbuf.h>
51c76ddeebSMark Johnston #include <sys/priv.h>
522f345d8eSLuigi Rizzo #include <sys/rman.h>
532f345d8eSLuigi Rizzo #include <sys/socket.h>
542f345d8eSLuigi Rizzo #include <sys/sockio.h>
552f345d8eSLuigi Rizzo #include <sys/sockopt.h>
562f345d8eSLuigi Rizzo #include <sys/queue.h>
572f345d8eSLuigi Rizzo #include <sys/taskqueue.h>
582f345d8eSLuigi Rizzo #include <sys/lock.h>
592f345d8eSLuigi Rizzo #include <sys/mutex.h>
602f345d8eSLuigi Rizzo #include <sys/sysctl.h>
612f345d8eSLuigi Rizzo #include <sys/random.h>
622f345d8eSLuigi Rizzo #include <sys/firmware.h>
632f345d8eSLuigi Rizzo #include <sys/systm.h>
642f345d8eSLuigi Rizzo #include <sys/proc.h>
652f345d8eSLuigi Rizzo
662f345d8eSLuigi Rizzo #include <dev/pci/pcireg.h>
672f345d8eSLuigi Rizzo #include <dev/pci/pcivar.h>
682f345d8eSLuigi Rizzo
692f345d8eSLuigi Rizzo #include <net/bpf.h>
702f345d8eSLuigi Rizzo #include <net/ethernet.h>
712f345d8eSLuigi Rizzo #include <net/if.h>
7276039bc8SGleb Smirnoff #include <net/if_var.h>
732f345d8eSLuigi Rizzo #include <net/if_types.h>
742f345d8eSLuigi Rizzo #include <net/if_media.h>
752f345d8eSLuigi Rizzo #include <net/if_vlan_var.h>
762f345d8eSLuigi Rizzo #include <net/if_dl.h>
772f345d8eSLuigi Rizzo
782f345d8eSLuigi Rizzo #include <netinet/in.h>
792f345d8eSLuigi Rizzo #include <netinet/in_systm.h>
802f345d8eSLuigi Rizzo #include <netinet/in_var.h>
812f345d8eSLuigi Rizzo #include <netinet/if_ether.h>
822f345d8eSLuigi Rizzo #include <netinet/ip.h>
832f345d8eSLuigi Rizzo #include <netinet/ip6.h>
842f345d8eSLuigi Rizzo #include <netinet6/in6_var.h>
852f345d8eSLuigi Rizzo #include <netinet6/ip6_mroute.h>
862f345d8eSLuigi Rizzo
872f345d8eSLuigi Rizzo #include <netinet/udp.h>
882f345d8eSLuigi Rizzo #include <netinet/tcp.h>
892f345d8eSLuigi Rizzo #include <netinet/sctp.h>
902f345d8eSLuigi Rizzo #include <netinet/tcp_lro.h>
91c2625e6eSJosh Paetzel #include <netinet/icmp6.h>
922f345d8eSLuigi Rizzo
932f345d8eSLuigi Rizzo #include <machine/bus.h>
942f345d8eSLuigi Rizzo
952f345d8eSLuigi Rizzo #include "oce_hw.h"
962f345d8eSLuigi Rizzo
975fbb6830SXin LI /* OCE device driver module component revision informaiton */
98c2625e6eSJosh Paetzel #define COMPONENT_REVISION "11.0.50.0"
992f345d8eSLuigi Rizzo
1002f345d8eSLuigi Rizzo /* OCE devices supported by this driver */
1012f345d8eSLuigi Rizzo #define PCI_VENDOR_EMULEX 0x10df /* Emulex */
1022f345d8eSLuigi Rizzo #define PCI_VENDOR_SERVERENGINES 0x19a2 /* ServerEngines (BE) */
1032f345d8eSLuigi Rizzo #define PCI_PRODUCT_BE2 0x0700 /* BE2 network adapter */
1042f345d8eSLuigi Rizzo #define PCI_PRODUCT_BE3 0x0710 /* BE3 network adapter */
1052f345d8eSLuigi Rizzo #define PCI_PRODUCT_XE201 0xe220 /* XE201 network adapter */
1062f345d8eSLuigi Rizzo #define PCI_PRODUCT_XE201_VF 0xe228 /* XE201 with VF in Lancer */
107291a1934SXin LI #define PCI_PRODUCT_SH 0x0720 /* Skyhawk network adapter */
1082f345d8eSLuigi Rizzo
1092f345d8eSLuigi Rizzo #define IS_BE(sc) (((sc->flags & OCE_FLAGS_BE3) | \
1102f345d8eSLuigi Rizzo (sc->flags & OCE_FLAGS_BE2))? 1:0)
111291a1934SXin LI #define IS_BE3(sc) (sc->flags & OCE_FLAGS_BE3)
112291a1934SXin LI #define IS_BE2(sc) (sc->flags & OCE_FLAGS_BE2)
1132f345d8eSLuigi Rizzo #define IS_XE201(sc) ((sc->flags & OCE_FLAGS_XE201) ? 1:0)
1142f345d8eSLuigi Rizzo #define HAS_A0_CHIP(sc) ((sc->flags & OCE_FLAGS_HAS_A0_CHIP) ? 1:0)
115291a1934SXin LI #define IS_SH(sc) ((sc->flags & OCE_FLAGS_SH) ? 1 : 0)
116291a1934SXin LI
117291a1934SXin LI #define is_be_mode_mc(sc) ((sc->function_mode & FNM_FLEX10_MODE) || \
118291a1934SXin LI (sc->function_mode & FNM_UMC_MODE) || \
119291a1934SXin LI (sc->function_mode & FNM_VNIC_MODE))
120291a1934SXin LI #define OCE_FUNCTION_CAPS_SUPER_NIC 0x40
121291a1934SXin LI #define IS_PROFILE_SUPER_NIC(sc) (sc->function_caps & OCE_FUNCTION_CAPS_SUPER_NIC)
1222f345d8eSLuigi Rizzo
1232f345d8eSLuigi Rizzo /* proportion Service Level Interface queues */
1242f345d8eSLuigi Rizzo #define OCE_MAX_UNITS 2
1252f345d8eSLuigi Rizzo #define OCE_MAX_PPORT OCE_MAX_UNITS
1262f345d8eSLuigi Rizzo #define OCE_MAX_VPORT OCE_MAX_UNITS
1272f345d8eSLuigi Rizzo
1282f345d8eSLuigi Rizzo extern int mp_ncpus; /* system's total active cpu cores */
1292f345d8eSLuigi Rizzo #define OCE_NCPUS mp_ncpus
1309bd3250aSLuigi Rizzo
1319bd3250aSLuigi Rizzo /* This should be powers of 2. Like 2,4,8 & 16 */
132291a1934SXin LI #define OCE_MAX_RSS 8
1332f345d8eSLuigi Rizzo #define OCE_LEGACY_MODE_RSS 4 /* For BE3 Legacy mode*/
134291a1934SXin LI #define is_rss_enabled(sc) ((sc->function_caps & FNC_RSS) && !is_be_mode_mc(sc))
1352f345d8eSLuigi Rizzo
1362f345d8eSLuigi Rizzo #define OCE_MIN_RQ 1
1372f345d8eSLuigi Rizzo #define OCE_MIN_WQ 1
1382f345d8eSLuigi Rizzo
1392f345d8eSLuigi Rizzo #define OCE_MAX_RQ OCE_MAX_RSS + 1 /* one default queue */
1402f345d8eSLuigi Rizzo #define OCE_MAX_WQ 8
1412f345d8eSLuigi Rizzo
1422f345d8eSLuigi Rizzo #define OCE_MAX_EQ 32
1432f345d8eSLuigi Rizzo #define OCE_MAX_CQ OCE_MAX_RQ + OCE_MAX_WQ + 1 /* one MCC queue */
1442f345d8eSLuigi Rizzo #define OCE_MAX_CQ_EQ 8 /* Max CQ that can attached to an EQ */
1452f345d8eSLuigi Rizzo
1462f345d8eSLuigi Rizzo #define OCE_DEFAULT_WQ_EQD 16
1472f345d8eSLuigi Rizzo #define OCE_MAX_PACKET_Q 16
1482f345d8eSLuigi Rizzo #define OCE_LSO_MAX_SIZE (64 * 1024)
1492f345d8eSLuigi Rizzo #define LONG_TIMEOUT 30
150cdaba892SXin LI #define OCE_MAX_JUMBO_FRAME_SIZE 9018
1512f345d8eSLuigi Rizzo #define OCE_MAX_MTU (OCE_MAX_JUMBO_FRAME_SIZE - \
1522f345d8eSLuigi Rizzo ETHER_VLAN_ENCAP_LEN - \
1532f345d8eSLuigi Rizzo ETHER_HDR_LEN)
1542f345d8eSLuigi Rizzo
155c2625e6eSJosh Paetzel #define OCE_RDMA_VECTORS 2
156c2625e6eSJosh Paetzel
1572f345d8eSLuigi Rizzo #define OCE_MAX_TX_ELEMENTS 29
1582f345d8eSLuigi Rizzo #define OCE_MAX_TX_DESC 1024
1592f345d8eSLuigi Rizzo #define OCE_MAX_TX_SIZE 65535
160c2625e6eSJosh Paetzel #define OCE_MAX_TSO_SIZE (65535 - ETHER_HDR_LEN)
1612f345d8eSLuigi Rizzo #define OCE_MAX_RX_SIZE 4096
1622f345d8eSLuigi Rizzo #define OCE_MAX_RQ_POSTS 255
163c2625e6eSJosh Paetzel #define OCE_HWLRO_MAX_RQ_POSTS 64
1642f345d8eSLuigi Rizzo #define OCE_DEFAULT_PROMISCUOUS 0
1652f345d8eSLuigi Rizzo
1662f345d8eSLuigi Rizzo #define RSS_ENABLE_IPV4 0x1
1672f345d8eSLuigi Rizzo #define RSS_ENABLE_TCP_IPV4 0x2
1682f345d8eSLuigi Rizzo #define RSS_ENABLE_IPV6 0x4
1692f345d8eSLuigi Rizzo #define RSS_ENABLE_TCP_IPV6 0x8
1702f345d8eSLuigi Rizzo
171291a1934SXin LI #define INDIRECTION_TABLE_ENTRIES 128
1722f345d8eSLuigi Rizzo
1732f345d8eSLuigi Rizzo /* flow control definitions */
1742f345d8eSLuigi Rizzo #define OCE_FC_NONE 0x00000000
1752f345d8eSLuigi Rizzo #define OCE_FC_TX 0x00000001
1762f345d8eSLuigi Rizzo #define OCE_FC_RX 0x00000002
1772f345d8eSLuigi Rizzo #define OCE_DEFAULT_FLOW_CONTROL (OCE_FC_TX | OCE_FC_RX)
1782f345d8eSLuigi Rizzo
1792f345d8eSLuigi Rizzo /* Interface capabilities to give device when creating interface */
1802f345d8eSLuigi Rizzo #define OCE_CAPAB_FLAGS (MBX_RX_IFACE_FLAGS_BROADCAST | \
1812f345d8eSLuigi Rizzo MBX_RX_IFACE_FLAGS_UNTAGGED | \
1822f345d8eSLuigi Rizzo MBX_RX_IFACE_FLAGS_PROMISCUOUS | \
1835fbb6830SXin LI MBX_RX_IFACE_FLAGS_VLAN_PROMISCUOUS | \
1842f345d8eSLuigi Rizzo MBX_RX_IFACE_FLAGS_MCAST_PROMISCUOUS | \
1852f345d8eSLuigi Rizzo MBX_RX_IFACE_FLAGS_RSS | \
1862f345d8eSLuigi Rizzo MBX_RX_IFACE_FLAGS_PASS_L3L4_ERR)
1872f345d8eSLuigi Rizzo
1882f345d8eSLuigi Rizzo /* Interface capabilities to enable by default (others set dynamically) */
1892f345d8eSLuigi Rizzo #define OCE_CAPAB_ENABLE (MBX_RX_IFACE_FLAGS_BROADCAST | \
1902f345d8eSLuigi Rizzo MBX_RX_IFACE_FLAGS_UNTAGGED | \
1912f345d8eSLuigi Rizzo MBX_RX_IFACE_FLAGS_PASS_L3L4_ERR)
1922f345d8eSLuigi Rizzo
1932f345d8eSLuigi Rizzo #define OCE_IF_HWASSIST (CSUM_IP | CSUM_TCP | CSUM_UDP)
1942f345d8eSLuigi Rizzo #define OCE_IF_CAPABILITIES (IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING | \
1952f345d8eSLuigi Rizzo IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | \
1969bd3250aSLuigi Rizzo IFCAP_JUMBO_MTU | IFCAP_VLAN_MTU)
1972f345d8eSLuigi Rizzo #define OCE_IF_HWASSIST_NONE 0
1982f345d8eSLuigi Rizzo #define OCE_IF_CAPABILITIES_NONE 0
1992f345d8eSLuigi Rizzo
2002f345d8eSLuigi Rizzo #define MAX_VLANFILTER_SIZE 64
2012f345d8eSLuigi Rizzo #define MAX_VLANS 4096
2022f345d8eSLuigi Rizzo
2032f345d8eSLuigi Rizzo #define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16))
2042f345d8eSLuigi Rizzo #define BSWAP_8(x) ((x) & 0xff)
2052f345d8eSLuigi Rizzo #define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8))
2062f345d8eSLuigi Rizzo #define BSWAP_32(x) ((BSWAP_16(x) << 16) | \
2072f345d8eSLuigi Rizzo BSWAP_16((x) >> 16))
2082f345d8eSLuigi Rizzo #define BSWAP_64(x) ((BSWAP_32(x) << 32) | \
2092f345d8eSLuigi Rizzo BSWAP_32((x) >> 32))
2102f345d8eSLuigi Rizzo
2112f345d8eSLuigi Rizzo #define for_all_wq_queues(sc, wq, i) \
2122f345d8eSLuigi Rizzo for (i = 0, wq = sc->wq[0]; i < sc->nwqs; i++, wq = sc->wq[i])
2132f345d8eSLuigi Rizzo #define for_all_rq_queues(sc, rq, i) \
2142f345d8eSLuigi Rizzo for (i = 0, rq = sc->rq[0]; i < sc->nrqs; i++, rq = sc->rq[i])
215291a1934SXin LI #define for_all_rss_queues(sc, rq, i) \
216291a1934SXin LI for (i = 0, rq = sc->rq[i + 1]; i < (sc->nrqs - 1); \
217291a1934SXin LI i++, rq = sc->rq[i + 1])
2182f345d8eSLuigi Rizzo #define for_all_evnt_queues(sc, eq, i) \
2192f345d8eSLuigi Rizzo for (i = 0, eq = sc->eq[0]; i < sc->neqs; i++, eq = sc->eq[i])
2202f345d8eSLuigi Rizzo #define for_all_cq_queues(sc, cq, i) \
2212f345d8eSLuigi Rizzo for (i = 0, cq = sc->cq[0]; i < sc->ncqs; i++, cq = sc->cq[i])
2222f345d8eSLuigi Rizzo
2232f345d8eSLuigi Rizzo /* Flash specific */
2242f345d8eSLuigi Rizzo #define IOCTL_COOKIE "SERVERENGINES CORP"
2252f345d8eSLuigi Rizzo #define MAX_FLASH_COMP 32
2262f345d8eSLuigi Rizzo
2272f345d8eSLuigi Rizzo #define IMG_ISCSI 160
2282f345d8eSLuigi Rizzo #define IMG_REDBOOT 224
2292f345d8eSLuigi Rizzo #define IMG_BIOS 34
2302f345d8eSLuigi Rizzo #define IMG_PXEBIOS 32
2312f345d8eSLuigi Rizzo #define IMG_FCOEBIOS 33
2322f345d8eSLuigi Rizzo #define IMG_ISCSI_BAK 176
2332f345d8eSLuigi Rizzo #define IMG_FCOE 162
2342f345d8eSLuigi Rizzo #define IMG_FCOE_BAK 178
2352f345d8eSLuigi Rizzo #define IMG_NCSI 16
2362f345d8eSLuigi Rizzo #define IMG_PHY 192
2372f345d8eSLuigi Rizzo #define FLASHROM_OPER_FLASH 1
2382f345d8eSLuigi Rizzo #define FLASHROM_OPER_SAVE 2
2392f345d8eSLuigi Rizzo #define FLASHROM_OPER_REPORT 4
2402f345d8eSLuigi Rizzo #define FLASHROM_OPER_FLASH_PHY 9
2412f345d8eSLuigi Rizzo #define FLASHROM_OPER_SAVE_PHY 10
2422f345d8eSLuigi Rizzo #define TN_8022 13
2432f345d8eSLuigi Rizzo
2442f345d8eSLuigi Rizzo enum {
2452f345d8eSLuigi Rizzo PHY_TYPE_CX4_10GB = 0,
2462f345d8eSLuigi Rizzo PHY_TYPE_XFP_10GB,
2472f345d8eSLuigi Rizzo PHY_TYPE_SFP_1GB,
2482f345d8eSLuigi Rizzo PHY_TYPE_SFP_PLUS_10GB,
2492f345d8eSLuigi Rizzo PHY_TYPE_KR_10GB,
2502f345d8eSLuigi Rizzo PHY_TYPE_KX4_10GB,
2512f345d8eSLuigi Rizzo PHY_TYPE_BASET_10GB,
2522f345d8eSLuigi Rizzo PHY_TYPE_BASET_1GB,
2532f345d8eSLuigi Rizzo PHY_TYPE_BASEX_1GB,
2542f345d8eSLuigi Rizzo PHY_TYPE_SGMII,
2552f345d8eSLuigi Rizzo PHY_TYPE_DISABLED = 255
2562f345d8eSLuigi Rizzo };
2572f345d8eSLuigi Rizzo
2582f345d8eSLuigi Rizzo /**
2592f345d8eSLuigi Rizzo * @brief Define and hold all necessary info for a single interrupt
2602f345d8eSLuigi Rizzo */
2612f345d8eSLuigi Rizzo #define OCE_MAX_MSI 32 /* Message Signaled Interrupts */
2622f345d8eSLuigi Rizzo #define OCE_MAX_MSIX 2048 /* PCI Express MSI Interrrupts */
2632f345d8eSLuigi Rizzo
2642f345d8eSLuigi Rizzo typedef struct oce_intr_info {
2652f345d8eSLuigi Rizzo void *tag; /* cookie returned by bus_setup_intr */
2662f345d8eSLuigi Rizzo struct resource *intr_res; /* PCI resource container */
2672f345d8eSLuigi Rizzo int irq_rr; /* resource id for the interrupt */
2682f345d8eSLuigi Rizzo struct oce_softc *sc; /* pointer to the parent soft c */
2692f345d8eSLuigi Rizzo struct oce_eq *eq; /* pointer to the connected EQ */
2702f345d8eSLuigi Rizzo struct taskqueue *tq; /* Associated task queue */
2712f345d8eSLuigi Rizzo struct task task; /* task queue task */
2722f345d8eSLuigi Rizzo char task_name[32]; /* task name */
2732f345d8eSLuigi Rizzo int vector; /* interrupt vector number */
2742f345d8eSLuigi Rizzo } OCE_INTR_INFO, *POCE_INTR_INFO;
2752f345d8eSLuigi Rizzo
2762f345d8eSLuigi Rizzo /* Ring related */
2772f345d8eSLuigi Rizzo #define GET_Q_NEXT(_START, _STEP, _END) \
2782f345d8eSLuigi Rizzo (((_START) + (_STEP)) < (_END) ? ((_START) + (_STEP)) \
2792f345d8eSLuigi Rizzo : (((_START) + (_STEP)) - (_END)))
2802f345d8eSLuigi Rizzo
2812f345d8eSLuigi Rizzo #define DBUF_PA(obj) ((obj)->addr)
2822f345d8eSLuigi Rizzo #define DBUF_VA(obj) ((obj)->ptr)
2832f345d8eSLuigi Rizzo #define DBUF_TAG(obj) ((obj)->tag)
2842f345d8eSLuigi Rizzo #define DBUF_MAP(obj) ((obj)->map)
2852f345d8eSLuigi Rizzo #define DBUF_SYNC(obj, flags) \
2862f345d8eSLuigi Rizzo (void) bus_dmamap_sync(DBUF_TAG(obj), DBUF_MAP(obj), (flags))
2872f345d8eSLuigi Rizzo
2882f345d8eSLuigi Rizzo #define RING_NUM_PENDING(ring) ring->num_used
2892f345d8eSLuigi Rizzo #define RING_FULL(ring) (ring->num_used == ring->num_items)
2902f345d8eSLuigi Rizzo #define RING_EMPTY(ring) (ring->num_used == 0)
2912f345d8eSLuigi Rizzo #define RING_NUM_FREE(ring) \
2922f345d8eSLuigi Rizzo (uint32_t)(ring->num_items - ring->num_used)
2932f345d8eSLuigi Rizzo #define RING_GET(ring, n) \
2942f345d8eSLuigi Rizzo ring->cidx = GET_Q_NEXT(ring->cidx, n, ring->num_items)
2952f345d8eSLuigi Rizzo #define RING_PUT(ring, n) \
2962f345d8eSLuigi Rizzo ring->pidx = GET_Q_NEXT(ring->pidx, n, ring->num_items)
2972f345d8eSLuigi Rizzo
2982f345d8eSLuigi Rizzo #define RING_GET_CONSUMER_ITEM_VA(ring, type) \
2992f345d8eSLuigi Rizzo (void*)((type *)DBUF_VA(&ring->dma) + ring->cidx)
3002f345d8eSLuigi Rizzo #define RING_GET_CONSUMER_ITEM_PA(ring, type) \
3012f345d8eSLuigi Rizzo (uint64_t)(((type *)DBUF_PA(ring->dbuf)) + ring->cidx)
3022f345d8eSLuigi Rizzo #define RING_GET_PRODUCER_ITEM_VA(ring, type) \
3032f345d8eSLuigi Rizzo (void *)(((type *)DBUF_VA(&ring->dma)) + ring->pidx)
3042f345d8eSLuigi Rizzo #define RING_GET_PRODUCER_ITEM_PA(ring, type) \
3052f345d8eSLuigi Rizzo (uint64_t)(((type *)DBUF_PA(ring->dbuf)) + ring->pidx)
3062f345d8eSLuigi Rizzo
3072f345d8eSLuigi Rizzo #define OCE_DMAPTR(o, c) ((c *)(o)->ptr)
3082f345d8eSLuigi Rizzo
3092f345d8eSLuigi Rizzo struct oce_packet_desc {
3102f345d8eSLuigi Rizzo struct mbuf *mbuf;
3112f345d8eSLuigi Rizzo bus_dmamap_t map;
3122f345d8eSLuigi Rizzo int nsegs;
3132f345d8eSLuigi Rizzo uint32_t wqe_idx;
3142f345d8eSLuigi Rizzo };
3152f345d8eSLuigi Rizzo
3162f345d8eSLuigi Rizzo typedef struct oce_dma_mem {
3172f345d8eSLuigi Rizzo bus_dma_tag_t tag;
3182f345d8eSLuigi Rizzo bus_dmamap_t map;
3192f345d8eSLuigi Rizzo void *ptr;
3202f345d8eSLuigi Rizzo bus_addr_t paddr;
3212f345d8eSLuigi Rizzo } OCE_DMA_MEM, *POCE_DMA_MEM;
3222f345d8eSLuigi Rizzo
3232f345d8eSLuigi Rizzo typedef struct oce_ring_buffer_s {
3242f345d8eSLuigi Rizzo uint16_t cidx; /* Get ptr */
3252f345d8eSLuigi Rizzo uint16_t pidx; /* Put Ptr */
3262f345d8eSLuigi Rizzo size_t item_size;
3272f345d8eSLuigi Rizzo size_t num_items;
3282f345d8eSLuigi Rizzo uint32_t num_used;
3292f345d8eSLuigi Rizzo OCE_DMA_MEM dma;
3302f345d8eSLuigi Rizzo } oce_ring_buffer_t;
3312f345d8eSLuigi Rizzo
3322f345d8eSLuigi Rizzo /* Stats */
3332f345d8eSLuigi Rizzo #define OCE_UNICAST_PACKET 0
3342f345d8eSLuigi Rizzo #define OCE_MULTICAST_PACKET 1
3352f345d8eSLuigi Rizzo #define OCE_BROADCAST_PACKET 2
3362f345d8eSLuigi Rizzo #define OCE_RSVD_PACKET 3
3372f345d8eSLuigi Rizzo
3382f345d8eSLuigi Rizzo struct oce_rx_stats {
3392f345d8eSLuigi Rizzo /* Total Receive Stats*/
3402f345d8eSLuigi Rizzo uint64_t t_rx_pkts;
3412f345d8eSLuigi Rizzo uint64_t t_rx_bytes;
3422f345d8eSLuigi Rizzo uint32_t t_rx_frags;
3432f345d8eSLuigi Rizzo uint32_t t_rx_mcast_pkts;
3442f345d8eSLuigi Rizzo uint32_t t_rx_ucast_pkts;
3452f345d8eSLuigi Rizzo uint32_t t_rxcp_errs;
3462f345d8eSLuigi Rizzo };
3472f345d8eSLuigi Rizzo struct oce_tx_stats {
3482f345d8eSLuigi Rizzo /*Total Transmit Stats */
3492f345d8eSLuigi Rizzo uint64_t t_tx_pkts;
3502f345d8eSLuigi Rizzo uint64_t t_tx_bytes;
3512f345d8eSLuigi Rizzo uint32_t t_tx_reqs;
3522f345d8eSLuigi Rizzo uint32_t t_tx_stops;
3532f345d8eSLuigi Rizzo uint32_t t_tx_wrbs;
3542f345d8eSLuigi Rizzo uint32_t t_tx_compl;
3552f345d8eSLuigi Rizzo uint32_t t_ipv6_ext_hdr_tx_drop;
3562f345d8eSLuigi Rizzo };
3572f345d8eSLuigi Rizzo
3582f345d8eSLuigi Rizzo struct oce_be_stats {
3592f345d8eSLuigi Rizzo uint8_t be_on_die_temperature;
3602f345d8eSLuigi Rizzo uint32_t be_tx_events;
3612f345d8eSLuigi Rizzo uint32_t eth_red_drops;
3622f345d8eSLuigi Rizzo uint32_t rx_drops_no_pbuf;
3632f345d8eSLuigi Rizzo uint32_t rx_drops_no_txpb;
3642f345d8eSLuigi Rizzo uint32_t rx_drops_no_erx_descr;
3652f345d8eSLuigi Rizzo uint32_t rx_drops_no_tpre_descr;
3662f345d8eSLuigi Rizzo uint32_t rx_drops_too_many_frags;
3672f345d8eSLuigi Rizzo uint32_t rx_drops_invalid_ring;
3682f345d8eSLuigi Rizzo uint32_t forwarded_packets;
3692f345d8eSLuigi Rizzo uint32_t rx_drops_mtu;
3702f345d8eSLuigi Rizzo uint32_t rx_crc_errors;
3712f345d8eSLuigi Rizzo uint32_t rx_alignment_symbol_errors;
3722f345d8eSLuigi Rizzo uint32_t rx_pause_frames;
3732f345d8eSLuigi Rizzo uint32_t rx_priority_pause_frames;
3742f345d8eSLuigi Rizzo uint32_t rx_control_frames;
3752f345d8eSLuigi Rizzo uint32_t rx_in_range_errors;
3762f345d8eSLuigi Rizzo uint32_t rx_out_range_errors;
3772f345d8eSLuigi Rizzo uint32_t rx_frame_too_long;
3782f345d8eSLuigi Rizzo uint32_t rx_address_match_errors;
3792f345d8eSLuigi Rizzo uint32_t rx_dropped_too_small;
3802f345d8eSLuigi Rizzo uint32_t rx_dropped_too_short;
3812f345d8eSLuigi Rizzo uint32_t rx_dropped_header_too_small;
3822f345d8eSLuigi Rizzo uint32_t rx_dropped_tcp_length;
3832f345d8eSLuigi Rizzo uint32_t rx_dropped_runt;
3842f345d8eSLuigi Rizzo uint32_t rx_ip_checksum_errs;
3852f345d8eSLuigi Rizzo uint32_t rx_tcp_checksum_errs;
3862f345d8eSLuigi Rizzo uint32_t rx_udp_checksum_errs;
3872f345d8eSLuigi Rizzo uint32_t rx_switched_unicast_packets;
3882f345d8eSLuigi Rizzo uint32_t rx_switched_multicast_packets;
3892f345d8eSLuigi Rizzo uint32_t rx_switched_broadcast_packets;
3902f345d8eSLuigi Rizzo uint32_t tx_pauseframes;
3912f345d8eSLuigi Rizzo uint32_t tx_priority_pauseframes;
3922f345d8eSLuigi Rizzo uint32_t tx_controlframes;
3932f345d8eSLuigi Rizzo uint32_t rxpp_fifo_overflow_drop;
3942f345d8eSLuigi Rizzo uint32_t rx_input_fifo_overflow_drop;
3952f345d8eSLuigi Rizzo uint32_t pmem_fifo_overflow_drop;
3962f345d8eSLuigi Rizzo uint32_t jabber_events;
3972f345d8eSLuigi Rizzo };
3982f345d8eSLuigi Rizzo
3992f345d8eSLuigi Rizzo struct oce_xe201_stats {
4002f345d8eSLuigi Rizzo uint64_t tx_pkts;
4012f345d8eSLuigi Rizzo uint64_t tx_unicast_pkts;
4022f345d8eSLuigi Rizzo uint64_t tx_multicast_pkts;
4032f345d8eSLuigi Rizzo uint64_t tx_broadcast_pkts;
4042f345d8eSLuigi Rizzo uint64_t tx_bytes;
4052f345d8eSLuigi Rizzo uint64_t tx_unicast_bytes;
4062f345d8eSLuigi Rizzo uint64_t tx_multicast_bytes;
4072f345d8eSLuigi Rizzo uint64_t tx_broadcast_bytes;
4082f345d8eSLuigi Rizzo uint64_t tx_discards;
4092f345d8eSLuigi Rizzo uint64_t tx_errors;
4102f345d8eSLuigi Rizzo uint64_t tx_pause_frames;
4112f345d8eSLuigi Rizzo uint64_t tx_pause_on_frames;
4122f345d8eSLuigi Rizzo uint64_t tx_pause_off_frames;
4132f345d8eSLuigi Rizzo uint64_t tx_internal_mac_errors;
4142f345d8eSLuigi Rizzo uint64_t tx_control_frames;
4152f345d8eSLuigi Rizzo uint64_t tx_pkts_64_bytes;
4162f345d8eSLuigi Rizzo uint64_t tx_pkts_65_to_127_bytes;
4172f345d8eSLuigi Rizzo uint64_t tx_pkts_128_to_255_bytes;
4182f345d8eSLuigi Rizzo uint64_t tx_pkts_256_to_511_bytes;
4192f345d8eSLuigi Rizzo uint64_t tx_pkts_512_to_1023_bytes;
4202f345d8eSLuigi Rizzo uint64_t tx_pkts_1024_to_1518_bytes;
4212f345d8eSLuigi Rizzo uint64_t tx_pkts_1519_to_2047_bytes;
4222f345d8eSLuigi Rizzo uint64_t tx_pkts_2048_to_4095_bytes;
4232f345d8eSLuigi Rizzo uint64_t tx_pkts_4096_to_8191_bytes;
4242f345d8eSLuigi Rizzo uint64_t tx_pkts_8192_to_9216_bytes;
4252f345d8eSLuigi Rizzo uint64_t tx_lso_pkts;
4262f345d8eSLuigi Rizzo uint64_t rx_pkts;
4272f345d8eSLuigi Rizzo uint64_t rx_unicast_pkts;
4282f345d8eSLuigi Rizzo uint64_t rx_multicast_pkts;
4292f345d8eSLuigi Rizzo uint64_t rx_broadcast_pkts;
4302f345d8eSLuigi Rizzo uint64_t rx_bytes;
4312f345d8eSLuigi Rizzo uint64_t rx_unicast_bytes;
4322f345d8eSLuigi Rizzo uint64_t rx_multicast_bytes;
4332f345d8eSLuigi Rizzo uint64_t rx_broadcast_bytes;
4342f345d8eSLuigi Rizzo uint32_t rx_unknown_protos;
4352f345d8eSLuigi Rizzo uint64_t rx_discards;
4362f345d8eSLuigi Rizzo uint64_t rx_errors;
4372f345d8eSLuigi Rizzo uint64_t rx_crc_errors;
4382f345d8eSLuigi Rizzo uint64_t rx_alignment_errors;
4392f345d8eSLuigi Rizzo uint64_t rx_symbol_errors;
4402f345d8eSLuigi Rizzo uint64_t rx_pause_frames;
4412f345d8eSLuigi Rizzo uint64_t rx_pause_on_frames;
4422f345d8eSLuigi Rizzo uint64_t rx_pause_off_frames;
4432f345d8eSLuigi Rizzo uint64_t rx_frames_too_long;
4442f345d8eSLuigi Rizzo uint64_t rx_internal_mac_errors;
4452f345d8eSLuigi Rizzo uint32_t rx_undersize_pkts;
4462f345d8eSLuigi Rizzo uint32_t rx_oversize_pkts;
4472f345d8eSLuigi Rizzo uint32_t rx_fragment_pkts;
4482f345d8eSLuigi Rizzo uint32_t rx_jabbers;
4492f345d8eSLuigi Rizzo uint64_t rx_control_frames;
4502f345d8eSLuigi Rizzo uint64_t rx_control_frames_unknown_opcode;
4512f345d8eSLuigi Rizzo uint32_t rx_in_range_errors;
4522f345d8eSLuigi Rizzo uint32_t rx_out_of_range_errors;
4532f345d8eSLuigi Rizzo uint32_t rx_address_match_errors;
4542f345d8eSLuigi Rizzo uint32_t rx_vlan_mismatch_errors;
4552f345d8eSLuigi Rizzo uint32_t rx_dropped_too_small;
4562f345d8eSLuigi Rizzo uint32_t rx_dropped_too_short;
4572f345d8eSLuigi Rizzo uint32_t rx_dropped_header_too_small;
4582f345d8eSLuigi Rizzo uint32_t rx_dropped_invalid_tcp_length;
4592f345d8eSLuigi Rizzo uint32_t rx_dropped_runt;
4602f345d8eSLuigi Rizzo uint32_t rx_ip_checksum_errors;
4612f345d8eSLuigi Rizzo uint32_t rx_tcp_checksum_errors;
4622f345d8eSLuigi Rizzo uint32_t rx_udp_checksum_errors;
4632f345d8eSLuigi Rizzo uint32_t rx_non_rss_pkts;
4642f345d8eSLuigi Rizzo uint64_t rx_ipv4_pkts;
4652f345d8eSLuigi Rizzo uint64_t rx_ipv6_pkts;
4662f345d8eSLuigi Rizzo uint64_t rx_ipv4_bytes;
4672f345d8eSLuigi Rizzo uint64_t rx_ipv6_bytes;
4682f345d8eSLuigi Rizzo uint64_t rx_nic_pkts;
4692f345d8eSLuigi Rizzo uint64_t rx_tcp_pkts;
4702f345d8eSLuigi Rizzo uint64_t rx_iscsi_pkts;
4712f345d8eSLuigi Rizzo uint64_t rx_management_pkts;
4722f345d8eSLuigi Rizzo uint64_t rx_switched_unicast_pkts;
4732f345d8eSLuigi Rizzo uint64_t rx_switched_multicast_pkts;
4742f345d8eSLuigi Rizzo uint64_t rx_switched_broadcast_pkts;
4752f345d8eSLuigi Rizzo uint64_t num_forwards;
4762f345d8eSLuigi Rizzo uint32_t rx_fifo_overflow;
4772f345d8eSLuigi Rizzo uint32_t rx_input_fifo_overflow;
4782f345d8eSLuigi Rizzo uint64_t rx_drops_too_many_frags;
4792f345d8eSLuigi Rizzo uint32_t rx_drops_invalid_queue;
4802f345d8eSLuigi Rizzo uint64_t rx_drops_mtu;
4812f345d8eSLuigi Rizzo uint64_t rx_pkts_64_bytes;
4822f345d8eSLuigi Rizzo uint64_t rx_pkts_65_to_127_bytes;
4832f345d8eSLuigi Rizzo uint64_t rx_pkts_128_to_255_bytes;
4842f345d8eSLuigi Rizzo uint64_t rx_pkts_256_to_511_bytes;
4852f345d8eSLuigi Rizzo uint64_t rx_pkts_512_to_1023_bytes;
4862f345d8eSLuigi Rizzo uint64_t rx_pkts_1024_to_1518_bytes;
4872f345d8eSLuigi Rizzo uint64_t rx_pkts_1519_to_2047_bytes;
4882f345d8eSLuigi Rizzo uint64_t rx_pkts_2048_to_4095_bytes;
4892f345d8eSLuigi Rizzo uint64_t rx_pkts_4096_to_8191_bytes;
4902f345d8eSLuigi Rizzo uint64_t rx_pkts_8192_to_9216_bytes;
4912f345d8eSLuigi Rizzo };
4922f345d8eSLuigi Rizzo
4932f345d8eSLuigi Rizzo struct oce_drv_stats {
4942f345d8eSLuigi Rizzo struct oce_rx_stats rx;
4952f345d8eSLuigi Rizzo struct oce_tx_stats tx;
4962f345d8eSLuigi Rizzo union {
4972f345d8eSLuigi Rizzo struct oce_be_stats be;
4982f345d8eSLuigi Rizzo struct oce_xe201_stats xe201;
4992f345d8eSLuigi Rizzo } u0;
5002f345d8eSLuigi Rizzo };
5012f345d8eSLuigi Rizzo
502cdaba892SXin LI #define INTR_RATE_HWM 15000
503cdaba892SXin LI #define INTR_RATE_LWM 10000
5042f345d8eSLuigi Rizzo
505cdaba892SXin LI #define OCE_MAX_EQD 128u
506c2625e6eSJosh Paetzel #define OCE_MIN_EQD 0u
507cdaba892SXin LI
508cdaba892SXin LI struct oce_set_eqd {
509cdaba892SXin LI uint32_t eq_id;
510cdaba892SXin LI uint32_t phase;
511cdaba892SXin LI uint32_t delay_multiplier;
512cdaba892SXin LI };
513cdaba892SXin LI
514cdaba892SXin LI struct oce_aic_obj { /* Adaptive interrupt coalescing (AIC) info */
515cdaba892SXin LI boolean_t enable;
516cdaba892SXin LI uint32_t min_eqd; /* in usecs */
517cdaba892SXin LI uint32_t max_eqd; /* in usecs */
518cdaba892SXin LI uint32_t cur_eqd; /* in usecs */
519cdaba892SXin LI uint32_t et_eqd; /* configured value when aic is off */
520cdaba892SXin LI uint64_t ticks;
521c2625e6eSJosh Paetzel uint64_t prev_rxpkts;
522c2625e6eSJosh Paetzel uint64_t prev_txreqs;
523cdaba892SXin LI };
5242f345d8eSLuigi Rizzo
5252f345d8eSLuigi Rizzo #define MAX_LOCK_DESC_LEN 32
5262f345d8eSLuigi Rizzo struct oce_lock {
5272f345d8eSLuigi Rizzo struct mtx mutex;
5282f345d8eSLuigi Rizzo char name[MAX_LOCK_DESC_LEN+1];
5292f345d8eSLuigi Rizzo };
5302f345d8eSLuigi Rizzo #define OCE_LOCK struct oce_lock
5312f345d8eSLuigi Rizzo
5322f345d8eSLuigi Rizzo #define LOCK_CREATE(lock, desc) { \
5332f345d8eSLuigi Rizzo strncpy((lock)->name, (desc), MAX_LOCK_DESC_LEN); \
5342f345d8eSLuigi Rizzo (lock)->name[MAX_LOCK_DESC_LEN] = '\0'; \
535beb0f7e7SJosh Paetzel mtx_init(&(lock)->mutex, (lock)->name, NULL, MTX_DEF); \
5362f345d8eSLuigi Rizzo }
5372f345d8eSLuigi Rizzo #define LOCK_DESTROY(lock) \
5382f345d8eSLuigi Rizzo if (mtx_initialized(&(lock)->mutex))\
5392f345d8eSLuigi Rizzo mtx_destroy(&(lock)->mutex)
5402f345d8eSLuigi Rizzo #define TRY_LOCK(lock) mtx_trylock(&(lock)->mutex)
5412f345d8eSLuigi Rizzo #define LOCK(lock) mtx_lock(&(lock)->mutex)
5422f345d8eSLuigi Rizzo #define LOCKED(lock) mtx_owned(&(lock)->mutex)
5432f345d8eSLuigi Rizzo #define UNLOCK(lock) mtx_unlock(&(lock)->mutex)
5442f345d8eSLuigi Rizzo
5452f345d8eSLuigi Rizzo #define DEFAULT_MQ_MBOX_TIMEOUT (5 * 1000 * 1000)
5462f345d8eSLuigi Rizzo #define MBX_READY_TIMEOUT (1 * 1000 * 1000)
5472f345d8eSLuigi Rizzo #define DEFAULT_DRAIN_TIME 200
5482f345d8eSLuigi Rizzo #define MBX_TIMEOUT_SEC 5
5492f345d8eSLuigi Rizzo #define STAT_TIMEOUT 2000000
5502f345d8eSLuigi Rizzo
5512f345d8eSLuigi Rizzo /* size of the packet descriptor array in a transmit queue */
5522f345d8eSLuigi Rizzo #define OCE_TX_RING_SIZE 2048
5532f345d8eSLuigi Rizzo #define OCE_RX_RING_SIZE 1024
5542f345d8eSLuigi Rizzo #define OCE_WQ_PACKET_ARRAY_SIZE (OCE_TX_RING_SIZE/2)
5552f345d8eSLuigi Rizzo #define OCE_RQ_PACKET_ARRAY_SIZE (OCE_RX_RING_SIZE)
5562f345d8eSLuigi Rizzo
5572f345d8eSLuigi Rizzo struct oce_dev;
5582f345d8eSLuigi Rizzo
5592f345d8eSLuigi Rizzo enum eq_len {
5602f345d8eSLuigi Rizzo EQ_LEN_256 = 256,
5612f345d8eSLuigi Rizzo EQ_LEN_512 = 512,
5622f345d8eSLuigi Rizzo EQ_LEN_1024 = 1024,
5632f345d8eSLuigi Rizzo EQ_LEN_2048 = 2048,
5642f345d8eSLuigi Rizzo EQ_LEN_4096 = 4096
5652f345d8eSLuigi Rizzo };
5662f345d8eSLuigi Rizzo
5672f345d8eSLuigi Rizzo enum eqe_size {
5682f345d8eSLuigi Rizzo EQE_SIZE_4 = 4,
5692f345d8eSLuigi Rizzo EQE_SIZE_16 = 16
5702f345d8eSLuigi Rizzo };
5712f345d8eSLuigi Rizzo
5722f345d8eSLuigi Rizzo enum qtype {
5732f345d8eSLuigi Rizzo QTYPE_EQ,
5742f345d8eSLuigi Rizzo QTYPE_MQ,
5752f345d8eSLuigi Rizzo QTYPE_WQ,
5762f345d8eSLuigi Rizzo QTYPE_RQ,
5772f345d8eSLuigi Rizzo QTYPE_CQ,
5782f345d8eSLuigi Rizzo QTYPE_RSS
5792f345d8eSLuigi Rizzo };
5802f345d8eSLuigi Rizzo
5812f345d8eSLuigi Rizzo typedef enum qstate_e {
5822f345d8eSLuigi Rizzo QDELETED = 0x0,
5832f345d8eSLuigi Rizzo QCREATED = 0x1
5842f345d8eSLuigi Rizzo } qstate_t;
5852f345d8eSLuigi Rizzo
5862f345d8eSLuigi Rizzo struct eq_config {
5872f345d8eSLuigi Rizzo enum eq_len q_len;
5882f345d8eSLuigi Rizzo enum eqe_size item_size;
5892f345d8eSLuigi Rizzo uint32_t q_vector_num;
5902f345d8eSLuigi Rizzo uint8_t min_eqd;
5912f345d8eSLuigi Rizzo uint8_t max_eqd;
5922f345d8eSLuigi Rizzo uint8_t cur_eqd;
5932f345d8eSLuigi Rizzo uint8_t pad;
5942f345d8eSLuigi Rizzo };
5952f345d8eSLuigi Rizzo
5962f345d8eSLuigi Rizzo struct oce_eq {
5972f345d8eSLuigi Rizzo uint32_t eq_id;
5982f345d8eSLuigi Rizzo void *parent;
5992f345d8eSLuigi Rizzo void *cb_context;
6002f345d8eSLuigi Rizzo oce_ring_buffer_t *ring;
6012f345d8eSLuigi Rizzo uint32_t ref_count;
6022f345d8eSLuigi Rizzo qstate_t qstate;
6032f345d8eSLuigi Rizzo struct oce_cq *cq[OCE_MAX_CQ_EQ];
6042f345d8eSLuigi Rizzo int cq_valid;
6052f345d8eSLuigi Rizzo struct eq_config eq_cfg;
6062f345d8eSLuigi Rizzo int vector;
607cdaba892SXin LI uint64_t intr;
6082f345d8eSLuigi Rizzo };
6092f345d8eSLuigi Rizzo
6102f345d8eSLuigi Rizzo enum cq_len {
6112f345d8eSLuigi Rizzo CQ_LEN_256 = 256,
6122f345d8eSLuigi Rizzo CQ_LEN_512 = 512,
613c2625e6eSJosh Paetzel CQ_LEN_1024 = 1024,
614c2625e6eSJosh Paetzel CQ_LEN_2048 = 2048
6152f345d8eSLuigi Rizzo };
6162f345d8eSLuigi Rizzo
6172f345d8eSLuigi Rizzo struct cq_config {
6182f345d8eSLuigi Rizzo enum cq_len q_len;
6192f345d8eSLuigi Rizzo uint32_t item_size;
6202f345d8eSLuigi Rizzo boolean_t is_eventable;
6212f345d8eSLuigi Rizzo boolean_t sol_eventable;
6222f345d8eSLuigi Rizzo boolean_t nodelay;
6232f345d8eSLuigi Rizzo uint16_t dma_coalescing;
6242f345d8eSLuigi Rizzo };
6252f345d8eSLuigi Rizzo
6262f345d8eSLuigi Rizzo typedef uint16_t(*cq_handler_t) (void *arg1);
6272f345d8eSLuigi Rizzo
6282f345d8eSLuigi Rizzo struct oce_cq {
6292f345d8eSLuigi Rizzo uint32_t cq_id;
6302f345d8eSLuigi Rizzo void *parent;
6312f345d8eSLuigi Rizzo struct oce_eq *eq;
6322f345d8eSLuigi Rizzo cq_handler_t cq_handler;
6332f345d8eSLuigi Rizzo void *cb_arg;
6342f345d8eSLuigi Rizzo oce_ring_buffer_t *ring;
6352f345d8eSLuigi Rizzo qstate_t qstate;
6362f345d8eSLuigi Rizzo struct cq_config cq_cfg;
6372f345d8eSLuigi Rizzo uint32_t ref_count;
6382f345d8eSLuigi Rizzo };
6392f345d8eSLuigi Rizzo
6402f345d8eSLuigi Rizzo struct mq_config {
6412f345d8eSLuigi Rizzo uint32_t eqd;
6422f345d8eSLuigi Rizzo uint8_t q_len;
6432f345d8eSLuigi Rizzo uint8_t pad[3];
6442f345d8eSLuigi Rizzo };
6452f345d8eSLuigi Rizzo
6462f345d8eSLuigi Rizzo struct oce_mq {
6472f345d8eSLuigi Rizzo void *parent;
6482f345d8eSLuigi Rizzo oce_ring_buffer_t *ring;
6492f345d8eSLuigi Rizzo uint32_t mq_id;
6502f345d8eSLuigi Rizzo struct oce_cq *cq;
6512f345d8eSLuigi Rizzo struct oce_cq *async_cq;
6522f345d8eSLuigi Rizzo uint32_t mq_free;
6532f345d8eSLuigi Rizzo qstate_t qstate;
6542f345d8eSLuigi Rizzo struct mq_config cfg;
6552f345d8eSLuigi Rizzo };
6562f345d8eSLuigi Rizzo
6572f345d8eSLuigi Rizzo struct oce_mbx_ctx {
6582f345d8eSLuigi Rizzo struct oce_mbx *mbx;
6592f345d8eSLuigi Rizzo void (*cb) (void *ctx);
6602f345d8eSLuigi Rizzo void *cb_ctx;
6612f345d8eSLuigi Rizzo };
6622f345d8eSLuigi Rizzo
6632f345d8eSLuigi Rizzo struct wq_config {
6642f345d8eSLuigi Rizzo uint8_t wq_type;
6652f345d8eSLuigi Rizzo uint16_t buf_size;
6662f345d8eSLuigi Rizzo uint8_t pad[1];
6672f345d8eSLuigi Rizzo uint32_t q_len;
6682f345d8eSLuigi Rizzo uint16_t pd_id;
6692f345d8eSLuigi Rizzo uint16_t pci_fn_num;
6702f345d8eSLuigi Rizzo uint32_t eqd; /* interrupt delay */
6712f345d8eSLuigi Rizzo uint32_t nbufs;
6722f345d8eSLuigi Rizzo uint32_t nhdl;
6732f345d8eSLuigi Rizzo };
6742f345d8eSLuigi Rizzo
6752f345d8eSLuigi Rizzo struct oce_tx_queue_stats {
6762f345d8eSLuigi Rizzo uint64_t tx_pkts;
6772f345d8eSLuigi Rizzo uint64_t tx_bytes;
6782f345d8eSLuigi Rizzo uint32_t tx_reqs;
6792f345d8eSLuigi Rizzo uint32_t tx_stops; /* number of times TX Q was stopped */
6802f345d8eSLuigi Rizzo uint32_t tx_wrbs;
6812f345d8eSLuigi Rizzo uint32_t tx_compl;
6822f345d8eSLuigi Rizzo uint32_t tx_rate;
6832f345d8eSLuigi Rizzo uint32_t ipv6_ext_hdr_tx_drop;
6842f345d8eSLuigi Rizzo };
6852f345d8eSLuigi Rizzo
6862f345d8eSLuigi Rizzo struct oce_wq {
6872f345d8eSLuigi Rizzo OCE_LOCK tx_lock;
688c2625e6eSJosh Paetzel OCE_LOCK tx_compl_lock;
6892f345d8eSLuigi Rizzo void *parent;
6902f345d8eSLuigi Rizzo oce_ring_buffer_t *ring;
6912f345d8eSLuigi Rizzo struct oce_cq *cq;
6922f345d8eSLuigi Rizzo bus_dma_tag_t tag;
6932f345d8eSLuigi Rizzo struct oce_packet_desc pckts[OCE_WQ_PACKET_ARRAY_SIZE];
694291a1934SXin LI uint32_t pkt_desc_tail;
695291a1934SXin LI uint32_t pkt_desc_head;
6962f345d8eSLuigi Rizzo uint32_t wqm_used;
6972f345d8eSLuigi Rizzo boolean_t resched;
6982f345d8eSLuigi Rizzo uint32_t wq_free;
6992f345d8eSLuigi Rizzo uint32_t tx_deferd;
7002f345d8eSLuigi Rizzo uint32_t pkt_drops;
7012f345d8eSLuigi Rizzo qstate_t qstate;
7022f345d8eSLuigi Rizzo uint16_t wq_id;
7032f345d8eSLuigi Rizzo struct wq_config cfg;
7042f345d8eSLuigi Rizzo int queue_index;
7052f345d8eSLuigi Rizzo struct oce_tx_queue_stats tx_stats;
7062f345d8eSLuigi Rizzo struct buf_ring *br;
7072f345d8eSLuigi Rizzo struct task txtask;
708291a1934SXin LI uint32_t db_offset;
7092f345d8eSLuigi Rizzo };
7102f345d8eSLuigi Rizzo
7112f345d8eSLuigi Rizzo struct rq_config {
7122f345d8eSLuigi Rizzo uint32_t q_len;
7132f345d8eSLuigi Rizzo uint32_t frag_size;
7142f345d8eSLuigi Rizzo uint32_t mtu;
7152f345d8eSLuigi Rizzo uint32_t if_id;
7162f345d8eSLuigi Rizzo uint32_t is_rss_queue;
7172f345d8eSLuigi Rizzo uint32_t eqd;
7182f345d8eSLuigi Rizzo uint32_t nbufs;
7192f345d8eSLuigi Rizzo };
7202f345d8eSLuigi Rizzo
7212f345d8eSLuigi Rizzo struct oce_rx_queue_stats {
7222f345d8eSLuigi Rizzo uint32_t rx_post_fail;
7232f345d8eSLuigi Rizzo uint32_t rx_ucast_pkts;
7242f345d8eSLuigi Rizzo uint32_t rx_compl;
7252f345d8eSLuigi Rizzo uint64_t rx_bytes;
7262f345d8eSLuigi Rizzo uint64_t rx_bytes_prev;
7272f345d8eSLuigi Rizzo uint64_t rx_pkts;
7282f345d8eSLuigi Rizzo uint32_t rx_rate;
7292f345d8eSLuigi Rizzo uint32_t rx_mcast_pkts;
7302f345d8eSLuigi Rizzo uint32_t rxcp_err;
7312f345d8eSLuigi Rizzo uint32_t rx_frags;
7322f345d8eSLuigi Rizzo uint32_t prev_rx_frags;
7332f345d8eSLuigi Rizzo uint32_t rx_fps;
734c2625e6eSJosh Paetzel uint32_t rx_drops_no_frags; /* HW has no fetched frags */
7352f345d8eSLuigi Rizzo };
7362f345d8eSLuigi Rizzo
7372f345d8eSLuigi Rizzo struct oce_rq {
7382f345d8eSLuigi Rizzo struct rq_config cfg;
7392f345d8eSLuigi Rizzo uint32_t rq_id;
7402f345d8eSLuigi Rizzo int queue_index;
7412f345d8eSLuigi Rizzo uint32_t rss_cpuid;
7422f345d8eSLuigi Rizzo void *parent;
7432f345d8eSLuigi Rizzo oce_ring_buffer_t *ring;
7442f345d8eSLuigi Rizzo struct oce_cq *cq;
7452f345d8eSLuigi Rizzo void *pad1;
7462f345d8eSLuigi Rizzo bus_dma_tag_t tag;
7472f345d8eSLuigi Rizzo struct oce_packet_desc pckts[OCE_RQ_PACKET_ARRAY_SIZE];
7482f345d8eSLuigi Rizzo uint32_t pending;
7492f345d8eSLuigi Rizzo #ifdef notdef
7502f345d8eSLuigi Rizzo struct mbuf *head;
7512f345d8eSLuigi Rizzo struct mbuf *tail;
7522f345d8eSLuigi Rizzo int fragsleft;
7532f345d8eSLuigi Rizzo #endif
7542f345d8eSLuigi Rizzo qstate_t qstate;
7552f345d8eSLuigi Rizzo OCE_LOCK rx_lock;
7562f345d8eSLuigi Rizzo struct oce_rx_queue_stats rx_stats;
7572f345d8eSLuigi Rizzo struct lro_ctrl lro;
7582f345d8eSLuigi Rizzo int lro_pkts_queued;
759c2625e6eSJosh Paetzel int islro;
760c2625e6eSJosh Paetzel struct nic_hwlro_cqe_part1 *cqe_firstpart;
7612f345d8eSLuigi Rizzo
7622f345d8eSLuigi Rizzo };
7632f345d8eSLuigi Rizzo
7642f345d8eSLuigi Rizzo struct link_status {
765a4f734b4SXin LI uint8_t phys_port_speed;
766a4f734b4SXin LI uint8_t logical_link_status;
7672f345d8eSLuigi Rizzo uint16_t qos_link_speed;
7682f345d8eSLuigi Rizzo };
7692f345d8eSLuigi Rizzo
7702f345d8eSLuigi Rizzo #define OCE_FLAGS_PCIX 0x00000001
7712f345d8eSLuigi Rizzo #define OCE_FLAGS_PCIE 0x00000002
7722f345d8eSLuigi Rizzo #define OCE_FLAGS_MSI_CAPABLE 0x00000004
7732f345d8eSLuigi Rizzo #define OCE_FLAGS_MSIX_CAPABLE 0x00000008
7742f345d8eSLuigi Rizzo #define OCE_FLAGS_USING_MSI 0x00000010
7752f345d8eSLuigi Rizzo #define OCE_FLAGS_USING_MSIX 0x00000020
7762f345d8eSLuigi Rizzo #define OCE_FLAGS_FUNCRESET_RQD 0x00000040
7772f345d8eSLuigi Rizzo #define OCE_FLAGS_VIRTUAL_PORT 0x00000080
7782f345d8eSLuigi Rizzo #define OCE_FLAGS_MBOX_ENDIAN_RQD 0x00000100
7792f345d8eSLuigi Rizzo #define OCE_FLAGS_BE3 0x00000200
7802f345d8eSLuigi Rizzo #define OCE_FLAGS_XE201 0x00000400
7812f345d8eSLuigi Rizzo #define OCE_FLAGS_BE2 0x00000800
782291a1934SXin LI #define OCE_FLAGS_SH 0x00001000
783c2625e6eSJosh Paetzel #define OCE_FLAGS_OS2BMC 0x00002000
7842f345d8eSLuigi Rizzo
7852f345d8eSLuigi Rizzo #define OCE_DEV_BE2_CFG_BAR 1
7862f345d8eSLuigi Rizzo #define OCE_DEV_CFG_BAR 0
7872f345d8eSLuigi Rizzo #define OCE_PCI_CSR_BAR 2
7882f345d8eSLuigi Rizzo #define OCE_PCI_DB_BAR 4
7892f345d8eSLuigi Rizzo
7902f345d8eSLuigi Rizzo typedef struct oce_softc {
7912f345d8eSLuigi Rizzo device_t dev;
7922f345d8eSLuigi Rizzo OCE_LOCK dev_lock;
7932f345d8eSLuigi Rizzo
7942f345d8eSLuigi Rizzo uint32_t flags;
7952f345d8eSLuigi Rizzo
7962f345d8eSLuigi Rizzo uint32_t pcie_link_speed;
7972f345d8eSLuigi Rizzo uint32_t pcie_link_width;
7982f345d8eSLuigi Rizzo
7992f345d8eSLuigi Rizzo uint8_t fn; /* PCI function number */
8002f345d8eSLuigi Rizzo
8012f345d8eSLuigi Rizzo struct resource *devcfg_res;
8022f345d8eSLuigi Rizzo bus_space_tag_t devcfg_btag;
8032f345d8eSLuigi Rizzo bus_space_handle_t devcfg_bhandle;
8042f345d8eSLuigi Rizzo void *devcfg_vhandle;
8052f345d8eSLuigi Rizzo
8062f345d8eSLuigi Rizzo struct resource *csr_res;
8072f345d8eSLuigi Rizzo bus_space_tag_t csr_btag;
8082f345d8eSLuigi Rizzo bus_space_handle_t csr_bhandle;
8092f345d8eSLuigi Rizzo void *csr_vhandle;
8102f345d8eSLuigi Rizzo
8112f345d8eSLuigi Rizzo struct resource *db_res;
8122f345d8eSLuigi Rizzo bus_space_tag_t db_btag;
8132f345d8eSLuigi Rizzo bus_space_handle_t db_bhandle;
8142f345d8eSLuigi Rizzo void *db_vhandle;
8152f345d8eSLuigi Rizzo
8162f345d8eSLuigi Rizzo OCE_INTR_INFO intrs[OCE_MAX_EQ];
8172f345d8eSLuigi Rizzo int intr_count;
818c2625e6eSJosh Paetzel int roce_intr_count;
8192f345d8eSLuigi Rizzo
820*67fd4c9dSJustin Hibbits if_t ifp;
8212f345d8eSLuigi Rizzo
8222f345d8eSLuigi Rizzo struct ifmedia media;
8232f345d8eSLuigi Rizzo uint8_t link_status;
8242f345d8eSLuigi Rizzo uint8_t link_speed;
8252f345d8eSLuigi Rizzo uint8_t duplex;
8262f345d8eSLuigi Rizzo uint32_t qos_link_speed;
8272f345d8eSLuigi Rizzo uint32_t speed;
828c2625e6eSJosh Paetzel uint32_t enable_hwlro;
8292f345d8eSLuigi Rizzo
8302f345d8eSLuigi Rizzo char fw_version[32];
8312f345d8eSLuigi Rizzo struct mac_address_format macaddr;
8322f345d8eSLuigi Rizzo
8332f345d8eSLuigi Rizzo OCE_DMA_MEM bsmbx;
8342f345d8eSLuigi Rizzo OCE_LOCK bmbx_lock;
8352f345d8eSLuigi Rizzo
8362f345d8eSLuigi Rizzo uint32_t config_number;
8372f345d8eSLuigi Rizzo uint32_t asic_revision;
8382f345d8eSLuigi Rizzo uint32_t port_id;
8392f345d8eSLuigi Rizzo uint32_t function_mode;
8402f345d8eSLuigi Rizzo uint32_t function_caps;
8412f345d8eSLuigi Rizzo uint32_t max_tx_rings;
8422f345d8eSLuigi Rizzo uint32_t max_rx_rings;
8432f345d8eSLuigi Rizzo
8442f345d8eSLuigi Rizzo struct oce_wq *wq[OCE_MAX_WQ]; /* TX work queues */
8452f345d8eSLuigi Rizzo struct oce_rq *rq[OCE_MAX_RQ]; /* RX work queues */
8462f345d8eSLuigi Rizzo struct oce_cq *cq[OCE_MAX_CQ]; /* Completion queues */
8472f345d8eSLuigi Rizzo struct oce_eq *eq[OCE_MAX_EQ]; /* Event queues */
8482f345d8eSLuigi Rizzo struct oce_mq *mq; /* Mailbox queue */
8492f345d8eSLuigi Rizzo
8502f345d8eSLuigi Rizzo uint32_t neqs;
8512f345d8eSLuigi Rizzo uint32_t ncqs;
8522f345d8eSLuigi Rizzo uint32_t nrqs;
8532f345d8eSLuigi Rizzo uint32_t nwqs;
854291a1934SXin LI uint32_t nrssqs;
8552f345d8eSLuigi Rizzo
8562f345d8eSLuigi Rizzo uint32_t tx_ring_size;
8572f345d8eSLuigi Rizzo uint32_t rx_ring_size;
8582f345d8eSLuigi Rizzo uint32_t rq_frag_size;
8592f345d8eSLuigi Rizzo
8602f345d8eSLuigi Rizzo uint32_t if_id; /* interface ID */
8612f345d8eSLuigi Rizzo uint32_t nifs; /* number of adapter interfaces, 0 or 1 */
8622f345d8eSLuigi Rizzo uint32_t pmac_id; /* PMAC id */
8632f345d8eSLuigi Rizzo
8642f345d8eSLuigi Rizzo uint32_t if_cap_flags;
8652f345d8eSLuigi Rizzo
8662f345d8eSLuigi Rizzo uint32_t flow_control;
8675fbb6830SXin LI uint8_t promisc;
868cdaba892SXin LI
869cdaba892SXin LI struct oce_aic_obj aic_obj[OCE_MAX_EQ];
870cdaba892SXin LI
8712f345d8eSLuigi Rizzo /*Vlan Filtering related */
8722f345d8eSLuigi Rizzo eventhandler_tag vlan_attach;
8732f345d8eSLuigi Rizzo eventhandler_tag vlan_detach;
8742f345d8eSLuigi Rizzo uint16_t vlans_added;
8752f345d8eSLuigi Rizzo uint8_t vlan_tag[MAX_VLANS];
8762f345d8eSLuigi Rizzo /*stats */
8772f345d8eSLuigi Rizzo OCE_DMA_MEM stats_mem;
8782f345d8eSLuigi Rizzo struct oce_drv_stats oce_stats_info;
8792f345d8eSLuigi Rizzo struct callout timer;
8802f345d8eSLuigi Rizzo int8_t be3_native;
8815fbb6830SXin LI uint8_t hw_error;
882cdaba892SXin LI uint16_t qnq_debug_event;
883cdaba892SXin LI uint16_t qnqid;
884b41206d8SXin LI uint32_t pvid;
885b41206d8SXin LI uint32_t max_vlans;
886c2625e6eSJosh Paetzel uint32_t bmc_filt_mask;
887c2625e6eSJosh Paetzel
888c2625e6eSJosh Paetzel void *rdma_context;
889c2625e6eSJosh Paetzel uint32_t rdma_flags;
890c2625e6eSJosh Paetzel struct oce_softc *next;
8912f345d8eSLuigi Rizzo
8922f345d8eSLuigi Rizzo } OCE_SOFTC, *POCE_SOFTC;
8932f345d8eSLuigi Rizzo
894c2625e6eSJosh Paetzel #define OCE_RDMA_FLAG_SUPPORTED 0x00000001
8952f345d8eSLuigi Rizzo
8962f345d8eSLuigi Rizzo /**************************************************
8972f345d8eSLuigi Rizzo * BUS memory read/write macros
8982f345d8eSLuigi Rizzo * BE3: accesses three BAR spaces (CFG, CSR, DB)
8992f345d8eSLuigi Rizzo * Lancer: accesses one BAR space (CFG)
9002f345d8eSLuigi Rizzo **************************************************/
901291a1934SXin LI #define OCE_READ_CSR_MPU(sc, space, o) \
9022f345d8eSLuigi Rizzo ((IS_BE(sc)) ? (bus_space_read_4((sc)->space##_btag, \
9032f345d8eSLuigi Rizzo (sc)->space##_bhandle,o)) \
9042f345d8eSLuigi Rizzo : (bus_space_read_4((sc)->devcfg_btag, \
9052f345d8eSLuigi Rizzo (sc)->devcfg_bhandle,o)))
906291a1934SXin LI #define OCE_READ_REG32(sc, space, o) \
907291a1934SXin LI ((IS_BE(sc) || IS_SH(sc)) ? (bus_space_read_4((sc)->space##_btag, \
908291a1934SXin LI (sc)->space##_bhandle,o)) \
909291a1934SXin LI : (bus_space_read_4((sc)->devcfg_btag, \
910291a1934SXin LI (sc)->devcfg_bhandle,o)))
9112f345d8eSLuigi Rizzo #define OCE_READ_REG16(sc, space, o) \
912291a1934SXin LI ((IS_BE(sc) || IS_SH(sc)) ? (bus_space_read_2((sc)->space##_btag, \
9132f345d8eSLuigi Rizzo (sc)->space##_bhandle,o)) \
9142f345d8eSLuigi Rizzo : (bus_space_read_2((sc)->devcfg_btag, \
9152f345d8eSLuigi Rizzo (sc)->devcfg_bhandle,o)))
9162f345d8eSLuigi Rizzo #define OCE_READ_REG8(sc, space, o) \
917291a1934SXin LI ((IS_BE(sc) || IS_SH(sc)) ? (bus_space_read_1((sc)->space##_btag, \
9182f345d8eSLuigi Rizzo (sc)->space##_bhandle,o)) \
9192f345d8eSLuigi Rizzo : (bus_space_read_1((sc)->devcfg_btag, \
9202f345d8eSLuigi Rizzo (sc)->devcfg_bhandle,o)))
9212f345d8eSLuigi Rizzo
922291a1934SXin LI #define OCE_WRITE_CSR_MPU(sc, space, o, v) \
9232f345d8eSLuigi Rizzo ((IS_BE(sc)) ? (bus_space_write_4((sc)->space##_btag, \
9242f345d8eSLuigi Rizzo (sc)->space##_bhandle,o,v)) \
9252f345d8eSLuigi Rizzo : (bus_space_write_4((sc)->devcfg_btag, \
9262f345d8eSLuigi Rizzo (sc)->devcfg_bhandle,o,v)))
927291a1934SXin LI #define OCE_WRITE_REG32(sc, space, o, v) \
928291a1934SXin LI ((IS_BE(sc) || IS_SH(sc)) ? (bus_space_write_4((sc)->space##_btag, \
929291a1934SXin LI (sc)->space##_bhandle,o,v)) \
930291a1934SXin LI : (bus_space_write_4((sc)->devcfg_btag, \
931291a1934SXin LI (sc)->devcfg_bhandle,o,v)))
9322f345d8eSLuigi Rizzo #define OCE_WRITE_REG16(sc, space, o, v) \
933291a1934SXin LI ((IS_BE(sc) || IS_SH(sc)) ? (bus_space_write_2((sc)->space##_btag, \
9342f345d8eSLuigi Rizzo (sc)->space##_bhandle,o,v)) \
9352f345d8eSLuigi Rizzo : (bus_space_write_2((sc)->devcfg_btag, \
9362f345d8eSLuigi Rizzo (sc)->devcfg_bhandle,o,v)))
9372f345d8eSLuigi Rizzo #define OCE_WRITE_REG8(sc, space, o, v) \
938291a1934SXin LI ((IS_BE(sc) || IS_SH(sc)) ? (bus_space_write_1((sc)->space##_btag, \
9392f345d8eSLuigi Rizzo (sc)->space##_bhandle,o,v)) \
9402f345d8eSLuigi Rizzo : (bus_space_write_1((sc)->devcfg_btag, \
9412f345d8eSLuigi Rizzo (sc)->devcfg_bhandle,o,v)))
9422f345d8eSLuigi Rizzo
943c2625e6eSJosh Paetzel void oce_rx_flush_lro(struct oce_rq *rq);
9442f345d8eSLuigi Rizzo /***********************************************************
9452f345d8eSLuigi Rizzo * DMA memory functions
9462f345d8eSLuigi Rizzo ***********************************************************/
9472f345d8eSLuigi Rizzo #define oce_dma_sync(d, f) bus_dmamap_sync((d)->tag, (d)->map, f)
9482f345d8eSLuigi Rizzo int oce_dma_alloc(POCE_SOFTC sc, bus_size_t size, POCE_DMA_MEM dma, int flags);
9492f345d8eSLuigi Rizzo void oce_dma_free(POCE_SOFTC sc, POCE_DMA_MEM dma);
9502f345d8eSLuigi Rizzo void oce_dma_map_addr(void *arg, bus_dma_segment_t * segs, int nseg, int error);
9512f345d8eSLuigi Rizzo void oce_destroy_ring_buffer(POCE_SOFTC sc, oce_ring_buffer_t *ring);
9522f345d8eSLuigi Rizzo oce_ring_buffer_t *oce_create_ring_buffer(POCE_SOFTC sc,
9532f345d8eSLuigi Rizzo uint32_t q_len, uint32_t num_entries);
9542f345d8eSLuigi Rizzo /************************************************************
9552f345d8eSLuigi Rizzo * oce_hw_xxx functions
9562f345d8eSLuigi Rizzo ************************************************************/
9572f345d8eSLuigi Rizzo int oce_clear_rx_buf(struct oce_rq *rq);
9582f345d8eSLuigi Rizzo int oce_hw_pci_alloc(POCE_SOFTC sc);
9592f345d8eSLuigi Rizzo int oce_hw_init(POCE_SOFTC sc);
9602f345d8eSLuigi Rizzo int oce_hw_start(POCE_SOFTC sc);
9612f345d8eSLuigi Rizzo int oce_create_nw_interface(POCE_SOFTC sc);
9622f345d8eSLuigi Rizzo int oce_pci_soft_reset(POCE_SOFTC sc);
9632f345d8eSLuigi Rizzo int oce_hw_update_multicast(POCE_SOFTC sc);
9642f345d8eSLuigi Rizzo void oce_delete_nw_interface(POCE_SOFTC sc);
9652f345d8eSLuigi Rizzo void oce_hw_shutdown(POCE_SOFTC sc);
9662f345d8eSLuigi Rizzo void oce_hw_intr_enable(POCE_SOFTC sc);
9672f345d8eSLuigi Rizzo void oce_hw_intr_disable(POCE_SOFTC sc);
9682f345d8eSLuigi Rizzo void oce_hw_pci_free(POCE_SOFTC sc);
9692f345d8eSLuigi Rizzo
9702f345d8eSLuigi Rizzo /***********************************************************
9712f345d8eSLuigi Rizzo * oce_queue_xxx functions
9722f345d8eSLuigi Rizzo ***********************************************************/
9732f345d8eSLuigi Rizzo int oce_queue_init_all(POCE_SOFTC sc);
9742f345d8eSLuigi Rizzo int oce_start_rq(struct oce_rq *rq);
9752f345d8eSLuigi Rizzo int oce_start_wq(struct oce_wq *wq);
9762f345d8eSLuigi Rizzo int oce_start_mq(struct oce_mq *mq);
9772f345d8eSLuigi Rizzo int oce_start_rx(POCE_SOFTC sc);
9782f345d8eSLuigi Rizzo void oce_arm_eq(POCE_SOFTC sc,
9792f345d8eSLuigi Rizzo int16_t qid, int npopped, uint32_t rearm, uint32_t clearint);
9802f345d8eSLuigi Rizzo void oce_queue_release_all(POCE_SOFTC sc);
9812f345d8eSLuigi Rizzo void oce_arm_cq(POCE_SOFTC sc, int16_t qid, int npopped, uint32_t rearm);
9822f345d8eSLuigi Rizzo void oce_drain_eq(struct oce_eq *eq);
9832f345d8eSLuigi Rizzo void oce_drain_mq_cq(void *arg);
9842f345d8eSLuigi Rizzo void oce_drain_rq_cq(struct oce_rq *rq);
9852f345d8eSLuigi Rizzo void oce_drain_wq_cq(struct oce_wq *wq);
9862f345d8eSLuigi Rizzo
9872f345d8eSLuigi Rizzo uint32_t oce_page_list(oce_ring_buffer_t *ring, struct phys_addr *pa_list);
9882f345d8eSLuigi Rizzo
9892f345d8eSLuigi Rizzo /***********************************************************
9902f345d8eSLuigi Rizzo * cleanup functions
9912f345d8eSLuigi Rizzo ***********************************************************/
9922f345d8eSLuigi Rizzo void oce_stop_rx(POCE_SOFTC sc);
993c2625e6eSJosh Paetzel void oce_discard_rx_comp(struct oce_rq *rq, int num_frags);
994c2625e6eSJosh Paetzel void oce_rx_cq_clean(struct oce_rq *rq);
995c2625e6eSJosh Paetzel void oce_rx_cq_clean_hwlro(struct oce_rq *rq);
9962f345d8eSLuigi Rizzo void oce_intr_free(POCE_SOFTC sc);
9972f345d8eSLuigi Rizzo void oce_free_posted_rxbuf(struct oce_rq *rq);
9989bd3250aSLuigi Rizzo #if defined(INET6) || defined(INET)
9999bd3250aSLuigi Rizzo void oce_free_lro(POCE_SOFTC sc);
10009bd3250aSLuigi Rizzo #endif
10012f345d8eSLuigi Rizzo
10022f345d8eSLuigi Rizzo /************************************************************
10032f345d8eSLuigi Rizzo * Mailbox functions
10042f345d8eSLuigi Rizzo ************************************************************/
10052f345d8eSLuigi Rizzo int oce_fw_clean(POCE_SOFTC sc);
1006dced0d18SJosh Paetzel int oce_wait_ready(POCE_SOFTC sc);
10072f345d8eSLuigi Rizzo int oce_reset_fun(POCE_SOFTC sc);
10082f345d8eSLuigi Rizzo int oce_mbox_init(POCE_SOFTC sc);
10092f345d8eSLuigi Rizzo int oce_mbox_dispatch(POCE_SOFTC sc, uint32_t tmo_sec);
10102f345d8eSLuigi Rizzo int oce_get_fw_version(POCE_SOFTC sc);
10119bd3250aSLuigi Rizzo int oce_first_mcc_cmd(POCE_SOFTC sc);
10129bd3250aSLuigi Rizzo
10132f345d8eSLuigi Rizzo int oce_read_mac_addr(POCE_SOFTC sc, uint32_t if_id, uint8_t perm,
10142f345d8eSLuigi Rizzo uint8_t type, struct mac_address_format *mac);
10152f345d8eSLuigi Rizzo int oce_get_fw_config(POCE_SOFTC sc);
10162f345d8eSLuigi Rizzo int oce_if_create(POCE_SOFTC sc, uint32_t cap_flags, uint32_t en_flags,
10172f345d8eSLuigi Rizzo uint16_t vlan_tag, uint8_t *mac_addr, uint32_t *if_id);
10182f345d8eSLuigi Rizzo int oce_if_del(POCE_SOFTC sc, uint32_t if_id);
10192f345d8eSLuigi Rizzo int oce_config_vlan(POCE_SOFTC sc, uint32_t if_id,
10202f345d8eSLuigi Rizzo struct normal_vlan *vtag_arr, uint8_t vtag_cnt,
10212f345d8eSLuigi Rizzo uint32_t untagged, uint32_t enable_promisc);
10222f345d8eSLuigi Rizzo int oce_set_flow_control(POCE_SOFTC sc, uint32_t flow_control);
10232f345d8eSLuigi Rizzo int oce_config_nic_rss(POCE_SOFTC sc, uint32_t if_id, uint16_t enable_rss);
10245fbb6830SXin LI int oce_rxf_set_promiscuous(POCE_SOFTC sc, uint8_t enable);
10252f345d8eSLuigi Rizzo int oce_set_common_iface_rx_filter(POCE_SOFTC sc, POCE_DMA_MEM sgl);
10262f345d8eSLuigi Rizzo int oce_get_link_status(POCE_SOFTC sc, struct link_status *link);
10272f345d8eSLuigi Rizzo int oce_mbox_get_nic_stats_v0(POCE_SOFTC sc, POCE_DMA_MEM pstats_dma_mem);
1028c2625e6eSJosh Paetzel int oce_mbox_get_nic_stats_v1(POCE_SOFTC sc, POCE_DMA_MEM pstats_dma_mem);
1029c2625e6eSJosh Paetzel int oce_mbox_get_nic_stats_v2(POCE_SOFTC sc, POCE_DMA_MEM pstats_dma_mem);
10302f345d8eSLuigi Rizzo int oce_mbox_get_pport_stats(POCE_SOFTC sc, POCE_DMA_MEM pstats_dma_mem,
10312f345d8eSLuigi Rizzo uint32_t reset_stats);
10322f345d8eSLuigi Rizzo int oce_mbox_get_vport_stats(POCE_SOFTC sc, POCE_DMA_MEM pstats_dma_mem,
10332f345d8eSLuigi Rizzo uint32_t req_size, uint32_t reset_stats);
10342f345d8eSLuigi Rizzo int oce_update_multicast(POCE_SOFTC sc, POCE_DMA_MEM pdma_mem);
10352f345d8eSLuigi Rizzo int oce_pass_through_mbox(POCE_SOFTC sc, POCE_DMA_MEM dma_mem, uint32_t req_size);
10362f345d8eSLuigi Rizzo int oce_mbox_macaddr_del(POCE_SOFTC sc, uint32_t if_id, uint32_t pmac_id);
10372f345d8eSLuigi Rizzo int oce_mbox_macaddr_add(POCE_SOFTC sc, uint8_t *mac_addr,
10382f345d8eSLuigi Rizzo uint32_t if_id, uint32_t *pmac_id);
10392f345d8eSLuigi Rizzo int oce_mbox_cmd_test_loopback(POCE_SOFTC sc, uint32_t port_num,
10402f345d8eSLuigi Rizzo uint32_t loopback_type, uint32_t pkt_size, uint32_t num_pkts,
10412f345d8eSLuigi Rizzo uint64_t pattern);
10422f345d8eSLuigi Rizzo
10432f345d8eSLuigi Rizzo int oce_mbox_cmd_set_loopback(POCE_SOFTC sc, uint8_t port_num,
10442f345d8eSLuigi Rizzo uint8_t loopback_type, uint8_t enable);
10452f345d8eSLuigi Rizzo
10462f345d8eSLuigi Rizzo int oce_mbox_check_native_mode(POCE_SOFTC sc);
10472f345d8eSLuigi Rizzo int oce_mbox_post(POCE_SOFTC sc,
10482f345d8eSLuigi Rizzo struct oce_mbx *mbx, struct oce_mbx_ctx *mbxctx);
10492f345d8eSLuigi Rizzo int oce_mbox_write_flashrom(POCE_SOFTC sc, uint32_t optype,uint32_t opcode,
10502f345d8eSLuigi Rizzo POCE_DMA_MEM pdma_mem, uint32_t num_bytes);
10512f345d8eSLuigi Rizzo int oce_mbox_lancer_write_flashrom(POCE_SOFTC sc, uint32_t data_size,
10522f345d8eSLuigi Rizzo uint32_t data_offset,POCE_DMA_MEM pdma_mem,
10532f345d8eSLuigi Rizzo uint32_t *written_data, uint32_t *additional_status);
10542f345d8eSLuigi Rizzo
10552f345d8eSLuigi Rizzo int oce_mbox_get_flashrom_crc(POCE_SOFTC sc, uint8_t *flash_crc,
10562f345d8eSLuigi Rizzo uint32_t offset, uint32_t optype);
10572f345d8eSLuigi Rizzo int oce_mbox_get_phy_info(POCE_SOFTC sc, struct oce_phy_info *phy_info);
10582f345d8eSLuigi Rizzo int oce_mbox_create_rq(struct oce_rq *rq);
10592f345d8eSLuigi Rizzo int oce_mbox_create_wq(struct oce_wq *wq);
10602f345d8eSLuigi Rizzo int oce_mbox_create_eq(struct oce_eq *eq);
10612f345d8eSLuigi Rizzo int oce_mbox_cq_create(struct oce_cq *cq, uint32_t ncoalesce,
10622f345d8eSLuigi Rizzo uint32_t is_eventable);
1063cdaba892SXin LI int oce_mbox_read_transrecv_data(POCE_SOFTC sc, uint32_t page_num);
1064cdaba892SXin LI void oce_mbox_eqd_modify_periodic(POCE_SOFTC sc, struct oce_set_eqd *set_eqd,
1065cdaba892SXin LI int num);
1066b41206d8SXin LI int oce_get_profile_config(POCE_SOFTC sc, uint32_t max_rss);
1067291a1934SXin LI int oce_get_func_config(POCE_SOFTC sc);
10682f345d8eSLuigi Rizzo void mbx_common_req_hdr_init(struct mbx_hdr *hdr,
10692f345d8eSLuigi Rizzo uint8_t dom,
10702f345d8eSLuigi Rizzo uint8_t port,
10712f345d8eSLuigi Rizzo uint8_t subsys,
10722f345d8eSLuigi Rizzo uint8_t opcode,
10732f345d8eSLuigi Rizzo uint32_t timeout, uint32_t pyld_len,
10742f345d8eSLuigi Rizzo uint8_t version);
10752f345d8eSLuigi Rizzo
10762f345d8eSLuigi Rizzo uint16_t oce_mq_handler(void *arg);
10772f345d8eSLuigi Rizzo
10782f345d8eSLuigi Rizzo /************************************************************
10792f345d8eSLuigi Rizzo * Transmit functions
10802f345d8eSLuigi Rizzo ************************************************************/
10812f345d8eSLuigi Rizzo uint16_t oce_wq_handler(void *arg);
1082*67fd4c9dSJustin Hibbits void oce_start(if_t ifp);
10832f345d8eSLuigi Rizzo void oce_tx_task(void *arg, int npending);
10842f345d8eSLuigi Rizzo
10852f345d8eSLuigi Rizzo /************************************************************
10862f345d8eSLuigi Rizzo * Receive functions
10872f345d8eSLuigi Rizzo ************************************************************/
10882f345d8eSLuigi Rizzo int oce_alloc_rx_bufs(struct oce_rq *rq, int count);
10892f345d8eSLuigi Rizzo uint16_t oce_rq_handler(void *arg);
10902f345d8eSLuigi Rizzo
10912f345d8eSLuigi Rizzo /* Sysctl functions */
10922f345d8eSLuigi Rizzo void oce_add_sysctls(POCE_SOFTC sc);
10932f345d8eSLuigi Rizzo void oce_refresh_queue_stats(POCE_SOFTC sc);
10942f345d8eSLuigi Rizzo int oce_refresh_nic_stats(POCE_SOFTC sc);
10952f345d8eSLuigi Rizzo int oce_stats_init(POCE_SOFTC sc);
10962f345d8eSLuigi Rizzo void oce_stats_free(POCE_SOFTC sc);
10972f345d8eSLuigi Rizzo
1098c2625e6eSJosh Paetzel /* hw lro functions */
1099c2625e6eSJosh Paetzel int oce_mbox_nic_query_lro_capabilities(POCE_SOFTC sc, uint32_t *lro_rq_cnt, uint32_t *lro_flags);
1100c2625e6eSJosh Paetzel int oce_mbox_nic_set_iface_lro_config(POCE_SOFTC sc, int enable);
1101c2625e6eSJosh Paetzel int oce_mbox_create_rq_v2(struct oce_rq *rq);
1102c2625e6eSJosh Paetzel
11032f345d8eSLuigi Rizzo /* Capabilities */
11042f345d8eSLuigi Rizzo #define OCE_MODCAP_RSS 1
11052f345d8eSLuigi Rizzo #define OCE_MAX_RSP_HANDLED 64
11062f345d8eSLuigi Rizzo extern uint32_t oce_max_rsp_handled; /* max responses */
1107c2625e6eSJosh Paetzel extern uint32_t oce_rq_buf_size;
11082f345d8eSLuigi Rizzo
11092f345d8eSLuigi Rizzo #define OCE_MAC_LOOPBACK 0x0
11102f345d8eSLuigi Rizzo #define OCE_PHY_LOOPBACK 0x1
11112f345d8eSLuigi Rizzo #define OCE_ONE_PORT_EXT_LOOPBACK 0x2
11122f345d8eSLuigi Rizzo #define OCE_NO_LOOPBACK 0xff
11132f345d8eSLuigi Rizzo
1114b41206d8SXin LI #undef IFM_40G_SR4
1115b41206d8SXin LI #define IFM_40G_SR4 28
1116b41206d8SXin LI
11172f345d8eSLuigi Rizzo #define atomic_inc_32(x) atomic_add_32(x, 1)
11182f345d8eSLuigi Rizzo #define atomic_dec_32(x) atomic_subtract_32(x, 1)
11192f345d8eSLuigi Rizzo
11202f345d8eSLuigi Rizzo #define LE_64(x) htole64(x)
11212f345d8eSLuigi Rizzo #define LE_32(x) htole32(x)
11222f345d8eSLuigi Rizzo #define LE_16(x) htole16(x)
1123291a1934SXin LI #define HOST_64(x) le64toh(x)
1124291a1934SXin LI #define HOST_32(x) le32toh(x)
1125291a1934SXin LI #define HOST_16(x) le16toh(x)
11262f345d8eSLuigi Rizzo #define DW_SWAP(x, l)
11272f345d8eSLuigi Rizzo #define IS_ALIGNED(x,a) ((x % a) == 0)
11282f345d8eSLuigi Rizzo #define ADDR_HI(x) ((uint32_t)((uint64_t)(x) >> 32))
11292f345d8eSLuigi Rizzo #define ADDR_LO(x) ((uint32_t)((uint64_t)(x) & 0xffffffff));
11302f345d8eSLuigi Rizzo
1131*67fd4c9dSJustin Hibbits #define IF_LRO_ENABLED(sc) ((if_getcapenable((sc)->ifp) & IFCAP_LRO) ? 1:0)
1132*67fd4c9dSJustin Hibbits #define IF_LSO_ENABLED(sc) ((if_getcapenable((sc)->ifp) & IFCAP_TSO4) ? 1:0)
1133*67fd4c9dSJustin Hibbits #define IF_CSUM_ENABLED(sc) ((if_getcapenable((sc)->ifp) & IFCAP_HWCSUM) ? 1:0)
11342f345d8eSLuigi Rizzo
11352f345d8eSLuigi Rizzo #define OCE_LOG2(x) (oce_highbit(x))
oce_highbit(uint32_t x)11362f345d8eSLuigi Rizzo static inline uint32_t oce_highbit(uint32_t x)
11372f345d8eSLuigi Rizzo {
11382f345d8eSLuigi Rizzo int i;
11392f345d8eSLuigi Rizzo int c;
11402f345d8eSLuigi Rizzo int b;
11412f345d8eSLuigi Rizzo
11422f345d8eSLuigi Rizzo c = 0;
11432f345d8eSLuigi Rizzo b = 0;
11442f345d8eSLuigi Rizzo
11452f345d8eSLuigi Rizzo for (i = 0; i < 32; i++) {
11462f345d8eSLuigi Rizzo if ((1 << i) & x) {
11472f345d8eSLuigi Rizzo c++;
11482f345d8eSLuigi Rizzo b = i;
11492f345d8eSLuigi Rizzo }
11502f345d8eSLuigi Rizzo }
11512f345d8eSLuigi Rizzo
11522f345d8eSLuigi Rizzo if (c == 1)
11532f345d8eSLuigi Rizzo return b;
11542f345d8eSLuigi Rizzo
11552f345d8eSLuigi Rizzo return 0;
11562f345d8eSLuigi Rizzo }
11572f345d8eSLuigi Rizzo
MPU_EP_SEMAPHORE(POCE_SOFTC sc)1158291a1934SXin LI static inline int MPU_EP_SEMAPHORE(POCE_SOFTC sc)
1159291a1934SXin LI {
1160291a1934SXin LI if (IS_BE(sc))
1161291a1934SXin LI return MPU_EP_SEMAPHORE_BE3;
1162291a1934SXin LI else if (IS_SH(sc))
1163291a1934SXin LI return MPU_EP_SEMAPHORE_SH;
1164291a1934SXin LI else
1165291a1934SXin LI return MPU_EP_SEMAPHORE_XE201;
1166291a1934SXin LI }
1167291a1934SXin LI
1168cdaba892SXin LI #define TRANSCEIVER_DATA_NUM_ELE 64
1169cdaba892SXin LI #define TRANSCEIVER_DATA_SIZE 256
1170cdaba892SXin LI #define TRANSCEIVER_A0_SIZE 128
1171cdaba892SXin LI #define TRANSCEIVER_A2_SIZE 128
1172cdaba892SXin LI #define PAGE_NUM_A0 0xa0
1173cdaba892SXin LI #define PAGE_NUM_A2 0xa2
1174cdaba892SXin LI #define IS_QNQ_OR_UMC(sc) ((sc->pvid && (sc->function_mode & FNM_UMC_MODE ))\
1175cdaba892SXin LI || (sc->qnqid && (sc->function_mode & FNM_FLEX10_MODE)))
1176e0dd0fe3SXin LI extern uint8_t sfp_vpd_dump_buffer[TRANSCEIVER_DATA_SIZE];
1177cdaba892SXin LI
1178c2625e6eSJosh Paetzel struct oce_rdma_info;
1179c2625e6eSJosh Paetzel extern struct oce_rdma_if *oce_rdma_if;
1180c2625e6eSJosh Paetzel
1181c2625e6eSJosh Paetzel /* OS2BMC related */
1182c2625e6eSJosh Paetzel
1183c2625e6eSJosh Paetzel #define DHCP_CLIENT_PORT 68
1184c2625e6eSJosh Paetzel #define DHCP_SERVER_PORT 67
1185c2625e6eSJosh Paetzel #define NET_BIOS_PORT1 137
1186c2625e6eSJosh Paetzel #define NET_BIOS_PORT2 138
1187c2625e6eSJosh Paetzel #define DHCPV6_RAS_PORT 547
1188c2625e6eSJosh Paetzel
1189c2625e6eSJosh Paetzel #define BMC_FILT_BROADCAST_ARP ((uint32_t)(1))
1190c2625e6eSJosh Paetzel #define BMC_FILT_BROADCAST_DHCP_CLIENT ((uint32_t)(1 << 1))
1191c2625e6eSJosh Paetzel #define BMC_FILT_BROADCAST_DHCP_SERVER ((uint32_t)(1 << 2))
1192c2625e6eSJosh Paetzel #define BMC_FILT_BROADCAST_NET_BIOS ((uint32_t)(1 << 3))
1193c2625e6eSJosh Paetzel #define BMC_FILT_BROADCAST ((uint32_t)(1 << 4))
1194c2625e6eSJosh Paetzel #define BMC_FILT_MULTICAST_IPV6_NEIGH_ADVER ((uint32_t)(1 << 5))
1195c2625e6eSJosh Paetzel #define BMC_FILT_MULTICAST_IPV6_RA ((uint32_t)(1 << 6))
1196c2625e6eSJosh Paetzel #define BMC_FILT_MULTICAST_IPV6_RAS ((uint32_t)(1 << 7))
1197c2625e6eSJosh Paetzel #define BMC_FILT_MULTICAST ((uint32_t)(1 << 8))
1198c2625e6eSJosh Paetzel
1199c2625e6eSJosh Paetzel #define ND_ROUTER_ADVERT 134
1200c2625e6eSJosh Paetzel #define ND_NEIGHBOR_ADVERT 136
1201c2625e6eSJosh Paetzel
1202c2625e6eSJosh Paetzel #define is_mc_allowed_on_bmc(sc, eh) \
1203c2625e6eSJosh Paetzel (!is_multicast_filt_enabled(sc) && \
1204c2625e6eSJosh Paetzel ETHER_IS_MULTICAST(eh->ether_dhost) && \
1205c2625e6eSJosh Paetzel !ETHER_IS_BROADCAST(eh->ether_dhost))
1206c2625e6eSJosh Paetzel
1207c2625e6eSJosh Paetzel #define is_bc_allowed_on_bmc(sc, eh) \
1208c2625e6eSJosh Paetzel (!is_broadcast_filt_enabled(sc) && \
1209c2625e6eSJosh Paetzel ETHER_IS_BROADCAST(eh->ether_dhost))
1210c2625e6eSJosh Paetzel
1211c2625e6eSJosh Paetzel #define is_arp_allowed_on_bmc(sc, et) \
1212c2625e6eSJosh Paetzel (is_arp(et) && is_arp_filt_enabled(sc))
1213c2625e6eSJosh Paetzel
1214c2625e6eSJosh Paetzel #define is_arp(et) (et == ETHERTYPE_ARP)
1215c2625e6eSJosh Paetzel
1216c2625e6eSJosh Paetzel #define is_arp_filt_enabled(sc) \
1217c2625e6eSJosh Paetzel (sc->bmc_filt_mask & (BMC_FILT_BROADCAST_ARP))
1218c2625e6eSJosh Paetzel
1219c2625e6eSJosh Paetzel #define is_dhcp_client_filt_enabled(sc) \
1220c2625e6eSJosh Paetzel (sc->bmc_filt_mask & BMC_FILT_BROADCAST_DHCP_CLIENT)
1221c2625e6eSJosh Paetzel
1222c2625e6eSJosh Paetzel #define is_dhcp_srvr_filt_enabled(sc) \
1223c2625e6eSJosh Paetzel (sc->bmc_filt_mask & BMC_FILT_BROADCAST_DHCP_SERVER)
1224c2625e6eSJosh Paetzel
1225c2625e6eSJosh Paetzel #define is_nbios_filt_enabled(sc) \
1226c2625e6eSJosh Paetzel (sc->bmc_filt_mask & BMC_FILT_BROADCAST_NET_BIOS)
1227c2625e6eSJosh Paetzel
1228c2625e6eSJosh Paetzel #define is_ipv6_na_filt_enabled(sc) \
1229c2625e6eSJosh Paetzel (sc->bmc_filt_mask & \
1230c2625e6eSJosh Paetzel BMC_FILT_MULTICAST_IPV6_NEIGH_ADVER)
1231c2625e6eSJosh Paetzel
1232c2625e6eSJosh Paetzel #define is_ipv6_ra_filt_enabled(sc) \
1233c2625e6eSJosh Paetzel (sc->bmc_filt_mask & BMC_FILT_MULTICAST_IPV6_RA)
1234c2625e6eSJosh Paetzel
1235c2625e6eSJosh Paetzel #define is_ipv6_ras_filt_enabled(sc) \
1236c2625e6eSJosh Paetzel (sc->bmc_filt_mask & BMC_FILT_MULTICAST_IPV6_RAS)
1237c2625e6eSJosh Paetzel
1238c2625e6eSJosh Paetzel #define is_broadcast_filt_enabled(sc) \
1239c2625e6eSJosh Paetzel (sc->bmc_filt_mask & BMC_FILT_BROADCAST)
1240c2625e6eSJosh Paetzel
1241c2625e6eSJosh Paetzel #define is_multicast_filt_enabled(sc) \
1242c2625e6eSJosh Paetzel (sc->bmc_filt_mask & BMC_FILT_MULTICAST)
1243c2625e6eSJosh Paetzel
1244c2625e6eSJosh Paetzel #define is_os2bmc_enabled(sc) (sc->flags & OCE_FLAGS_OS2BMC)
1245c2625e6eSJosh Paetzel
1246c2625e6eSJosh Paetzel #define LRO_FLAGS_HASH_MODE 0x00000001
1247c2625e6eSJosh Paetzel #define LRO_FLAGS_RSS_MODE 0x00000004
1248c2625e6eSJosh Paetzel #define LRO_FLAGS_CLSC_IPV4 0x00000010
1249c2625e6eSJosh Paetzel #define LRO_FLAGS_CLSC_IPV6 0x00000020
1250c2625e6eSJosh Paetzel #define NIC_RQ_FLAGS_RSS 0x0001
1251c2625e6eSJosh Paetzel #define NIC_RQ_FLAGS_LRO 0x0020
1252