2011-11-16 17:11:13 +00:00
|
|
|
/*-
|
2015-05-25 08:34:55 +00:00
|
|
|
* Copyright (c) 2010-2015 Solarflare Communications Inc.
|
2011-11-16 17:11:13 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This software was developed in part by Philip Paeps under contract for
|
|
|
|
* Solarflare Communications, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
2015-05-25 08:34:55 +00:00
|
|
|
* modification, are permitted provided that the following conditions are met:
|
2011-11-16 17:11:13 +00:00
|
|
|
*
|
2015-05-25 08:34:55 +00:00
|
|
|
* 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
|
|
|
|
*
|
|
|
|
* The views and conclusions contained in the software and documentation are
|
|
|
|
* those of the authors and should not be interpreted as representing official
|
|
|
|
* policies, either expressed or implied, of the FreeBSD Project.
|
2011-11-16 17:11:13 +00:00
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SFXGE_H
|
2014-09-30 20:18:10 +00:00
|
|
|
#define _SFXGE_H
|
2011-11-16 17:11:13 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/sx.h>
|
|
|
|
#include <vm/uma.h>
|
|
|
|
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
#include <net/if.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <net/if_var.h>
|
2011-11-16 17:11:13 +00:00
|
|
|
#include <net/if_media.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
|
2015-05-25 08:34:55 +00:00
|
|
|
#include "sfxge_ioc.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Debugging
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
#define DBGPRINT(dev, fmt, args...) \
|
|
|
|
device_printf(dev, "%s: " fmt "\n", __func__, ## args)
|
|
|
|
#else
|
|
|
|
#define DBGPRINT(dev, fmt, args...)
|
|
|
|
#endif
|
|
|
|
|
2011-11-16 17:11:13 +00:00
|
|
|
/*
|
|
|
|
* Backward-compatibility
|
|
|
|
*/
|
|
|
|
#ifndef CACHE_LINE_SIZE
|
|
|
|
/* This should be right on most machines the driver will be used on, and
|
|
|
|
* we needn't care too much about wasting a few KB per interface.
|
|
|
|
*/
|
2014-09-30 20:18:10 +00:00
|
|
|
#define CACHE_LINE_SIZE 128
|
2011-11-16 17:11:13 +00:00
|
|
|
#endif
|
2015-03-24 11:25:19 +00:00
|
|
|
|
2011-11-16 17:11:13 +00:00
|
|
|
#ifndef IFCAP_LINKSTATE
|
2014-09-30 20:18:10 +00:00
|
|
|
#define IFCAP_LINKSTATE 0
|
2011-11-16 17:11:13 +00:00
|
|
|
#endif
|
2015-03-24 11:25:19 +00:00
|
|
|
|
2011-11-16 17:11:13 +00:00
|
|
|
#ifndef IFCAP_VLAN_HWTSO
|
2014-09-30 20:18:10 +00:00
|
|
|
#define IFCAP_VLAN_HWTSO 0
|
2011-11-16 17:11:13 +00:00
|
|
|
#endif
|
2015-03-24 11:25:19 +00:00
|
|
|
|
2011-11-16 17:11:13 +00:00
|
|
|
#ifndef IFM_10G_T
|
2014-09-30 20:18:10 +00:00
|
|
|
#define IFM_10G_T IFM_UNKNOWN
|
2011-11-16 17:11:13 +00:00
|
|
|
#endif
|
2015-03-24 11:25:19 +00:00
|
|
|
|
2011-11-16 17:11:13 +00:00
|
|
|
#ifndef IFM_10G_KX4
|
2014-09-30 20:18:10 +00:00
|
|
|
#define IFM_10G_KX4 IFM_10G_CX4
|
2011-11-16 17:11:13 +00:00
|
|
|
#endif
|
2015-03-24 11:25:19 +00:00
|
|
|
|
2015-05-25 08:34:55 +00:00
|
|
|
#ifndef IFM_40G_CR4
|
|
|
|
#define IFM_40G_CR4 IFM_UNKNOWN
|
|
|
|
#endif
|
|
|
|
|
2011-11-16 17:11:13 +00:00
|
|
|
#if (__FreeBSD_version >= 800501 && __FreeBSD_version < 900000) || \
|
|
|
|
__FreeBSD_version >= 900003
|
2014-09-30 20:18:10 +00:00
|
|
|
#define SFXGE_HAVE_DESCRIBE_INTR
|
2011-11-16 17:11:13 +00:00
|
|
|
#endif
|
2015-03-24 11:25:19 +00:00
|
|
|
|
2011-11-16 17:11:13 +00:00
|
|
|
#ifdef IFM_ETH_RXPAUSE
|
2014-09-30 20:18:10 +00:00
|
|
|
#define SFXGE_HAVE_PAUSE_MEDIAOPTS
|
2011-11-16 17:11:13 +00:00
|
|
|
#endif
|
2015-03-24 11:25:19 +00:00
|
|
|
|
2011-11-16 17:11:13 +00:00
|
|
|
#ifndef CTLTYPE_U64
|
2014-09-30 20:18:10 +00:00
|
|
|
#define CTLTYPE_U64 CTLTYPE_QUAD
|
2011-11-16 17:11:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "sfxge_rx.h"
|
|
|
|
#include "sfxge_tx.h"
|
|
|
|
|
2014-09-30 20:36:07 +00:00
|
|
|
#define ROUNDUP_POW_OF_TWO(_n) (1ULL << flsl((_n) - 1))
|
|
|
|
|
2014-09-30 20:18:10 +00:00
|
|
|
#define SFXGE_IP_ALIGN 2
|
2011-11-16 17:11:13 +00:00
|
|
|
|
2014-09-30 20:18:10 +00:00
|
|
|
#define SFXGE_ETHERTYPE_LOOPBACK 0x9000 /* Xerox loopback */
|
2011-11-16 17:11:13 +00:00
|
|
|
|
|
|
|
enum sfxge_evq_state {
|
|
|
|
SFXGE_EVQ_UNINITIALIZED = 0,
|
|
|
|
SFXGE_EVQ_INITIALIZED,
|
|
|
|
SFXGE_EVQ_STARTING,
|
|
|
|
SFXGE_EVQ_STARTED
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SFXGE_EV_BATCH 16384
|
|
|
|
|
|
|
|
struct sfxge_evq {
|
2015-01-29 18:57:27 +00:00
|
|
|
/* Structure members below are sorted by usage order */
|
|
|
|
struct sfxge_softc *sc;
|
|
|
|
struct mtx lock;
|
2011-11-16 17:11:13 +00:00
|
|
|
unsigned int index;
|
2015-01-29 18:57:27 +00:00
|
|
|
enum sfxge_evq_state init_state;
|
2011-11-16 17:11:13 +00:00
|
|
|
efsys_mem_t mem;
|
|
|
|
efx_evq_t *common;
|
|
|
|
unsigned int read_ptr;
|
2015-01-29 18:57:27 +00:00
|
|
|
boolean_t exception;
|
2011-11-16 17:11:13 +00:00
|
|
|
unsigned int rx_done;
|
|
|
|
unsigned int tx_done;
|
|
|
|
|
|
|
|
/* Linked list of TX queues with completions to process */
|
|
|
|
struct sfxge_txq *txq;
|
|
|
|
struct sfxge_txq **txqs;
|
2015-01-29 18:57:27 +00:00
|
|
|
|
|
|
|
/* Structure members not used on event processing path */
|
|
|
|
unsigned int buf_base_id;
|
|
|
|
unsigned int entries;
|
2015-02-05 11:39:15 +00:00
|
|
|
char lock_name[SFXGE_LOCK_NAME_MAX];
|
2015-01-29 18:57:27 +00:00
|
|
|
} __aligned(CACHE_LINE_SIZE);
|
2011-11-16 17:11:13 +00:00
|
|
|
|
|
|
|
#define SFXGE_NDESCS 1024
|
|
|
|
#define SFXGE_MODERATION 30
|
|
|
|
|
|
|
|
enum sfxge_intr_state {
|
|
|
|
SFXGE_INTR_UNINITIALIZED = 0,
|
|
|
|
SFXGE_INTR_INITIALIZED,
|
|
|
|
SFXGE_INTR_TESTING,
|
|
|
|
SFXGE_INTR_STARTED
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sfxge_intr_hdl {
|
2014-09-30 20:18:10 +00:00
|
|
|
int eih_rid;
|
|
|
|
void *eih_tag;
|
|
|
|
struct resource *eih_res;
|
2011-11-16 17:11:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sfxge_intr {
|
|
|
|
enum sfxge_intr_state state;
|
|
|
|
struct resource *msix_res;
|
|
|
|
struct sfxge_intr_hdl *table;
|
|
|
|
int n_alloc;
|
|
|
|
int type;
|
|
|
|
efsys_mem_t status;
|
|
|
|
uint32_t zero_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum sfxge_mcdi_state {
|
|
|
|
SFXGE_MCDI_UNINITIALIZED = 0,
|
|
|
|
SFXGE_MCDI_INITIALIZED,
|
|
|
|
SFXGE_MCDI_BUSY,
|
|
|
|
SFXGE_MCDI_COMPLETED
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sfxge_mcdi {
|
|
|
|
struct mtx lock;
|
2015-05-25 08:34:55 +00:00
|
|
|
efsys_mem_t mem;
|
2011-11-16 17:11:13 +00:00
|
|
|
enum sfxge_mcdi_state state;
|
|
|
|
efx_mcdi_transport_t transport;
|
2015-02-05 11:39:15 +00:00
|
|
|
|
|
|
|
/* Only used in debugging output */
|
|
|
|
char lock_name[SFXGE_LOCK_NAME_MAX];
|
2011-11-16 17:11:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sfxge_hw_stats {
|
|
|
|
clock_t update_time;
|
|
|
|
efsys_mem_t dma_buf;
|
|
|
|
void *decode_buf;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum sfxge_port_state {
|
|
|
|
SFXGE_PORT_UNINITIALIZED = 0,
|
|
|
|
SFXGE_PORT_INITIALIZED,
|
|
|
|
SFXGE_PORT_STARTED
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sfxge_port {
|
|
|
|
struct sfxge_softc *sc;
|
|
|
|
struct mtx lock;
|
|
|
|
enum sfxge_port_state init_state;
|
|
|
|
#ifndef SFXGE_HAVE_PAUSE_MEDIAOPTS
|
|
|
|
unsigned int wanted_fc;
|
|
|
|
#endif
|
|
|
|
struct sfxge_hw_stats phy_stats;
|
|
|
|
struct sfxge_hw_stats mac_stats;
|
|
|
|
efx_link_mode_t link_mode;
|
2015-05-25 08:34:55 +00:00
|
|
|
uint8_t mcast_addrs[EFX_MAC_MULTICAST_LIST_MAX *
|
|
|
|
EFX_MAC_ADDR_LEN];
|
|
|
|
unsigned int mcast_count;
|
2015-02-05 11:39:15 +00:00
|
|
|
|
|
|
|
/* Only used in debugging output */
|
|
|
|
char lock_name[SFXGE_LOCK_NAME_MAX];
|
2011-11-16 17:11:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum sfxge_softc_state {
|
|
|
|
SFXGE_UNINITIALIZED = 0,
|
|
|
|
SFXGE_INITIALIZED,
|
|
|
|
SFXGE_REGISTERED,
|
|
|
|
SFXGE_STARTED
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sfxge_softc {
|
|
|
|
device_t dev;
|
|
|
|
struct sx softc_lock;
|
2015-02-05 11:39:15 +00:00
|
|
|
char softc_lock_name[SFXGE_LOCK_NAME_MAX];
|
2011-11-16 17:11:13 +00:00
|
|
|
enum sfxge_softc_state init_state;
|
2014-09-30 20:18:10 +00:00
|
|
|
struct ifnet *ifnet;
|
2011-11-16 17:11:13 +00:00
|
|
|
unsigned int if_flags;
|
|
|
|
struct sysctl_oid *stats_node;
|
2014-09-30 20:43:21 +00:00
|
|
|
struct sysctl_oid *txqs_node;
|
2011-11-16 17:11:13 +00:00
|
|
|
|
|
|
|
struct task task_reset;
|
|
|
|
|
|
|
|
efx_family_t family;
|
|
|
|
caddr_t vpd_data;
|
|
|
|
size_t vpd_size;
|
|
|
|
efx_nic_t *enp;
|
2015-02-05 11:39:15 +00:00
|
|
|
efsys_lock_t enp_lock;
|
2011-11-16 17:11:13 +00:00
|
|
|
|
2014-09-30 20:36:07 +00:00
|
|
|
unsigned int rxq_entries;
|
|
|
|
unsigned int txq_entries;
|
|
|
|
|
2014-09-30 20:18:10 +00:00
|
|
|
bus_dma_tag_t parent_dma_tag;
|
2011-11-16 17:11:13 +00:00
|
|
|
efsys_bar_t bar;
|
|
|
|
|
|
|
|
struct sfxge_intr intr;
|
|
|
|
struct sfxge_mcdi mcdi;
|
|
|
|
struct sfxge_port port;
|
|
|
|
uint32_t buffer_table_next;
|
|
|
|
|
|
|
|
struct sfxge_evq *evq[SFXGE_RX_SCALE_MAX];
|
|
|
|
unsigned int ev_moderation;
|
2015-01-29 18:54:43 +00:00
|
|
|
#if EFSYS_OPT_QSTATS
|
2011-11-16 17:11:13 +00:00
|
|
|
clock_t ev_stats_update_time;
|
|
|
|
uint64_t ev_stats[EV_NQSTATS];
|
2015-01-29 18:54:43 +00:00
|
|
|
#endif
|
2011-11-16 17:11:13 +00:00
|
|
|
|
2015-01-29 19:09:14 +00:00
|
|
|
unsigned int max_rss_channels;
|
2011-11-16 17:11:13 +00:00
|
|
|
uma_zone_t rxq_cache;
|
|
|
|
struct sfxge_rxq *rxq[SFXGE_RX_SCALE_MAX];
|
|
|
|
unsigned int rx_indir_table[SFXGE_RX_SCALE_MAX];
|
|
|
|
|
|
|
|
struct sfxge_txq *txq[SFXGE_TXQ_NTYPES + SFXGE_RX_SCALE_MAX];
|
|
|
|
|
|
|
|
struct ifmedia media;
|
|
|
|
|
|
|
|
size_t rx_prefix_size;
|
|
|
|
size_t rx_buffer_size;
|
2015-05-25 08:34:55 +00:00
|
|
|
size_t rx_buffer_align;
|
2016-01-28 16:51:56 +00:00
|
|
|
int rx_cluster_size;
|
2011-11-16 17:11:13 +00:00
|
|
|
|
2015-05-25 08:34:55 +00:00
|
|
|
unsigned int evq_max;
|
2015-02-18 06:21:59 +00:00
|
|
|
unsigned int evq_count;
|
2015-02-18 06:20:59 +00:00
|
|
|
unsigned int rxq_count;
|
2015-02-18 06:19:35 +00:00
|
|
|
unsigned int txq_count;
|
2015-05-25 08:34:55 +00:00
|
|
|
|
2016-01-15 06:25:26 +00:00
|
|
|
unsigned int tso_fw_assisted;
|
|
|
|
#define SFXGE_FATSOV1 (1 << 0)
|
|
|
|
#define SFXGE_FATSOV2 (1 << 1)
|
|
|
|
|
2015-12-05 07:04:11 +00:00
|
|
|
#if EFSYS_OPT_MCDI_LOGGING
|
|
|
|
int mcdi_logging;
|
|
|
|
#endif
|
2011-11-16 17:11:13 +00:00
|
|
|
};
|
|
|
|
|
2014-09-30 20:18:10 +00:00
|
|
|
#define SFXGE_LINK_UP(sc) ((sc)->port.link_mode != EFX_LINK_DOWN)
|
|
|
|
#define SFXGE_RUNNING(sc) ((sc)->ifnet->if_drv_flags & IFF_DRV_RUNNING)
|
2011-11-16 17:11:13 +00:00
|
|
|
|
2014-09-30 20:36:07 +00:00
|
|
|
#define SFXGE_PARAM(_name) "hw.sfxge." #_name
|
|
|
|
|
|
|
|
SYSCTL_DECL(_hw_sfxge);
|
|
|
|
|
2011-11-16 17:11:13 +00:00
|
|
|
/*
|
|
|
|
* From sfxge.c.
|
|
|
|
*/
|
|
|
|
extern void sfxge_schedule_reset(struct sfxge_softc *sc);
|
|
|
|
extern void sfxge_sram_buf_tbl_alloc(struct sfxge_softc *sc, size_t n,
|
|
|
|
uint32_t *idp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* From sfxge_dma.c.
|
|
|
|
*/
|
|
|
|
extern int sfxge_dma_init(struct sfxge_softc *sc);
|
|
|
|
extern void sfxge_dma_fini(struct sfxge_softc *sc);
|
|
|
|
extern int sfxge_dma_alloc(struct sfxge_softc *sc, bus_size_t len,
|
2015-05-25 08:34:55 +00:00
|
|
|
efsys_mem_t *esmp);
|
2011-11-16 17:11:13 +00:00
|
|
|
extern void sfxge_dma_free(efsys_mem_t *esmp);
|
|
|
|
extern int sfxge_dma_map_sg_collapse(bus_dma_tag_t tag, bus_dmamap_t map,
|
2015-05-25 08:34:55 +00:00
|
|
|
struct mbuf **mp,
|
|
|
|
bus_dma_segment_t *segs,
|
|
|
|
int *nsegs, int maxsegs);
|
2011-11-16 17:11:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* From sfxge_ev.c.
|
|
|
|
*/
|
|
|
|
extern int sfxge_ev_init(struct sfxge_softc *sc);
|
|
|
|
extern void sfxge_ev_fini(struct sfxge_softc *sc);
|
|
|
|
extern int sfxge_ev_start(struct sfxge_softc *sc);
|
|
|
|
extern void sfxge_ev_stop(struct sfxge_softc *sc);
|
2015-01-29 18:50:25 +00:00
|
|
|
extern int sfxge_ev_qpoll(struct sfxge_evq *evq);
|
2011-11-16 17:11:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* From sfxge_intr.c.
|
|
|
|
*/
|
|
|
|
extern int sfxge_intr_init(struct sfxge_softc *sc);
|
|
|
|
extern void sfxge_intr_fini(struct sfxge_softc *sc);
|
|
|
|
extern int sfxge_intr_start(struct sfxge_softc *sc);
|
|
|
|
extern void sfxge_intr_stop(struct sfxge_softc *sc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* From sfxge_mcdi.c.
|
|
|
|
*/
|
|
|
|
extern int sfxge_mcdi_init(struct sfxge_softc *sc);
|
|
|
|
extern void sfxge_mcdi_fini(struct sfxge_softc *sc);
|
2015-05-25 08:34:55 +00:00
|
|
|
extern int sfxge_mcdi_ioctl(struct sfxge_softc *sc, sfxge_ioc_t *ip);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* From sfxge_nvram.c.
|
|
|
|
*/
|
|
|
|
extern int sfxge_nvram_ioctl(struct sfxge_softc *sc, sfxge_ioc_t *ip);
|
2011-11-16 17:11:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* From sfxge_port.c.
|
|
|
|
*/
|
|
|
|
extern int sfxge_port_init(struct sfxge_softc *sc);
|
|
|
|
extern void sfxge_port_fini(struct sfxge_softc *sc);
|
|
|
|
extern int sfxge_port_start(struct sfxge_softc *sc);
|
|
|
|
extern void sfxge_port_stop(struct sfxge_softc *sc);
|
|
|
|
extern void sfxge_mac_link_update(struct sfxge_softc *sc,
|
2015-05-25 08:34:55 +00:00
|
|
|
efx_link_mode_t mode);
|
2011-11-16 17:11:13 +00:00
|
|
|
extern int sfxge_mac_filter_set(struct sfxge_softc *sc);
|
|
|
|
extern int sfxge_port_ifmedia_init(struct sfxge_softc *sc);
|
2015-02-22 19:25:57 +00:00
|
|
|
extern uint64_t sfxge_get_counter(struct ifnet *ifp, ift_counter c);
|
2011-11-16 17:11:13 +00:00
|
|
|
|
2014-09-30 20:18:10 +00:00
|
|
|
#define SFXGE_MAX_MTU (9 * 1024)
|
2011-11-16 17:11:13 +00:00
|
|
|
|
2015-02-05 11:39:15 +00:00
|
|
|
#define SFXGE_ADAPTER_LOCK_INIT(_sc, _ifname) \
|
|
|
|
do { \
|
|
|
|
struct sfxge_softc *__sc = (_sc); \
|
|
|
|
\
|
|
|
|
snprintf((__sc)->softc_lock_name, \
|
|
|
|
sizeof((__sc)->softc_lock_name), \
|
|
|
|
"%s:softc", (_ifname)); \
|
|
|
|
sx_init(&(__sc)->softc_lock, (__sc)->softc_lock_name); \
|
|
|
|
} while (B_FALSE)
|
2015-02-04 20:03:57 +00:00
|
|
|
#define SFXGE_ADAPTER_LOCK_DESTROY(_sc) \
|
|
|
|
sx_destroy(&(_sc)->softc_lock)
|
|
|
|
#define SFXGE_ADAPTER_LOCK(_sc) \
|
|
|
|
sx_xlock(&(_sc)->softc_lock)
|
|
|
|
#define SFXGE_ADAPTER_UNLOCK(_sc) \
|
|
|
|
sx_xunlock(&(_sc)->softc_lock)
|
|
|
|
#define SFXGE_ADAPTER_LOCK_ASSERT_OWNED(_sc) \
|
|
|
|
sx_assert(&(_sc)->softc_lock, LA_XLOCKED)
|
|
|
|
|
2015-02-05 11:39:15 +00:00
|
|
|
#define SFXGE_PORT_LOCK_INIT(_port, _ifname) \
|
|
|
|
do { \
|
|
|
|
struct sfxge_port *__port = (_port); \
|
|
|
|
\
|
|
|
|
snprintf((__port)->lock_name, \
|
|
|
|
sizeof((__port)->lock_name), \
|
|
|
|
"%s:port", (_ifname)); \
|
|
|
|
mtx_init(&(__port)->lock, (__port)->lock_name, \
|
|
|
|
NULL, MTX_DEF); \
|
|
|
|
} while (B_FALSE)
|
2015-02-04 20:03:57 +00:00
|
|
|
#define SFXGE_PORT_LOCK_DESTROY(_port) \
|
|
|
|
mtx_destroy(&(_port)->lock)
|
|
|
|
#define SFXGE_PORT_LOCK(_port) \
|
|
|
|
mtx_lock(&(_port)->lock)
|
|
|
|
#define SFXGE_PORT_UNLOCK(_port) \
|
|
|
|
mtx_unlock(&(_port)->lock)
|
|
|
|
#define SFXGE_PORT_LOCK_ASSERT_OWNED(_port) \
|
|
|
|
mtx_assert(&(_port)->lock, MA_OWNED)
|
|
|
|
|
2015-02-05 11:39:15 +00:00
|
|
|
#define SFXGE_MCDI_LOCK_INIT(_mcdi, _ifname) \
|
|
|
|
do { \
|
|
|
|
struct sfxge_mcdi *__mcdi = (_mcdi); \
|
|
|
|
\
|
|
|
|
snprintf((__mcdi)->lock_name, \
|
|
|
|
sizeof((__mcdi)->lock_name), \
|
|
|
|
"%s:mcdi", (_ifname)); \
|
|
|
|
mtx_init(&(__mcdi)->lock, (__mcdi)->lock_name, \
|
|
|
|
NULL, MTX_DEF); \
|
|
|
|
} while (B_FALSE)
|
2015-02-04 20:03:57 +00:00
|
|
|
#define SFXGE_MCDI_LOCK_DESTROY(_mcdi) \
|
|
|
|
mtx_destroy(&(_mcdi)->lock)
|
|
|
|
#define SFXGE_MCDI_LOCK(_mcdi) \
|
|
|
|
mtx_lock(&(_mcdi)->lock)
|
|
|
|
#define SFXGE_MCDI_UNLOCK(_mcdi) \
|
|
|
|
mtx_unlock(&(_mcdi)->lock)
|
|
|
|
#define SFXGE_MCDI_LOCK_ASSERT_OWNED(_mcdi) \
|
|
|
|
mtx_assert(&(_mcdi)->lock, MA_OWNED)
|
|
|
|
|
2015-02-05 11:39:15 +00:00
|
|
|
#define SFXGE_EVQ_LOCK_INIT(_evq, _ifname, _evq_index) \
|
|
|
|
do { \
|
|
|
|
struct sfxge_evq *__evq = (_evq); \
|
|
|
|
\
|
|
|
|
snprintf((__evq)->lock_name, \
|
|
|
|
sizeof((__evq)->lock_name), \
|
|
|
|
"%s:evq%u", (_ifname), (_evq_index)); \
|
|
|
|
mtx_init(&(__evq)->lock, (__evq)->lock_name, \
|
|
|
|
NULL, MTX_DEF); \
|
|
|
|
} while (B_FALSE)
|
2015-02-04 20:03:57 +00:00
|
|
|
#define SFXGE_EVQ_LOCK_DESTROY(_evq) \
|
|
|
|
mtx_destroy(&(_evq)->lock)
|
|
|
|
#define SFXGE_EVQ_LOCK(_evq) \
|
|
|
|
mtx_lock(&(_evq)->lock)
|
|
|
|
#define SFXGE_EVQ_UNLOCK(_evq) \
|
|
|
|
mtx_unlock(&(_evq)->lock)
|
|
|
|
#define SFXGE_EVQ_LOCK_ASSERT_OWNED(_evq) \
|
|
|
|
mtx_assert(&(_evq)->lock, MA_OWNED)
|
|
|
|
|
2011-11-16 17:11:13 +00:00
|
|
|
#endif /* _SFXGE_H */
|