2011-02-18 08:00:26 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2011 Chelsio Communications, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
* Written by: Navdeep Parhar <np@FreeBSD.org>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __T4_ADAPTER_H__
|
|
|
|
#define __T4_ADAPTER_H__
|
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
#include <sys/kernel.h>
|
2011-02-18 08:00:26 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <sys/types.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <sys/lock.h>
|
2011-02-18 08:00:26 +00:00
|
|
|
#include <sys/malloc.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <sys/rwlock.h>
|
|
|
|
#include <sys/sx.h>
|
|
|
|
#include <vm/uma.h>
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
#include <net/if.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <net/if_var.h>
|
2011-02-18 08:00:26 +00:00
|
|
|
#include <net/if_media.h>
|
2012-05-24 23:03:23 +00:00
|
|
|
#include <netinet/in.h>
|
2011-02-18 08:00:26 +00:00
|
|
|
#include <netinet/tcp_lro.h>
|
|
|
|
|
|
|
|
#include "offload.h"
|
2014-05-27 18:18:41 +00:00
|
|
|
#include "common/t4_msg.h"
|
2011-12-16 02:09:51 +00:00
|
|
|
#include "firmware/t4fw_interface.h"
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
MALLOC_DECLARE(M_CXGBE);
|
|
|
|
#define CXGBE_UNIMPLEMENTED(s) \
|
|
|
|
panic("%s (%s, line %d) not implemented yet.", s, __FILE__, __LINE__)
|
|
|
|
|
|
|
|
#if defined(__i386__) || defined(__amd64__)
|
|
|
|
static __inline void
|
|
|
|
prefetch(void *x)
|
|
|
|
{
|
|
|
|
__asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define prefetch(x)
|
|
|
|
#endif
|
|
|
|
|
2012-02-07 06:21:59 +00:00
|
|
|
#ifndef SYSCTL_ADD_UQUAD
|
|
|
|
#define SYSCTL_ADD_UQUAD SYSCTL_ADD_QUAD
|
|
|
|
#define sysctl_handle_64 sysctl_handle_quad
|
|
|
|
#define CTLTYPE_U64 CTLTYPE_QUAD
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (__FreeBSD_version >= 900030) || \
|
|
|
|
((__FreeBSD_version >= 802507) && (__FreeBSD_version < 900000))
|
|
|
|
#define SBUF_DRAIN 1
|
|
|
|
#endif
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
#ifdef __amd64__
|
|
|
|
/* XXX: need systemwide bus_space_read_8/bus_space_write_8 */
|
|
|
|
static __inline uint64_t
|
|
|
|
t4_bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle,
|
|
|
|
bus_size_t offset)
|
|
|
|
{
|
2011-03-05 03:01:14 +00:00
|
|
|
KASSERT(tag == X86_BUS_SPACE_MEM,
|
|
|
|
("%s: can only handle mem space", __func__));
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
return (*(volatile uint64_t *)(handle + offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
t4_bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh,
|
|
|
|
bus_size_t offset, uint64_t value)
|
|
|
|
{
|
2011-03-05 03:01:14 +00:00
|
|
|
KASSERT(tag == X86_BUS_SPACE_MEM,
|
|
|
|
("%s: can only handle mem space", __func__));
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
*(volatile uint64_t *)(bsh + offset) = value;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static __inline uint64_t
|
|
|
|
t4_bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle,
|
|
|
|
bus_size_t offset)
|
|
|
|
{
|
|
|
|
return (uint64_t)bus_space_read_4(tag, handle, offset) +
|
|
|
|
((uint64_t)bus_space_read_4(tag, handle, offset + 4) << 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
t4_bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh,
|
|
|
|
bus_size_t offset, uint64_t value)
|
|
|
|
{
|
|
|
|
bus_space_write_4(tag, bsh, offset, value);
|
|
|
|
bus_space_write_4(tag, bsh, offset + 4, value >> 32);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct adapter;
|
|
|
|
typedef struct adapter adapter_t;
|
|
|
|
|
|
|
|
enum {
|
2014-08-02 00:56:34 +00:00
|
|
|
/*
|
|
|
|
* All ingress queues use this entry size. Note that the firmware event
|
|
|
|
* queue and any iq expecting CPL_RX_PKT in the descriptor needs this to
|
|
|
|
* be at least 64.
|
|
|
|
*/
|
|
|
|
IQ_ESIZE = 64,
|
|
|
|
|
|
|
|
/* Default queue sizes for all kinds of ingress queues */
|
2011-02-18 08:00:26 +00:00
|
|
|
FW_IQ_QSIZE = 256,
|
|
|
|
RX_IQ_QSIZE = 1024,
|
|
|
|
|
2014-08-02 00:56:34 +00:00
|
|
|
/* All egress queues use this entry size */
|
|
|
|
EQ_ESIZE = 64,
|
|
|
|
|
|
|
|
/* Default queue sizes for all kinds of egress queues */
|
|
|
|
CTRL_EQ_QSIZE = 128,
|
|
|
|
TX_EQ_QSIZE = 1024,
|
2011-02-18 08:00:26 +00:00
|
|
|
|
2011-03-08 03:04:07 +00:00
|
|
|
#if MJUMPAGESIZE != MCLBYTES
|
2014-03-18 20:14:13 +00:00
|
|
|
SW_ZONE_SIZES = 4, /* cluster, jumbop, jumbo9k, jumbo16k */
|
2011-03-08 03:04:07 +00:00
|
|
|
#else
|
2014-03-18 20:14:13 +00:00
|
|
|
SW_ZONE_SIZES = 3, /* cluster, jumbo9k, jumbo16k */
|
2011-03-08 03:04:07 +00:00
|
|
|
#endif
|
2014-12-06 01:47:38 +00:00
|
|
|
CL_METADATA_SIZE = CACHE_LINE_SIZE,
|
2011-02-18 08:00:26 +00:00
|
|
|
|
2014-08-02 00:56:34 +00:00
|
|
|
SGE_MAX_WR_NDESC = SGE_MAX_WR_LEN / EQ_ESIZE, /* max WR size in desc */
|
2011-02-18 08:00:26 +00:00
|
|
|
TX_SGL_SEGS = 36,
|
|
|
|
TX_WR_FLITS = SGE_MAX_WR_LEN / 8
|
|
|
|
};
|
|
|
|
|
2011-03-24 01:03:01 +00:00
|
|
|
enum {
|
|
|
|
/* adapter intr_type */
|
|
|
|
INTR_INTX = (1 << 0),
|
|
|
|
INTR_MSI = (1 << 1),
|
|
|
|
INTR_MSIX = (1 << 2)
|
|
|
|
};
|
|
|
|
|
2014-05-27 18:18:41 +00:00
|
|
|
enum {
|
|
|
|
XGMAC_MTU = (1 << 0),
|
|
|
|
XGMAC_PROMISC = (1 << 1),
|
|
|
|
XGMAC_ALLMULTI = (1 << 2),
|
|
|
|
XGMAC_VLANEX = (1 << 3),
|
|
|
|
XGMAC_UCADDR = (1 << 4),
|
|
|
|
XGMAC_MCADDRS = (1 << 5),
|
|
|
|
|
|
|
|
XGMAC_ALL = 0xffff
|
|
|
|
};
|
|
|
|
|
2013-01-10 23:56:50 +00:00
|
|
|
enum {
|
|
|
|
/* flags understood by begin_synchronized_op */
|
|
|
|
HOLD_LOCK = (1 << 0),
|
|
|
|
SLEEP_OK = (1 << 1),
|
|
|
|
INTR_OK = (1 << 2),
|
|
|
|
|
|
|
|
/* flags understood by end_synchronized_op */
|
|
|
|
LOCK_HELD = HOLD_LOCK,
|
|
|
|
};
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
enum {
|
|
|
|
/* adapter flags */
|
|
|
|
FULL_INIT_DONE = (1 << 0),
|
|
|
|
FW_OK = (1 << 1),
|
2014-05-27 18:18:41 +00:00
|
|
|
/* INTR_DIRECT = (1 << 2), No longer used. */
|
2011-12-16 02:09:51 +00:00
|
|
|
MASTER_PF = (1 << 3),
|
|
|
|
ADAP_SYSCTL_CTX = (1 << 4),
|
2012-06-19 07:34:13 +00:00
|
|
|
TOM_INIT_DONE = (1 << 5),
|
2013-08-30 01:45:36 +00:00
|
|
|
BUF_PACKING_OK = (1 << 6),
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
CXGBE_BUSY = (1 << 9),
|
|
|
|
|
|
|
|
/* port flags */
|
|
|
|
DOOMED = (1 << 0),
|
2011-12-16 02:09:51 +00:00
|
|
|
PORT_INIT_DONE = (1 << 1),
|
|
|
|
PORT_SYSCTL_CTX = (1 << 2),
|
Add support for packet-sniffing tracers to cxgbe(4). This works with
all T4 and T5 based cards and is useful for analyzing TSO, LRO, TOE, and
for general purpose monitoring without tapping any cxgbe or cxl ifnet
directly.
Tracers on the T4/T5 chips provide access to Ethernet frames exactly as
they were received from or transmitted on the wire. On transmit, a
tracer will capture a frame after TSO segmentation, hw VLAN tag
insertion, hw L3 & L4 checksum insertion, etc. It will also capture
frames generated by the TCP offload engine (TOE traffic is normally
invisible to the kernel). On receive, a tracer will capture a frame
before hw VLAN extraction, runt filtering, other badness filtering,
before the steering/drop/L2-rewrite filters or the TOE have had a go at
it, and of course before sw LRO in the driver.
There are 4 tracers on a chip. A tracer can trace only in one direction
(tx or rx). For now cxgbetool will set up tracers to capture the first
128B of every transmitted or received frame on a given port. This is a
small subset of what the hardware can do. A pseudo ifnet with the same
name as the nexus driver (t4nex0 or t5nex0) will be created for tracing.
The data delivered to this ifnet is an additional copy made inside the
chip. Normal delivery to cxgbe<n> or cxl<n> will be made as usual.
/* watch cxl0, which is the first port hanging off t5nex0. */
# cxgbetool t5nex0 tracer 0 tx0 (watch what cxl0 is transmitting)
# cxgbetool t5nex0 tracer 1 rx0 (watch what cxl0 is receiving)
# cxgbetool t5nex0 tracer list
# tcpdump -i t5nex0 <== all that cxl0 sees and puts on the wire
If you were doing TSO, a tcpdump on cxl0 may have shown you ~64K
"frames" with no L3/L4 checksum but this will show you the frames that
were actually transmitted.
/* all done */
# cxgbetool t5nex0 tracer 0 disable
# cxgbetool t5nex0 tracer 1 disable
# cxgbetool t5nex0 tracer list
# ifconfig t5nex0 destroy
2013-07-26 22:04:11 +00:00
|
|
|
HAS_TRACEQ = (1 << 3),
|
2014-05-27 18:18:41 +00:00
|
|
|
INTR_RXQ = (1 << 4), /* All NIC rxq's take interrupts */
|
|
|
|
INTR_OFLD_RXQ = (1 << 5), /* All TOE rxq's take interrupts */
|
|
|
|
INTR_NM_RXQ = (1 << 6), /* All netmap rxq's take interrupts */
|
|
|
|
INTR_ALL = (INTR_RXQ | INTR_OFLD_RXQ | INTR_NM_RXQ),
|
2011-02-18 08:00:26 +00:00
|
|
|
};
|
|
|
|
|
2013-01-10 23:56:50 +00:00
|
|
|
#define IS_DOOMED(pi) ((pi)->flags & DOOMED)
|
|
|
|
#define SET_DOOMED(pi) do {(pi)->flags |= DOOMED;} while (0)
|
|
|
|
#define IS_BUSY(sc) ((sc)->flags & CXGBE_BUSY)
|
|
|
|
#define SET_BUSY(sc) do {(sc)->flags |= CXGBE_BUSY;} while (0)
|
|
|
|
#define CLR_BUSY(sc) do {(sc)->flags &= ~CXGBE_BUSY;} while (0)
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
struct port_info {
|
|
|
|
device_t dev;
|
|
|
|
struct adapter *adapter;
|
|
|
|
|
|
|
|
struct ifnet *ifp;
|
|
|
|
struct ifmedia media;
|
|
|
|
|
|
|
|
struct mtx pi_lock;
|
|
|
|
char lockname[16];
|
|
|
|
unsigned long flags;
|
|
|
|
int if_flags;
|
|
|
|
|
2013-12-08 17:47:37 +00:00
|
|
|
uint16_t *rss;
|
2011-02-18 08:00:26 +00:00
|
|
|
uint16_t viid;
|
|
|
|
int16_t xact_addr_filt;/* index of exact MAC address filter */
|
|
|
|
uint16_t rss_size; /* size of VI's RSS table slice */
|
|
|
|
uint8_t lport; /* associated offload logical port */
|
|
|
|
int8_t mdio_addr;
|
|
|
|
uint8_t port_type;
|
|
|
|
uint8_t mod_type;
|
|
|
|
uint8_t port_id;
|
|
|
|
uint8_t tx_chan;
|
2014-02-06 03:30:12 +00:00
|
|
|
uint8_t rx_chan_map; /* rx MPS channel bitmap */
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
/* These need to be int as they are used in sysctl */
|
|
|
|
int ntxq; /* # of tx queues */
|
|
|
|
int first_txq; /* index of first tx queue */
|
2014-02-06 18:40:38 +00:00
|
|
|
int rsrv_noflowq; /* Reserve queue 0 for non-flowid packets */
|
2011-02-18 08:00:26 +00:00
|
|
|
int nrxq; /* # of rx queues */
|
|
|
|
int first_rxq; /* index of first rx queue */
|
2012-06-19 07:34:13 +00:00
|
|
|
#ifdef TCP_OFFLOAD
|
2011-12-16 02:09:51 +00:00
|
|
|
int nofldtxq; /* # of offload tx queues */
|
|
|
|
int first_ofld_txq; /* index of first offload tx queue */
|
|
|
|
int nofldrxq; /* # of offload rx queues */
|
|
|
|
int first_ofld_rxq; /* index of first offload rx queue */
|
2014-05-27 18:18:41 +00:00
|
|
|
#endif
|
|
|
|
#ifdef DEV_NETMAP
|
|
|
|
int nnmtxq; /* # of netmap tx queues */
|
|
|
|
int first_nm_txq; /* index of first netmap tx queue */
|
|
|
|
int nnmrxq; /* # of netmap rx queues */
|
|
|
|
int first_nm_rxq; /* index of first netmap rx queue */
|
|
|
|
|
|
|
|
struct ifnet *nm_ifp;
|
|
|
|
struct ifmedia nm_media;
|
|
|
|
int nmif_flags;
|
|
|
|
uint16_t nm_viid;
|
|
|
|
int16_t nm_xact_addr_filt;
|
|
|
|
uint16_t nm_rss_size; /* size of netmap VI's RSS table slice */
|
2011-12-16 02:09:51 +00:00
|
|
|
#endif
|
2011-02-18 08:00:26 +00:00
|
|
|
int tmr_idx;
|
|
|
|
int pktc_idx;
|
|
|
|
int qsize_rxq;
|
|
|
|
int qsize_txq;
|
|
|
|
|
2013-07-05 01:53:51 +00:00
|
|
|
int linkdnrc;
|
2011-02-18 08:00:26 +00:00
|
|
|
struct link_config link_cfg;
|
2014-09-27 05:50:31 +00:00
|
|
|
|
|
|
|
struct timeval last_refreshed;
|
|
|
|
struct port_stats stats;
|
|
|
|
u_int tnl_cong_drops;
|
2011-02-18 08:00:26 +00:00
|
|
|
|
2012-06-19 07:34:13 +00:00
|
|
|
eventhandler_tag vlan_c;
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
struct callout tick;
|
2011-12-16 02:09:51 +00:00
|
|
|
struct sysctl_ctx_list ctx; /* from ifconfig up to driver detach */
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
uint8_t hw_addr[ETHER_ADDR_LEN]; /* factory MAC address, won't change */
|
|
|
|
};
|
|
|
|
|
2014-03-18 20:14:13 +00:00
|
|
|
/* Where the cluster came from, how it has been carved up. */
|
|
|
|
struct cluster_layout {
|
|
|
|
int8_t zidx;
|
|
|
|
int8_t hwidx;
|
|
|
|
uint16_t region1; /* mbufs laid out within this region */
|
|
|
|
/* region2 is the DMA region */
|
|
|
|
uint16_t region3; /* cluster_metadata within this region */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cluster_metadata {
|
|
|
|
u_int refcount;
|
2011-02-18 08:00:26 +00:00
|
|
|
#ifdef INVARIANTS
|
2014-03-18 20:14:13 +00:00
|
|
|
struct fl_sdesc *sd; /* For debug only. Could easily be stale */
|
2011-02-18 08:00:26 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2014-03-18 20:14:13 +00:00
|
|
|
struct fl_sdesc {
|
|
|
|
caddr_t cl;
|
2014-07-22 02:02:39 +00:00
|
|
|
uint16_t nmbuf; /* # of driver originated mbufs with ref on cluster */
|
2014-03-18 20:14:13 +00:00
|
|
|
struct cluster_layout cll;
|
|
|
|
};
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
struct tx_desc {
|
|
|
|
__be64 flit[8];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tx_map {
|
|
|
|
struct mbuf *m;
|
|
|
|
bus_dmamap_t map;
|
|
|
|
};
|
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
/* DMA maps used for tx */
|
|
|
|
struct tx_maps {
|
|
|
|
struct tx_map *maps;
|
|
|
|
uint32_t map_total; /* # of DMA maps */
|
|
|
|
uint32_t map_pidx; /* next map to be used */
|
|
|
|
uint32_t map_cidx; /* reclaimed up to this index */
|
|
|
|
uint32_t map_avail; /* # of available maps */
|
|
|
|
};
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
struct tx_sdesc {
|
|
|
|
uint8_t desc_used; /* # of hardware descriptors used by the WR */
|
2011-04-19 22:08:28 +00:00
|
|
|
uint8_t credits; /* NIC txq: # of frames sent out in the WR */
|
2011-02-18 08:00:26 +00:00
|
|
|
};
|
|
|
|
|
2014-08-02 00:56:34 +00:00
|
|
|
|
|
|
|
#define IQ_PAD (IQ_ESIZE - sizeof(struct rsp_ctrl) - sizeof(struct rss_header))
|
|
|
|
struct iq_desc {
|
|
|
|
struct rss_header rss;
|
|
|
|
uint8_t cpl[IQ_PAD];
|
|
|
|
struct rsp_ctrl rsp;
|
|
|
|
};
|
|
|
|
#undef IQ_PAD
|
|
|
|
CTASSERT(sizeof(struct iq_desc) == IQ_ESIZE);
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
enum {
|
|
|
|
/* iq flags */
|
2011-12-16 02:09:51 +00:00
|
|
|
IQ_ALLOCATED = (1 << 0), /* firmware resources allocated */
|
|
|
|
IQ_HAS_FL = (1 << 1), /* iq associated with a freelist */
|
|
|
|
IQ_INTR = (1 << 2), /* iq takes direct interrupt */
|
|
|
|
IQ_LRO_ENABLED = (1 << 3), /* iq is an eth rxq with LRO enabled */
|
2011-04-15 03:09:27 +00:00
|
|
|
|
|
|
|
/* iq state */
|
|
|
|
IQS_DISABLED = 0,
|
|
|
|
IQS_BUSY = 1,
|
|
|
|
IQS_IDLE = 2,
|
2011-02-18 08:00:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ingress Queue: T4 is producer, driver is consumer.
|
|
|
|
*/
|
|
|
|
struct sge_iq {
|
2011-03-05 03:42:03 +00:00
|
|
|
uint32_t flags;
|
2011-12-16 02:09:51 +00:00
|
|
|
volatile int state;
|
2011-03-05 03:42:03 +00:00
|
|
|
struct adapter *adapter;
|
2014-08-02 00:56:34 +00:00
|
|
|
struct iq_desc *desc; /* KVA of descriptor ring */
|
|
|
|
int8_t intr_pktc_idx; /* packet count threshold index */
|
2011-02-18 08:00:26 +00:00
|
|
|
uint8_t gen; /* generation bit */
|
|
|
|
uint8_t intr_params; /* interrupt holdoff parameters */
|
2011-12-16 02:09:51 +00:00
|
|
|
uint8_t intr_next; /* XXX: holdoff for next interrupt */
|
2011-02-18 08:00:26 +00:00
|
|
|
uint16_t qsize; /* size (# of entries) of the queue */
|
2014-08-02 00:56:34 +00:00
|
|
|
uint16_t sidx; /* index of the entry with the status page */
|
2011-02-18 08:00:26 +00:00
|
|
|
uint16_t cidx; /* consumer index */
|
2011-12-16 02:09:51 +00:00
|
|
|
uint16_t cntxt_id; /* SGE context id for the iq */
|
2014-08-02 00:56:34 +00:00
|
|
|
uint16_t abs_id; /* absolute SGE id for the iq */
|
2011-12-16 02:09:51 +00:00
|
|
|
|
|
|
|
STAILQ_ENTRY(sge_iq) link;
|
2014-08-02 00:56:34 +00:00
|
|
|
|
|
|
|
bus_dma_tag_t desc_tag;
|
|
|
|
bus_dmamap_t desc_map;
|
|
|
|
bus_addr_t ba; /* bus address of descriptor ring */
|
2011-02-18 08:00:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2011-12-16 02:09:51 +00:00
|
|
|
EQ_CTRL = 1,
|
|
|
|
EQ_ETH = 2,
|
2012-06-19 07:34:13 +00:00
|
|
|
#ifdef TCP_OFFLOAD
|
2011-12-16 02:09:51 +00:00
|
|
|
EQ_OFLD = 3,
|
|
|
|
#endif
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
/* eq flags */
|
2011-12-16 02:09:51 +00:00
|
|
|
EQ_TYPEMASK = 7, /* 3 lsbits hold the type */
|
|
|
|
EQ_ALLOCATED = (1 << 3), /* firmware resources allocated */
|
|
|
|
EQ_DOOMED = (1 << 4), /* about to be destroyed */
|
|
|
|
EQ_CRFLUSHED = (1 << 5), /* expecting an update from SGE */
|
|
|
|
EQ_STALLED = (1 << 6), /* out of hw descriptors or dmamaps */
|
2011-02-18 08:00:26 +00:00
|
|
|
};
|
|
|
|
|
2013-03-30 02:26:20 +00:00
|
|
|
/* Listed in order of preference. Update t4_sysctls too if you change these */
|
2013-04-11 22:49:29 +00:00
|
|
|
enum {DOORBELL_UDB, DOORBELL_WCWR, DOORBELL_UDBWC, DOORBELL_KDB};
|
2013-03-30 02:26:20 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
/*
|
|
|
|
* Egress Queue: driver is producer, T4 is consumer.
|
|
|
|
*
|
|
|
|
* Note: A free list is an egress queue (driver produces the buffers and T4
|
|
|
|
* consumes them) but it's special enough to have its own struct (see sge_fl).
|
|
|
|
*/
|
|
|
|
struct sge_eq {
|
2011-12-16 02:09:51 +00:00
|
|
|
unsigned int flags; /* MUST be first */
|
|
|
|
unsigned int cntxt_id; /* SGE context id for the eq */
|
2011-02-18 08:00:26 +00:00
|
|
|
bus_dma_tag_t desc_tag;
|
|
|
|
bus_dmamap_t desc_map;
|
|
|
|
char lockname[16];
|
|
|
|
struct mtx eq_lock;
|
|
|
|
|
|
|
|
struct tx_desc *desc; /* KVA of descriptor ring */
|
|
|
|
bus_addr_t ba; /* bus address of descriptor ring */
|
|
|
|
struct sge_qstat *spg; /* status page, for convenience */
|
2014-05-27 18:18:41 +00:00
|
|
|
uint16_t doorbells;
|
2013-03-30 02:26:20 +00:00
|
|
|
volatile uint32_t *udb; /* KVA of doorbell (lies within BAR2) */
|
|
|
|
u_int udb_qid; /* relative qid within the doorbell page */
|
2011-02-18 08:00:26 +00:00
|
|
|
uint16_t cap; /* max # of desc, for convenience */
|
|
|
|
uint16_t avail; /* available descriptors, for convenience */
|
|
|
|
uint16_t qsize; /* size (# of entries) of the queue */
|
|
|
|
uint16_t cidx; /* consumer idx (desc idx) */
|
|
|
|
uint16_t pidx; /* producer idx (desc idx) */
|
|
|
|
uint16_t pending; /* # of descriptors used since last doorbell */
|
2011-03-05 03:18:56 +00:00
|
|
|
uint16_t iqid; /* iq that gets egr_update for the eq */
|
2011-12-16 02:09:51 +00:00
|
|
|
uint8_t tx_chan; /* tx channel used by the eq */
|
|
|
|
struct task tx_task;
|
|
|
|
struct callout tx_callout;
|
|
|
|
|
|
|
|
/* stats */
|
|
|
|
|
|
|
|
uint32_t egr_update; /* # of SGE_EGR_UPDATE notifications for eq */
|
|
|
|
uint32_t unstalled; /* recovered from stall */
|
|
|
|
};
|
|
|
|
|
2014-03-18 20:14:13 +00:00
|
|
|
struct sw_zone_info {
|
|
|
|
uma_zone_t zone; /* zone that this cluster comes from */
|
|
|
|
int size; /* size of cluster: 2K, 4K, 9K, 16K, etc. */
|
|
|
|
int type; /* EXT_xxx type of the cluster */
|
|
|
|
int8_t head_hwidx;
|
|
|
|
int8_t tail_hwidx;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hw_buf_info {
|
|
|
|
int8_t zidx; /* backpointer to zone; -ve means unused */
|
|
|
|
int8_t next; /* next hwidx for this zone; -1 means no more */
|
|
|
|
int size;
|
2013-08-30 01:45:36 +00:00
|
|
|
};
|
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
enum {
|
|
|
|
FL_STARVING = (1 << 0), /* on the adapter's list of starving fl's */
|
|
|
|
FL_DOOMED = (1 << 1), /* about to be destroyed */
|
2013-08-30 01:45:36 +00:00
|
|
|
FL_BUF_PACKING = (1 << 2), /* buffer packing enabled */
|
2014-08-02 06:55:36 +00:00
|
|
|
FL_BUF_RESUME = (1 << 3), /* resume from the middle of the frame */
|
2011-04-19 22:08:28 +00:00
|
|
|
};
|
2011-02-18 08:00:26 +00:00
|
|
|
|
2014-08-02 06:55:36 +00:00
|
|
|
#define FL_RUNNING_LOW(fl) \
|
|
|
|
(IDXDIFF(fl->dbidx * 8, fl->cidx, fl->sidx * 8) <= fl->lowat)
|
|
|
|
#define FL_NOT_RUNNING_LOW(fl) \
|
|
|
|
(IDXDIFF(fl->dbidx * 8, fl->cidx, fl->sidx * 8) >= 2 * fl->lowat)
|
2011-12-16 02:09:51 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
struct sge_fl {
|
|
|
|
struct mtx fl_lock;
|
|
|
|
__be64 *desc; /* KVA of descriptor ring, ptr to addresses */
|
|
|
|
struct fl_sdesc *sdesc; /* KVA of software descriptor ring */
|
2014-08-02 06:55:36 +00:00
|
|
|
struct cluster_layout cll_def; /* default refill zone, layout */
|
|
|
|
uint16_t lowat; /* # of buffers <= this means fl needs help */
|
|
|
|
int flags;
|
|
|
|
uint16_t buf_boundary;
|
2014-03-18 20:14:13 +00:00
|
|
|
|
2014-08-02 06:55:36 +00:00
|
|
|
/* The 16b idx all deal with hw descriptors */
|
|
|
|
uint16_t dbidx; /* hw pidx after last doorbell */
|
|
|
|
uint16_t sidx; /* index of status page */
|
|
|
|
volatile uint16_t hw_cidx;
|
|
|
|
|
|
|
|
/* The 32b idx are all buffer idx, not hardware descriptor idx */
|
|
|
|
uint32_t cidx; /* consumer index */
|
|
|
|
uint32_t pidx; /* producer index */
|
|
|
|
|
|
|
|
uint32_t dbval;
|
|
|
|
u_int rx_offset; /* offset in fl buf (when buffer packing) */
|
|
|
|
volatile uint32_t *udb;
|
2014-03-18 20:14:13 +00:00
|
|
|
|
|
|
|
uint64_t mbuf_allocated;/* # of mbuf allocated from zone_mbuf */
|
|
|
|
uint64_t mbuf_inlined; /* # of mbuf created within clusters */
|
|
|
|
uint64_t cl_allocated; /* # of clusters allocated */
|
|
|
|
uint64_t cl_recycled; /* # of clusters recycled */
|
|
|
|
uint64_t cl_fast_recycled; /* # of clusters recycled (fast) */
|
2014-08-02 06:55:36 +00:00
|
|
|
|
|
|
|
/* These 3 are valid when FL_BUF_RESUME is set, stale otherwise. */
|
|
|
|
struct mbuf *m0;
|
|
|
|
struct mbuf **pnext;
|
|
|
|
u_int remaining;
|
|
|
|
|
|
|
|
uint16_t qsize; /* # of hw descriptors (status page included) */
|
|
|
|
uint16_t cntxt_id; /* SGE context id for the freelist */
|
|
|
|
TAILQ_ENTRY(sge_fl) link; /* All starving freelists */
|
|
|
|
bus_dma_tag_t desc_tag;
|
|
|
|
bus_dmamap_t desc_map;
|
|
|
|
char lockname[16];
|
|
|
|
bus_addr_t ba; /* bus address of descriptor ring */
|
|
|
|
struct cluster_layout cll_alt; /* alternate refill zone, layout */
|
2011-02-18 08:00:26 +00:00
|
|
|
};
|
|
|
|
|
2011-04-19 22:08:28 +00:00
|
|
|
/* txq: SGE egress queue + what's needed for Ethernet NIC */
|
2011-02-18 08:00:26 +00:00
|
|
|
struct sge_txq {
|
|
|
|
struct sge_eq eq; /* MUST be first */
|
2011-04-19 22:08:28 +00:00
|
|
|
|
|
|
|
struct ifnet *ifp; /* the interface this txq belongs to */
|
|
|
|
bus_dma_tag_t tx_tag; /* tag for transmit buffers */
|
|
|
|
struct buf_ring *br; /* tx buffer ring */
|
|
|
|
struct tx_sdesc *sdesc; /* KVA of software descriptor ring */
|
2011-02-18 08:00:26 +00:00
|
|
|
struct mbuf *m; /* held up due to temporary resource shortage */
|
2011-03-05 03:06:38 +00:00
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
struct tx_maps txmaps;
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
/* stats for common events first */
|
|
|
|
|
|
|
|
uint64_t txcsum; /* # of times hardware assisted with checksum */
|
2012-06-29 19:51:06 +00:00
|
|
|
uint64_t tso_wrs; /* # of TSO work requests */
|
2011-02-18 08:00:26 +00:00
|
|
|
uint64_t vlan_insertion;/* # of times VLAN tag was inserted */
|
|
|
|
uint64_t imm_wrs; /* # of work requests with immediate data */
|
|
|
|
uint64_t sgl_wrs; /* # of work requests with direct SGL */
|
|
|
|
uint64_t txpkt_wrs; /* # of txpkt work requests (not coalesced) */
|
|
|
|
uint64_t txpkts_wrs; /* # of coalesced tx work requests */
|
|
|
|
uint64_t txpkts_pkts; /* # of frames in coalesced tx work requests */
|
|
|
|
|
|
|
|
/* stats for not-that-common events */
|
|
|
|
|
|
|
|
uint32_t no_dmamap; /* no DMA map to load the mbuf */
|
|
|
|
uint32_t no_desc; /* out of hardware descriptors */
|
2011-04-19 22:08:28 +00:00
|
|
|
} __aligned(CACHE_LINE_SIZE);
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
/* rxq: SGE ingress queue + SGE free list + miscellaneous items */
|
|
|
|
struct sge_rxq {
|
|
|
|
struct sge_iq iq; /* MUST be first */
|
2011-12-16 02:09:51 +00:00
|
|
|
struct sge_fl fl; /* MUST follow iq */
|
2011-02-18 08:00:26 +00:00
|
|
|
|
2011-03-05 03:27:14 +00:00
|
|
|
struct ifnet *ifp; /* the interface this rxq belongs to */
|
2012-06-29 19:51:06 +00:00
|
|
|
#if defined(INET) || defined(INET6)
|
2011-02-18 08:00:26 +00:00
|
|
|
struct lro_ctrl lro; /* LRO state */
|
2011-03-05 03:42:03 +00:00
|
|
|
#endif
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
/* stats for common events first */
|
|
|
|
|
|
|
|
uint64_t rxcsum; /* # of times hardware assisted with checksum */
|
|
|
|
uint64_t vlan_extraction;/* # of times VLAN tag was extracted */
|
|
|
|
|
|
|
|
/* stats for not-that-common events */
|
|
|
|
|
|
|
|
} __aligned(CACHE_LINE_SIZE);
|
|
|
|
|
2012-06-19 07:34:13 +00:00
|
|
|
static inline struct sge_rxq *
|
|
|
|
iq_to_rxq(struct sge_iq *iq)
|
|
|
|
{
|
|
|
|
|
2012-10-19 13:26:40 +00:00
|
|
|
return (__containerof(iq, struct sge_rxq, iq));
|
2012-06-19 07:34:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef TCP_OFFLOAD
|
2011-12-16 02:09:51 +00:00
|
|
|
/* ofld_rxq: SGE ingress queue + SGE free list + miscellaneous items */
|
|
|
|
struct sge_ofld_rxq {
|
|
|
|
struct sge_iq iq; /* MUST be first */
|
|
|
|
struct sge_fl fl; /* MUST follow iq */
|
|
|
|
} __aligned(CACHE_LINE_SIZE);
|
2012-06-19 07:34:13 +00:00
|
|
|
|
|
|
|
static inline struct sge_ofld_rxq *
|
|
|
|
iq_to_ofld_rxq(struct sge_iq *iq)
|
|
|
|
{
|
|
|
|
|
2012-10-19 13:26:40 +00:00
|
|
|
return (__containerof(iq, struct sge_ofld_rxq, iq));
|
2012-06-19 07:34:13 +00:00
|
|
|
}
|
2011-12-16 02:09:51 +00:00
|
|
|
#endif
|
|
|
|
|
2012-06-19 07:34:13 +00:00
|
|
|
struct wrqe {
|
|
|
|
STAILQ_ENTRY(wrqe) link;
|
|
|
|
struct sge_wrq *wrq;
|
|
|
|
int wr_len;
|
|
|
|
uint64_t wr[] __aligned(16);
|
|
|
|
};
|
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
/*
|
|
|
|
* wrq: SGE egress queue that is given prebuilt work requests. Both the control
|
|
|
|
* and offload tx queues are of this type.
|
|
|
|
*/
|
|
|
|
struct sge_wrq {
|
2011-04-19 22:08:28 +00:00
|
|
|
struct sge_eq eq; /* MUST be first */
|
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
struct adapter *adapter;
|
2012-06-19 07:34:13 +00:00
|
|
|
|
|
|
|
/* List of WRs held up due to lack of tx descriptors */
|
|
|
|
STAILQ_HEAD(, wrqe) wr_list;
|
2011-12-16 02:09:51 +00:00
|
|
|
|
2011-04-19 22:08:28 +00:00
|
|
|
/* stats for common events first */
|
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
uint64_t tx_wrs; /* # of tx work requests */
|
2011-04-19 22:08:28 +00:00
|
|
|
|
|
|
|
/* stats for not-that-common events */
|
|
|
|
|
|
|
|
uint32_t no_desc; /* out of hardware descriptors */
|
|
|
|
} __aligned(CACHE_LINE_SIZE);
|
|
|
|
|
2014-05-27 18:18:41 +00:00
|
|
|
|
|
|
|
#ifdef DEV_NETMAP
|
|
|
|
struct sge_nm_rxq {
|
|
|
|
struct port_info *pi;
|
|
|
|
|
2014-08-02 00:56:34 +00:00
|
|
|
struct iq_desc *iq_desc;
|
2014-05-27 18:18:41 +00:00
|
|
|
uint16_t iq_abs_id;
|
|
|
|
uint16_t iq_cntxt_id;
|
|
|
|
uint16_t iq_cidx;
|
|
|
|
uint16_t iq_sidx;
|
|
|
|
uint8_t iq_gen;
|
|
|
|
|
|
|
|
__be64 *fl_desc;
|
|
|
|
uint16_t fl_cntxt_id;
|
|
|
|
uint32_t fl_cidx;
|
|
|
|
uint32_t fl_pidx;
|
|
|
|
uint32_t fl_sidx;
|
|
|
|
uint32_t fl_db_val;
|
|
|
|
u_int fl_hwidx:4;
|
|
|
|
|
|
|
|
u_int nid; /* netmap ring # for this queue */
|
|
|
|
|
|
|
|
/* infrequently used items after this */
|
|
|
|
|
|
|
|
bus_dma_tag_t iq_desc_tag;
|
|
|
|
bus_dmamap_t iq_desc_map;
|
|
|
|
bus_addr_t iq_ba;
|
|
|
|
int intr_idx;
|
|
|
|
|
|
|
|
bus_dma_tag_t fl_desc_tag;
|
|
|
|
bus_dmamap_t fl_desc_map;
|
|
|
|
bus_addr_t fl_ba;
|
|
|
|
} __aligned(CACHE_LINE_SIZE);
|
|
|
|
|
|
|
|
struct sge_nm_txq {
|
|
|
|
struct tx_desc *desc;
|
|
|
|
uint16_t cidx;
|
|
|
|
uint16_t pidx;
|
|
|
|
uint16_t sidx;
|
|
|
|
uint16_t equiqidx; /* EQUIQ last requested at this pidx */
|
|
|
|
uint16_t equeqidx; /* EQUEQ last requested at this pidx */
|
|
|
|
uint16_t dbidx; /* pidx of the most recent doorbell */
|
|
|
|
uint16_t doorbells;
|
|
|
|
volatile uint32_t *udb;
|
|
|
|
u_int udb_qid;
|
|
|
|
u_int cntxt_id;
|
|
|
|
__be32 cpl_ctrl0; /* for convenience */
|
|
|
|
u_int nid; /* netmap ring # for this queue */
|
|
|
|
|
|
|
|
/* infrequently used items after this */
|
|
|
|
|
|
|
|
bus_dma_tag_t desc_tag;
|
|
|
|
bus_dmamap_t desc_map;
|
|
|
|
bus_addr_t ba;
|
|
|
|
int iqidx;
|
|
|
|
} __aligned(CACHE_LINE_SIZE);
|
|
|
|
#endif
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
struct sge {
|
2011-12-16 02:09:51 +00:00
|
|
|
int timer_val[SGE_NTIMERS];
|
|
|
|
int counter_val[SGE_NCOUNTERS];
|
2011-06-04 23:31:33 +00:00
|
|
|
int fl_starve_threshold;
|
2014-02-06 03:21:43 +00:00
|
|
|
int fl_starve_threshold2;
|
2013-10-14 23:32:56 +00:00
|
|
|
int eq_s_qpp;
|
|
|
|
int iq_s_qpp;
|
2011-02-18 08:00:26 +00:00
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
int nrxq; /* total # of Ethernet rx queues */
|
|
|
|
int ntxq; /* total # of Ethernet tx tx queues */
|
2012-06-19 07:34:13 +00:00
|
|
|
#ifdef TCP_OFFLOAD
|
2011-12-16 02:09:51 +00:00
|
|
|
int nofldrxq; /* total # of TOE rx queues */
|
|
|
|
int nofldtxq; /* total # of TOE tx queues */
|
2014-05-27 18:18:41 +00:00
|
|
|
#endif
|
|
|
|
#ifdef DEV_NETMAP
|
|
|
|
int nnmrxq; /* total # of netmap rx queues */
|
|
|
|
int nnmtxq; /* total # of netmap tx queues */
|
2011-12-16 02:09:51 +00:00
|
|
|
#endif
|
|
|
|
int niq; /* total # of ingress queues */
|
|
|
|
int neq; /* total # of egress queues */
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
struct sge_iq fwq; /* Firmware event queue */
|
2011-12-16 02:09:51 +00:00
|
|
|
struct sge_wrq mgmtq; /* Management queue (control queue) */
|
|
|
|
struct sge_wrq *ctrlq; /* Control queues */
|
2011-02-18 08:00:26 +00:00
|
|
|
struct sge_txq *txq; /* NIC tx queues */
|
|
|
|
struct sge_rxq *rxq; /* NIC rx queues */
|
2012-06-19 07:34:13 +00:00
|
|
|
#ifdef TCP_OFFLOAD
|
2011-12-16 02:09:51 +00:00
|
|
|
struct sge_wrq *ofld_txq; /* TOE tx queues */
|
|
|
|
struct sge_ofld_rxq *ofld_rxq; /* TOE rx queues */
|
|
|
|
#endif
|
2014-05-27 18:18:41 +00:00
|
|
|
#ifdef DEV_NETMAP
|
|
|
|
struct sge_nm_txq *nm_txq; /* netmap tx queues */
|
|
|
|
struct sge_nm_rxq *nm_rxq; /* netmap rx queues */
|
|
|
|
#endif
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
uint16_t iq_start;
|
|
|
|
int eq_start;
|
|
|
|
struct sge_iq **iqmap; /* iq->cntxt_id to iq mapping */
|
|
|
|
struct sge_eq **eqmap; /* eq->cntxt_id to eq mapping */
|
2013-08-30 01:45:36 +00:00
|
|
|
|
2014-12-06 00:13:56 +00:00
|
|
|
int pad_boundary;
|
2014-03-18 20:14:13 +00:00
|
|
|
int pack_boundary;
|
|
|
|
int8_t safe_hwidx1; /* may not have room for metadata */
|
|
|
|
int8_t safe_hwidx2; /* with room for metadata and maybe more */
|
|
|
|
struct sw_zone_info sw_zone_info[SW_ZONE_SIZES];
|
|
|
|
struct hw_buf_info hw_buf_info[SGE_FLBUF_SIZES];
|
2011-02-18 08:00:26 +00:00
|
|
|
};
|
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
struct rss_header;
|
|
|
|
typedef int (*cpl_handler_t)(struct sge_iq *, const struct rss_header *,
|
|
|
|
struct mbuf *);
|
2012-06-19 07:34:13 +00:00
|
|
|
typedef int (*an_handler_t)(struct sge_iq *, const struct rsp_ctrl *);
|
2012-08-16 18:31:50 +00:00
|
|
|
typedef int (*fw_msg_handler_t)(struct adapter *, const __be64 *);
|
2011-12-16 02:09:51 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
struct adapter {
|
2011-12-16 02:09:51 +00:00
|
|
|
SLIST_ENTRY(adapter) link;
|
2011-02-18 08:00:26 +00:00
|
|
|
device_t dev;
|
|
|
|
struct cdev *cdev;
|
|
|
|
|
|
|
|
/* PCIe register resources */
|
|
|
|
int regs_rid;
|
|
|
|
struct resource *regs_res;
|
|
|
|
int msix_rid;
|
|
|
|
struct resource *msix_res;
|
|
|
|
bus_space_handle_t bh;
|
|
|
|
bus_space_tag_t bt;
|
|
|
|
bus_size_t mmio_len;
|
2013-03-30 02:26:20 +00:00
|
|
|
int udbs_rid;
|
|
|
|
struct resource *udbs_res;
|
|
|
|
volatile uint8_t *udbs_base;
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
unsigned int pf;
|
|
|
|
unsigned int mbox;
|
|
|
|
|
|
|
|
/* Interrupt information */
|
|
|
|
int intr_type;
|
|
|
|
int intr_count;
|
|
|
|
struct irq {
|
|
|
|
struct resource *res;
|
|
|
|
int rid;
|
|
|
|
void *tag;
|
|
|
|
} *irq;
|
|
|
|
|
|
|
|
bus_dma_tag_t dmat; /* Parent DMA tag */
|
|
|
|
|
|
|
|
struct sge sge;
|
2013-08-29 06:26:22 +00:00
|
|
|
int lro_timeout;
|
2011-02-18 08:00:26 +00:00
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
struct taskqueue *tq[NCHAN]; /* taskqueues that flush data out */
|
2011-02-18 08:00:26 +00:00
|
|
|
struct port_info *port[MAX_NPORTS];
|
|
|
|
uint8_t chan_map[NCHAN];
|
|
|
|
|
2012-06-19 07:34:13 +00:00
|
|
|
#ifdef TCP_OFFLOAD
|
|
|
|
void *tom_softc; /* (struct tom_data *) */
|
2011-12-16 02:09:51 +00:00
|
|
|
struct tom_tunables tt;
|
2013-08-28 20:45:45 +00:00
|
|
|
void *iwarp_softc; /* (struct c4iw_dev *) */
|
2014-07-11 21:02:54 +00:00
|
|
|
void *iscsi_softc;
|
2011-12-16 02:09:51 +00:00
|
|
|
#endif
|
2011-05-30 21:07:26 +00:00
|
|
|
struct l2t_data *l2t; /* L2 table */
|
2011-02-18 08:00:26 +00:00
|
|
|
struct tid_info tids;
|
|
|
|
|
2014-05-27 18:18:41 +00:00
|
|
|
uint16_t doorbells;
|
2011-02-18 08:00:26 +00:00
|
|
|
int open_device_map;
|
2012-06-19 07:34:13 +00:00
|
|
|
#ifdef TCP_OFFLOAD
|
2011-12-16 02:09:51 +00:00
|
|
|
int offload_map;
|
|
|
|
#endif
|
2011-02-18 08:00:26 +00:00
|
|
|
int flags;
|
|
|
|
|
Add support for packet-sniffing tracers to cxgbe(4). This works with
all T4 and T5 based cards and is useful for analyzing TSO, LRO, TOE, and
for general purpose monitoring without tapping any cxgbe or cxl ifnet
directly.
Tracers on the T4/T5 chips provide access to Ethernet frames exactly as
they were received from or transmitted on the wire. On transmit, a
tracer will capture a frame after TSO segmentation, hw VLAN tag
insertion, hw L3 & L4 checksum insertion, etc. It will also capture
frames generated by the TCP offload engine (TOE traffic is normally
invisible to the kernel). On receive, a tracer will capture a frame
before hw VLAN extraction, runt filtering, other badness filtering,
before the steering/drop/L2-rewrite filters or the TOE have had a go at
it, and of course before sw LRO in the driver.
There are 4 tracers on a chip. A tracer can trace only in one direction
(tx or rx). For now cxgbetool will set up tracers to capture the first
128B of every transmitted or received frame on a given port. This is a
small subset of what the hardware can do. A pseudo ifnet with the same
name as the nexus driver (t4nex0 or t5nex0) will be created for tracing.
The data delivered to this ifnet is an additional copy made inside the
chip. Normal delivery to cxgbe<n> or cxl<n> will be made as usual.
/* watch cxl0, which is the first port hanging off t5nex0. */
# cxgbetool t5nex0 tracer 0 tx0 (watch what cxl0 is transmitting)
# cxgbetool t5nex0 tracer 1 rx0 (watch what cxl0 is receiving)
# cxgbetool t5nex0 tracer list
# tcpdump -i t5nex0 <== all that cxl0 sees and puts on the wire
If you were doing TSO, a tcpdump on cxl0 may have shown you ~64K
"frames" with no L3/L4 checksum but this will show you the frames that
were actually transmitted.
/* all done */
# cxgbetool t5nex0 tracer 0 disable
# cxgbetool t5nex0 tracer 1 disable
# cxgbetool t5nex0 tracer list
# ifconfig t5nex0 destroy
2013-07-26 22:04:11 +00:00
|
|
|
char ifp_lockname[16];
|
|
|
|
struct mtx ifp_lock;
|
|
|
|
struct ifnet *ifp; /* tracer ifp */
|
|
|
|
struct ifmedia media;
|
|
|
|
int traceq; /* iq used by all tracers, -1 if none */
|
|
|
|
int tracer_valid; /* bitmap of valid tracers */
|
|
|
|
int tracer_enabled; /* bitmap of enabled tracers */
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
char fw_version[32];
|
2013-01-26 03:10:28 +00:00
|
|
|
char cfg_file[32];
|
|
|
|
u_int cfcsum;
|
2011-02-18 08:00:26 +00:00
|
|
|
struct adapter_params params;
|
|
|
|
struct t4_virt_res vres;
|
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
uint16_t linkcaps;
|
|
|
|
uint16_t niccaps;
|
|
|
|
uint16_t toecaps;
|
|
|
|
uint16_t rdmacaps;
|
|
|
|
uint16_t iscsicaps;
|
|
|
|
uint16_t fcoecaps;
|
|
|
|
|
|
|
|
struct sysctl_ctx_list ctx; /* from adapter_full_init to full_uninit */
|
2011-04-19 22:08:28 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
struct mtx sc_lock;
|
|
|
|
char lockname[16];
|
2011-12-16 02:09:51 +00:00
|
|
|
|
|
|
|
/* Starving free lists */
|
|
|
|
struct mtx sfl_lock; /* same cache-line as sc_lock? but that's ok */
|
|
|
|
TAILQ_HEAD(, sge_fl) sfl;
|
|
|
|
struct callout sfl_callout;
|
|
|
|
|
2014-09-27 05:50:31 +00:00
|
|
|
struct mtx regwin_lock; /* for indirect reads and memory windows */
|
|
|
|
|
2012-06-19 07:34:13 +00:00
|
|
|
an_handler_t an_handler __aligned(CACHE_LINE_SIZE);
|
2013-02-26 00:27:27 +00:00
|
|
|
fw_msg_handler_t fw_msg_handler[5]; /* NUM_FW6_TYPES */
|
2012-08-16 18:31:50 +00:00
|
|
|
cpl_handler_t cpl_handler[0xef]; /* NUM_CPL_CMDS */
|
2013-01-10 23:56:50 +00:00
|
|
|
|
|
|
|
#ifdef INVARIANTS
|
|
|
|
const char *last_op;
|
|
|
|
const void *last_op_thr;
|
|
|
|
#endif
|
2014-01-02 23:23:33 +00:00
|
|
|
|
|
|
|
int sc_do_rxcopy;
|
2011-02-18 08:00:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ADAPTER_LOCK(sc) mtx_lock(&(sc)->sc_lock)
|
|
|
|
#define ADAPTER_UNLOCK(sc) mtx_unlock(&(sc)->sc_lock)
|
|
|
|
#define ADAPTER_LOCK_ASSERT_OWNED(sc) mtx_assert(&(sc)->sc_lock, MA_OWNED)
|
|
|
|
#define ADAPTER_LOCK_ASSERT_NOTOWNED(sc) mtx_assert(&(sc)->sc_lock, MA_NOTOWNED)
|
|
|
|
|
2013-01-10 23:56:50 +00:00
|
|
|
/* XXX: not bulletproof, but much better than nothing */
|
|
|
|
#define ASSERT_SYNCHRONIZED_OP(sc) \
|
|
|
|
KASSERT(IS_BUSY(sc) && \
|
|
|
|
(mtx_owned(&(sc)->sc_lock) || sc->last_op_thr == curthread), \
|
|
|
|
("%s: operation not synchronized.", __func__))
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
#define PORT_LOCK(pi) mtx_lock(&(pi)->pi_lock)
|
|
|
|
#define PORT_UNLOCK(pi) mtx_unlock(&(pi)->pi_lock)
|
|
|
|
#define PORT_LOCK_ASSERT_OWNED(pi) mtx_assert(&(pi)->pi_lock, MA_OWNED)
|
|
|
|
#define PORT_LOCK_ASSERT_NOTOWNED(pi) mtx_assert(&(pi)->pi_lock, MA_NOTOWNED)
|
|
|
|
|
|
|
|
#define FL_LOCK(fl) mtx_lock(&(fl)->fl_lock)
|
|
|
|
#define FL_TRYLOCK(fl) mtx_trylock(&(fl)->fl_lock)
|
|
|
|
#define FL_UNLOCK(fl) mtx_unlock(&(fl)->fl_lock)
|
|
|
|
#define FL_LOCK_ASSERT_OWNED(fl) mtx_assert(&(fl)->fl_lock, MA_OWNED)
|
|
|
|
#define FL_LOCK_ASSERT_NOTOWNED(fl) mtx_assert(&(fl)->fl_lock, MA_NOTOWNED)
|
|
|
|
|
|
|
|
#define RXQ_FL_LOCK(rxq) FL_LOCK(&(rxq)->fl)
|
|
|
|
#define RXQ_FL_UNLOCK(rxq) FL_UNLOCK(&(rxq)->fl)
|
|
|
|
#define RXQ_FL_LOCK_ASSERT_OWNED(rxq) FL_LOCK_ASSERT_OWNED(&(rxq)->fl)
|
|
|
|
#define RXQ_FL_LOCK_ASSERT_NOTOWNED(rxq) FL_LOCK_ASSERT_NOTOWNED(&(rxq)->fl)
|
|
|
|
|
|
|
|
#define EQ_LOCK(eq) mtx_lock(&(eq)->eq_lock)
|
|
|
|
#define EQ_TRYLOCK(eq) mtx_trylock(&(eq)->eq_lock)
|
|
|
|
#define EQ_UNLOCK(eq) mtx_unlock(&(eq)->eq_lock)
|
|
|
|
#define EQ_LOCK_ASSERT_OWNED(eq) mtx_assert(&(eq)->eq_lock, MA_OWNED)
|
|
|
|
#define EQ_LOCK_ASSERT_NOTOWNED(eq) mtx_assert(&(eq)->eq_lock, MA_NOTOWNED)
|
|
|
|
|
|
|
|
#define TXQ_LOCK(txq) EQ_LOCK(&(txq)->eq)
|
|
|
|
#define TXQ_TRYLOCK(txq) EQ_TRYLOCK(&(txq)->eq)
|
|
|
|
#define TXQ_UNLOCK(txq) EQ_UNLOCK(&(txq)->eq)
|
|
|
|
#define TXQ_LOCK_ASSERT_OWNED(txq) EQ_LOCK_ASSERT_OWNED(&(txq)->eq)
|
|
|
|
#define TXQ_LOCK_ASSERT_NOTOWNED(txq) EQ_LOCK_ASSERT_NOTOWNED(&(txq)->eq)
|
|
|
|
|
2013-01-16 23:48:55 +00:00
|
|
|
#define for_each_txq(pi, iter, q) \
|
2013-01-17 18:52:49 +00:00
|
|
|
for (q = &pi->adapter->sge.txq[pi->first_txq], iter = 0; \
|
|
|
|
iter < pi->ntxq; ++iter, ++q)
|
2013-01-16 23:48:55 +00:00
|
|
|
#define for_each_rxq(pi, iter, q) \
|
2013-01-17 18:52:49 +00:00
|
|
|
for (q = &pi->adapter->sge.rxq[pi->first_rxq], iter = 0; \
|
|
|
|
iter < pi->nrxq; ++iter, ++q)
|
2013-01-16 23:48:55 +00:00
|
|
|
#define for_each_ofld_txq(pi, iter, q) \
|
2013-01-17 18:52:49 +00:00
|
|
|
for (q = &pi->adapter->sge.ofld_txq[pi->first_ofld_txq], iter = 0; \
|
|
|
|
iter < pi->nofldtxq; ++iter, ++q)
|
2013-01-16 23:48:55 +00:00
|
|
|
#define for_each_ofld_rxq(pi, iter, q) \
|
2013-01-17 18:52:49 +00:00
|
|
|
for (q = &pi->adapter->sge.ofld_rxq[pi->first_ofld_rxq], iter = 0; \
|
|
|
|
iter < pi->nofldrxq; ++iter, ++q)
|
2014-05-27 18:18:41 +00:00
|
|
|
#define for_each_nm_txq(pi, iter, q) \
|
|
|
|
for (q = &pi->adapter->sge.nm_txq[pi->first_nm_txq], iter = 0; \
|
|
|
|
iter < pi->nnmtxq; ++iter, ++q)
|
|
|
|
#define for_each_nm_rxq(pi, iter, q) \
|
|
|
|
for (q = &pi->adapter->sge.nm_rxq[pi->first_nm_rxq], iter = 0; \
|
|
|
|
iter < pi->nnmrxq; ++iter, ++q)
|
2011-02-18 08:00:26 +00:00
|
|
|
|
2014-08-02 06:55:36 +00:00
|
|
|
#define IDXINCR(idx, incr, wrap) do { \
|
|
|
|
idx = wrap - idx > incr ? idx + incr : incr - (wrap - idx); \
|
2014-08-02 00:56:34 +00:00
|
|
|
} while (0)
|
|
|
|
#define IDXDIFF(head, tail, wrap) \
|
2014-08-02 06:55:36 +00:00
|
|
|
((head) >= (tail) ? (head) - (tail) : (wrap) - (tail) + (head))
|
2014-08-02 00:56:34 +00:00
|
|
|
|
2011-05-30 21:34:44 +00:00
|
|
|
/* One for errors, one for firmware events */
|
|
|
|
#define T4_EXTRA_INTR 2
|
2011-02-18 08:00:26 +00:00
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
t4_read_reg(struct adapter *sc, uint32_t reg)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
return bus_space_read_4(sc->bt, sc->bh, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
t4_write_reg(struct adapter *sc, uint32_t reg, uint32_t val)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
bus_space_write_4(sc->bt, sc->bh, reg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint64_t
|
|
|
|
t4_read_reg64(struct adapter *sc, uint32_t reg)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
return t4_bus_space_read_8(sc->bt, sc->bh, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
t4_write_reg64(struct adapter *sc, uint32_t reg, uint64_t val)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
t4_bus_space_write_8(sc->bt, sc->bh, reg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
t4_os_pci_read_cfg1(struct adapter *sc, int reg, uint8_t *val)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
*val = pci_read_config(sc->dev, reg, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
t4_os_pci_write_cfg1(struct adapter *sc, int reg, uint8_t val)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
pci_write_config(sc->dev, reg, val, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
t4_os_pci_read_cfg2(struct adapter *sc, int reg, uint16_t *val)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
*val = pci_read_config(sc->dev, reg, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
t4_os_pci_write_cfg2(struct adapter *sc, int reg, uint16_t val)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
pci_write_config(sc->dev, reg, val, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
t4_os_pci_read_cfg4(struct adapter *sc, int reg, uint32_t *val)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
*val = pci_read_config(sc->dev, reg, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
t4_os_pci_write_cfg4(struct adapter *sc, int reg, uint32_t val)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
pci_write_config(sc->dev, reg, val, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct port_info *
|
|
|
|
adap2pinfo(struct adapter *sc, int idx)
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
return (sc->port[idx]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
t4_os_set_hw_addr(struct adapter *sc, int idx, uint8_t hw_addr[])
|
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
bcopy(hw_addr, sc->port[idx]->hw_addr, ETHER_ADDR_LEN);
|
|
|
|
}
|
|
|
|
|
2013-03-30 02:26:20 +00:00
|
|
|
static inline bool
|
|
|
|
is_10G_port(const struct port_info *pi)
|
2011-02-18 08:00:26 +00:00
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
return ((pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G) != 0);
|
|
|
|
}
|
|
|
|
|
2013-04-30 05:51:52 +00:00
|
|
|
static inline bool
|
|
|
|
is_40G_port(const struct port_info *pi)
|
|
|
|
{
|
|
|
|
|
|
|
|
return ((pi->link_cfg.supported & FW_PORT_CAP_SPEED_40G) != 0);
|
|
|
|
}
|
|
|
|
|
2013-03-30 02:26:20 +00:00
|
|
|
static inline int
|
|
|
|
tx_resume_threshold(struct sge_eq *eq)
|
2011-12-16 02:09:51 +00:00
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
|
2011-12-16 02:09:51 +00:00
|
|
|
return (eq->qsize / 4);
|
|
|
|
}
|
|
|
|
|
2011-03-05 03:06:38 +00:00
|
|
|
/* t4_main.c */
|
2011-12-16 02:09:51 +00:00
|
|
|
void t4_tx_task(void *, int);
|
|
|
|
void t4_tx_callout(void *);
|
2011-02-18 08:00:26 +00:00
|
|
|
int t4_os_find_pci_capability(struct adapter *, int);
|
|
|
|
int t4_os_pci_save_state(struct adapter *);
|
|
|
|
int t4_os_pci_restore_state(struct adapter *);
|
|
|
|
void t4_os_portmod_changed(const struct adapter *, int);
|
2013-07-05 01:53:51 +00:00
|
|
|
void t4_os_link_changed(struct adapter *, int, int, int);
|
2011-12-16 02:09:51 +00:00
|
|
|
void t4_iterate(void (*)(struct adapter *, void *), void *);
|
|
|
|
int t4_register_cpl_handler(struct adapter *, int, cpl_handler_t);
|
2012-06-19 07:34:13 +00:00
|
|
|
int t4_register_an_handler(struct adapter *, an_handler_t);
|
2012-08-16 18:31:50 +00:00
|
|
|
int t4_register_fw_msg_handler(struct adapter *, int, fw_msg_handler_t);
|
2012-08-16 20:15:29 +00:00
|
|
|
int t4_filter_rpl(struct sge_iq *, const struct rss_header *, struct mbuf *);
|
2013-01-10 23:56:50 +00:00
|
|
|
int begin_synchronized_op(struct adapter *, struct port_info *, int, char *);
|
|
|
|
void end_synchronized_op(struct adapter *, int);
|
2014-05-27 18:18:41 +00:00
|
|
|
int update_mac_settings(struct ifnet *, int);
|
|
|
|
int adapter_full_init(struct adapter *);
|
|
|
|
int adapter_full_uninit(struct adapter *);
|
|
|
|
int port_full_init(struct port_info *);
|
|
|
|
int port_full_uninit(struct port_info *);
|
|
|
|
|
|
|
|
#ifdef DEV_NETMAP
|
|
|
|
/* t4_netmap.c */
|
|
|
|
int create_netmap_ifnet(struct port_info *);
|
|
|
|
int destroy_netmap_ifnet(struct port_info *);
|
|
|
|
void t4_nm_intr(void *);
|
|
|
|
#endif
|
2011-02-18 08:00:26 +00:00
|
|
|
|
2011-03-05 03:06:38 +00:00
|
|
|
/* t4_sge.c */
|
2011-03-08 03:04:07 +00:00
|
|
|
void t4_sge_modload(void);
|
2014-07-23 22:29:22 +00:00
|
|
|
void t4_sge_modunload(void);
|
|
|
|
uint64_t t4_sge_extfree_refs(void);
|
2013-03-30 02:26:20 +00:00
|
|
|
void t4_init_sge_cpl_handlers(struct adapter *);
|
|
|
|
void t4_tweak_chip_settings(struct adapter *);
|
|
|
|
int t4_read_chip_settings(struct adapter *);
|
2011-02-18 08:00:26 +00:00
|
|
|
int t4_create_dma_tag(struct adapter *);
|
2013-07-31 05:12:51 +00:00
|
|
|
void t4_sge_sysctls(struct adapter *, struct sysctl_ctx_list *,
|
|
|
|
struct sysctl_oid_list *);
|
2011-02-18 08:00:26 +00:00
|
|
|
int t4_destroy_dma_tag(struct adapter *);
|
2011-04-19 22:08:28 +00:00
|
|
|
int t4_setup_adapter_queues(struct adapter *);
|
|
|
|
int t4_teardown_adapter_queues(struct adapter *);
|
2011-12-16 02:09:51 +00:00
|
|
|
int t4_setup_port_queues(struct port_info *);
|
|
|
|
int t4_teardown_port_queues(struct port_info *);
|
|
|
|
int t4_alloc_tx_maps(struct tx_maps *, bus_dma_tag_t, int, int);
|
|
|
|
void t4_free_tx_maps(struct tx_maps *, bus_dma_tag_t);
|
2011-02-18 08:00:26 +00:00
|
|
|
void t4_intr_all(void *);
|
2011-05-30 21:34:44 +00:00
|
|
|
void t4_intr(void *);
|
2011-02-18 08:00:26 +00:00
|
|
|
void t4_intr_err(void *);
|
|
|
|
void t4_intr_evt(void *);
|
2012-06-19 07:34:13 +00:00
|
|
|
void t4_wrq_tx_locked(struct adapter *, struct sge_wrq *, struct wrqe *);
|
2011-02-18 08:00:26 +00:00
|
|
|
int t4_eth_tx(struct ifnet *, struct sge_txq *, struct mbuf *);
|
|
|
|
void t4_update_fl_bufsize(struct ifnet *);
|
2011-12-16 02:09:51 +00:00
|
|
|
int can_resume_tx(struct sge_eq *);
|
|
|
|
|
Add support for packet-sniffing tracers to cxgbe(4). This works with
all T4 and T5 based cards and is useful for analyzing TSO, LRO, TOE, and
for general purpose monitoring without tapping any cxgbe or cxl ifnet
directly.
Tracers on the T4/T5 chips provide access to Ethernet frames exactly as
they were received from or transmitted on the wire. On transmit, a
tracer will capture a frame after TSO segmentation, hw VLAN tag
insertion, hw L3 & L4 checksum insertion, etc. It will also capture
frames generated by the TCP offload engine (TOE traffic is normally
invisible to the kernel). On receive, a tracer will capture a frame
before hw VLAN extraction, runt filtering, other badness filtering,
before the steering/drop/L2-rewrite filters or the TOE have had a go at
it, and of course before sw LRO in the driver.
There are 4 tracers on a chip. A tracer can trace only in one direction
(tx or rx). For now cxgbetool will set up tracers to capture the first
128B of every transmitted or received frame on a given port. This is a
small subset of what the hardware can do. A pseudo ifnet with the same
name as the nexus driver (t4nex0 or t5nex0) will be created for tracing.
The data delivered to this ifnet is an additional copy made inside the
chip. Normal delivery to cxgbe<n> or cxl<n> will be made as usual.
/* watch cxl0, which is the first port hanging off t5nex0. */
# cxgbetool t5nex0 tracer 0 tx0 (watch what cxl0 is transmitting)
# cxgbetool t5nex0 tracer 1 rx0 (watch what cxl0 is receiving)
# cxgbetool t5nex0 tracer list
# tcpdump -i t5nex0 <== all that cxl0 sees and puts on the wire
If you were doing TSO, a tcpdump on cxl0 may have shown you ~64K
"frames" with no L3/L4 checksum but this will show you the frames that
were actually transmitted.
/* all done */
# cxgbetool t5nex0 tracer 0 disable
# cxgbetool t5nex0 tracer 1 disable
# cxgbetool t5nex0 tracer list
# ifconfig t5nex0 destroy
2013-07-26 22:04:11 +00:00
|
|
|
/* t4_tracer.c */
|
|
|
|
struct t4_tracer;
|
|
|
|
void t4_tracer_modload(void);
|
|
|
|
void t4_tracer_modunload(void);
|
|
|
|
void t4_tracer_port_detach(struct adapter *);
|
|
|
|
int t4_get_tracer(struct adapter *, struct t4_tracer *);
|
|
|
|
int t4_set_tracer(struct adapter *, struct t4_tracer *);
|
|
|
|
int t4_trace_pkt(struct sge_iq *, const struct rss_header *, struct mbuf *);
|
|
|
|
int t5_trace_pkt(struct sge_iq *, const struct rss_header *, struct mbuf *);
|
|
|
|
|
2012-06-19 07:34:13 +00:00
|
|
|
static inline struct wrqe *
|
|
|
|
alloc_wrqe(int wr_len, struct sge_wrq *wrq)
|
2011-12-16 02:09:51 +00:00
|
|
|
{
|
2012-06-19 07:34:13 +00:00
|
|
|
int len = offsetof(struct wrqe, wr) + wr_len;
|
|
|
|
struct wrqe *wr;
|
|
|
|
|
|
|
|
wr = malloc(len, M_CXGBE, M_NOWAIT);
|
|
|
|
if (__predict_false(wr == NULL))
|
|
|
|
return (NULL);
|
|
|
|
wr->wr_len = wr_len;
|
|
|
|
wr->wrq = wrq;
|
|
|
|
return (wr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *
|
|
|
|
wrtod(struct wrqe *wr)
|
|
|
|
{
|
|
|
|
return (&wr->wr[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
free_wrqe(struct wrqe *wr)
|
|
|
|
{
|
|
|
|
free(wr, M_CXGBE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
t4_wrq_tx(struct adapter *sc, struct wrqe *wr)
|
|
|
|
{
|
|
|
|
struct sge_wrq *wrq = wr->wrq;
|
2011-12-16 02:09:51 +00:00
|
|
|
|
|
|
|
TXQ_LOCK(wrq);
|
2012-06-19 07:34:13 +00:00
|
|
|
t4_wrq_tx_locked(sc, wrq, wr);
|
2011-12-16 02:09:51 +00:00
|
|
|
TXQ_UNLOCK(wrq);
|
|
|
|
}
|
|
|
|
|
2011-02-18 08:00:26 +00:00
|
|
|
#endif
|