#ifndef _SYS_MAC_PROVIDER_H
#define _SYS_MAC_PROVIDER_H
#include <sys/types.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
#include <sys/stream.h>
#include <sys/mkdev.h>
#include <sys/mac.h>
#include <sys/mac_flow.h>
#ifdef __cplusplus
extern "C" {
#endif
#define MAC_VERSION_V1 0x1
#define MAC_VERSION MAC_VERSION_V1
#define XCVR_UNDEFINED 0
#define XCVR_NONE 1
#define XCVR_10 2
#define XCVR_100T4 3
#define XCVR_100X 4
#define XCVR_100T2 5
#define XCVR_1000X 6
#define XCVR_1000T 7
#ifdef _KERNEL
typedef enum {
MAC_CAPAB_HCKSUM = 0x00000001,
MAC_CAPAB_LSO = 0x00000008,
MAC_CAPAB_RESERVED1 = 0x00000002,
MAC_CAPAB_RESERVED2 = 0x00000004,
MAC_CAPAB_RINGS = 0x00000010,
MAC_CAPAB_SHARES = 0x00000020,
MAC_CAPAB_MULTIFACTADDR = 0x00000040,
MAC_CAPAB_VNIC = 0x00010000,
MAC_CAPAB_ANCHOR_VNIC = 0x00020000,
MAC_CAPAB_AGGR = 0x00040000,
MAC_CAPAB_NO_NATIVEVLAN = 0x00080000,
MAC_CAPAB_NO_ZCOPY = 0x00100000,
MAC_CAPAB_LEGACY = 0x00200000,
MAC_CAPAB_VRRP = 0x00400000,
MAC_CAPAB_OVERLAY = 0x00800000,
MAC_CAPAB_TRANSCEIVER = 0x01000000,
MAC_CAPAB_LED = 0x02000000
} mac_capab_t;
typedef struct lso_basic_tcp_ipv4_s {
t_uscalar_t lso_max;
} lso_basic_tcp_ipv4_t;
typedef struct lso_basic_tcp_ipv6_s {
t_uscalar_t lso_max;
} lso_basic_tcp_ipv6_t;
#define LSO_TX_BASIC_TCP_IPV4 0x01
#define LSO_TX_BASIC_TCP_IPV6 0x02
typedef struct mac_capab_lso_s {
t_uscalar_t lso_flags;
lso_basic_tcp_ipv4_t lso_basic_tcp_ipv4;
lso_basic_tcp_ipv6_t lso_basic_tcp_ipv6;
} mac_capab_lso_t;
typedef struct mac_capab_multifactaddr_s {
uint_t mcm_naddr;
void (*mcm_getaddr)(void *, uint_t, uint8_t *);
} mac_capab_multifactaddr_t;
typedef struct mac_capab_legacy_s {
uint32_t ml_unsup_note;
dev_t ml_dev;
boolean_t (*ml_active_set)(void *);
void (*ml_active_clear)(void *);
int (*ml_fastpath_disable)(void *);
void (*ml_fastpath_enable)(void *);
} mac_capab_legacy_t;
typedef struct __mac_prop_info_handle *mac_prop_info_handle_t;
typedef int (*mac_getstat_t)(void *, uint_t, uint64_t *);
typedef int (*mac_start_t)(void *);
typedef void (*mac_stop_t)(void *);
typedef int (*mac_setpromisc_t)(void *, boolean_t);
typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *);
typedef int (*mac_unicst_t)(void *, const uint8_t *);
typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *);
typedef void (*mac_resources_t)(void *);
typedef mblk_t *(*mac_tx_t)(void *, mblk_t *);
typedef boolean_t (*mac_getcapab_t)(void *, mac_capab_t, void *);
typedef int (*mac_open_t)(void *);
typedef void (*mac_close_t)(void *);
typedef int (*mac_set_prop_t)(void *, const char *, mac_prop_id_t,
uint_t, const void *);
typedef int (*mac_get_prop_t)(void *, const char *, mac_prop_id_t,
uint_t, void *);
typedef void (*mac_prop_info_t)(void *, const char *, mac_prop_id_t,
mac_prop_info_handle_t);
typedef struct mac_callbacks_s {
uint_t mc_callbacks;
mac_getstat_t mc_getstat;
mac_start_t mc_start;
mac_stop_t mc_stop;
mac_setpromisc_t mc_setpromisc;
mac_multicst_t mc_multicst;
mac_unicst_t mc_unicst;
mac_tx_t mc_tx;
void *mc_reserved;
mac_ioctl_t mc_ioctl;
mac_getcapab_t mc_getcapab;
mac_open_t mc_open;
mac_close_t mc_close;
mac_set_prop_t mc_setprop;
mac_get_prop_t mc_getprop;
mac_prop_info_t mc_propinfo;
} mac_callbacks_t;
#define MC_RESERVED 0x0001
#define MC_IOCTL 0x0002
#define MC_GETCAPAB 0x0004
#define MC_OPEN 0x0008
#define MC_CLOSE 0x0010
#define MC_SETPROP 0x0020
#define MC_GETPROP 0x0040
#define MC_PROPINFO 0x0080
#define MC_PROPERTIES (MC_SETPROP | MC_GETPROP | MC_PROPINFO)
typedef enum {
MAC_NO_CLASSIFIER = 0,
MAC_SW_CLASSIFIER,
MAC_HW_CLASSIFIER,
MAC_PASSTHRU_CLASSIFIER
} mac_classify_type_t;
typedef void (*mac_rx_func_t)(void *, mac_resource_handle_t, mblk_t *,
boolean_t);
#define MAC_VIRT_NONE 0x0
#define MAC_VIRT_LEVEL1 0x1
#define MAC_VIRT_HIO 0x2
typedef enum {
MAC_RING_TYPE_RX = 1,
MAC_RING_TYPE_TX
} mac_ring_type_t;
#define MAC_VLAN_UNTAGGED UINT16_MAX
#define MAC_VLAN_UNTAGGED_VID(vid) \
(((vid) == VLAN_ID_NONE) ? MAC_VLAN_UNTAGGED : (vid))
typedef enum {
MAC_GROUP_TYPE_STATIC = 1,
MAC_GROUP_TYPE_DYNAMIC
} mac_group_type_t;
typedef struct __mac_ring_driver *mac_ring_driver_t;
typedef struct __mac_group_driver *mac_group_driver_t;
typedef struct mac_ring_info_s mac_ring_info_t;
typedef struct mac_group_info_s mac_group_info_t;
typedef void (*mac_get_ring_t)(void *, mac_ring_type_t, const int, const int,
mac_ring_info_t *, mac_ring_handle_t);
typedef void (*mac_get_group_t)(void *, mac_ring_type_t, const int,
mac_group_info_t *, mac_group_handle_t);
typedef void (*mac_group_add_ring_t)(mac_group_driver_t,
mac_ring_driver_t, mac_ring_type_t);
typedef void (*mac_group_rem_ring_t)(mac_group_driver_t,
mac_ring_driver_t, mac_ring_type_t);
typedef struct mac_capab_rings_s {
mac_ring_type_t mr_type;
mac_group_type_t mr_group_type;
uint_t mr_rnum;
uint_t mr_gnum;
mac_get_ring_t mr_rget;
mac_get_group_t mr_gget;
mac_group_add_ring_t mr_gaddring;
mac_group_rem_ring_t mr_gremring;
} mac_capab_rings_t;
typedef int (*mac_ring_start_t)(mac_ring_driver_t, uint64_t);
typedef void (*mac_ring_stop_t)(mac_ring_driver_t);
typedef mblk_t *(*mac_ring_send_t)(void *, mblk_t *);
typedef mblk_t *(*mac_ring_poll_t)(void *, int);
typedef int (*mac_ring_stat_t)(mac_ring_driver_t, uint_t, uint64_t *);
typedef struct mac_ring_info_s {
mac_ring_driver_t mri_driver;
mac_ring_start_t mri_start;
mac_ring_stop_t mri_stop;
mac_intr_t mri_intr;
union {
mac_ring_send_t send;
mac_ring_poll_t poll;
} mrfunion;
mac_ring_stat_t mri_stat;
uint_t mri_flags;
} mac_ring_info_s;
#define mri_tx mrfunion.send
#define mri_poll mrfunion.poll
#define MAC_RING_TX_SERIALIZE 0x1
#define MAC_RING_RX_ENQUEUE 0x2
typedef int (*mac_group_start_t)(mac_group_driver_t);
typedef void (*mac_group_stop_t)(mac_group_driver_t);
typedef int (*mac_add_mac_addr_t)(void *, const uint8_t *);
typedef int (*mac_rem_mac_addr_t)(void *, const uint8_t *);
typedef int (*mac_add_vlan_filter_t)(mac_group_driver_t, uint16_t);
typedef int (*mac_rem_vlan_filter_t)(mac_group_driver_t, uint16_t);
struct mac_group_info_s {
mac_group_driver_t mgi_driver;
mac_group_start_t mgi_start;
mac_group_stop_t mgi_stop;
uint_t mgi_count;
mac_intr_t mgi_intr;
mac_add_mac_addr_t mgi_addmac;
mac_rem_mac_addr_t mgi_remmac;
mac_add_vlan_filter_t mgi_addvlan;
mac_rem_vlan_filter_t mgi_remvlan;
};
typedef uint64_t mac_share_handle_t;
typedef int (*mac_alloc_share_t)(void *, mac_share_handle_t *);
typedef void (*mac_free_share_t)(mac_share_handle_t);
typedef int (*mac_bind_share_t)(mac_share_handle_t, uint64_t, uint64_t *);
typedef void (*mac_unbind_share_t)(mac_share_handle_t);
typedef void (*mac_share_query_t)(mac_share_handle_t, mac_ring_type_t,
mac_ring_handle_t *, uint_t *);
typedef int (*mac_share_add_group_t)(mac_share_handle_t,
mac_group_driver_t);
typedef int (*mac_share_rem_group_t)(mac_share_handle_t,
mac_group_driver_t);
typedef struct mac_capab_share_s {
uint_t ms_snum;
void *ms_handle;
mac_alloc_share_t ms_salloc;
mac_free_share_t ms_sfree;
mac_share_add_group_t ms_sadd;
mac_share_rem_group_t ms_sremove;
mac_share_query_t ms_squery;
mac_bind_share_t ms_sbind;
mac_unbind_share_t ms_sunbind;
} mac_capab_share_t;
typedef struct mac_capab_vrrp_s {
int mcv_af;
} mac_capab_vrrp_t;
typedef struct mac_transceiver_info mac_transceiver_info_t;
typedef struct mac_capab_transceiver {
uint_t mct_flags;
uint_t mct_ntransceivers;
int (*mct_info)(void *, uint_t, mac_transceiver_info_t *);
int (*mct_read)(void *, uint_t, uint_t, void *, size_t, off_t,
size_t *);
} mac_capab_transceiver_t;
typedef struct mac_capab_led {
uint_t mcl_flags;
mac_led_mode_t mcl_modes;
int (*mcl_set)(void *, mac_led_mode_t, uint_t);
} mac_capab_led_t;
typedef struct mac_register_s {
uint_t m_version;
const char *m_type_ident;
void *m_driver;
dev_info_t *m_dip;
uint_t m_instance;
uint8_t *m_src_addr;
uint8_t *m_dst_addr;
mac_callbacks_t *m_callbacks;
uint_t m_min_sdu;
uint_t m_max_sdu;
void *m_pdata;
size_t m_pdata_size;
char **m_priv_props;
uint32_t m_margin;
uint32_t m_v12n;
uint_t m_multicast_sdu;
} mac_register_t;
extern mac_protect_t *mac_protect_get(mac_handle_t);
extern void mac_sdu_get(mac_handle_t, uint_t *, uint_t *);
extern void mac_sdu_get2(mac_handle_t, uint_t *, uint_t *,
uint_t *);
extern int mac_maxsdu_update(mac_handle_t, uint_t);
extern int mac_maxsdu_update2(mac_handle_t, uint_t,
uint_t);
extern mac_register_t *mac_alloc(uint_t);
extern void mac_free(mac_register_t *);
extern int mac_register(mac_register_t *, mac_handle_t *);
extern int mac_disable_nowait(mac_handle_t);
extern int mac_disable(mac_handle_t);
extern int mac_unregister(mac_handle_t);
extern void mac_rx(mac_handle_t, mac_resource_handle_t,
mblk_t *);
extern void mac_rx_ring(mac_handle_t, mac_ring_handle_t,
mblk_t *, uint64_t);
extern void mac_link_update(mac_handle_t, link_state_t);
extern void mac_link_redo(mac_handle_t, link_state_t);
extern void mac_unicst_update(mac_handle_t,
const uint8_t *);
extern void mac_dst_update(mac_handle_t, const uint8_t *);
extern void mac_tx_update(mac_handle_t);
extern void mac_tx_ring_update(mac_handle_t,
mac_ring_handle_t);
extern void mac_capab_update(mac_handle_t);
extern int mac_pdata_update(mac_handle_t, void *,
size_t);
extern void mac_multicast_refresh(mac_handle_t,
mac_multicst_t, void *, boolean_t);
extern void mac_unicst_refresh(mac_handle_t, mac_unicst_t,
void *);
extern void mac_promisc_refresh(mac_handle_t,
mac_setpromisc_t, void *);
extern boolean_t mac_margin_update(mac_handle_t, uint32_t);
extern void mac_margin_get(mac_handle_t, uint32_t *);
extern int mac_margin_remove(mac_handle_t, uint32_t);
extern int mac_margin_add(mac_handle_t, uint32_t *,
boolean_t);
extern void mac_init_ops(struct dev_ops *, const char *);
extern void mac_fini_ops(struct dev_ops *);
extern int mac_devt_to_instance(dev_t);
extern int mac_getinfo(dev_info_t *, ddi_info_cmd_t,
void *, void **);
extern minor_t mac_private_minor(void);
extern void mac_ring_intr_set(mac_ring_handle_t,
ddi_intr_handle_t);
extern mactype_register_t *mactype_alloc(uint_t);
extern void mactype_free(mactype_register_t *);
extern int mactype_register(mactype_register_t *);
extern int mactype_unregister(const char *);
extern boolean_t mac_unicst_verify(mac_handle_t,
const uint8_t *, uint_t);
extern int mac_group_add_ring(mac_group_handle_t, int);
extern void mac_group_rem_ring(mac_group_handle_t,
mac_ring_handle_t);
extern mac_ring_handle_t mac_find_ring(mac_group_handle_t, int);
extern void mac_prop_info_set_default_uint8(
mac_prop_info_handle_t, uint8_t);
extern void mac_prop_info_set_default_str(
mac_prop_info_handle_t, const char *);
extern void mac_prop_info_set_default_uint64(
mac_prop_info_handle_t, uint64_t);
extern void mac_prop_info_set_default_uint32(
mac_prop_info_handle_t, uint32_t);
extern void mac_prop_info_set_default_link_flowctrl(
mac_prop_info_handle_t, link_flowctrl_t);
extern void mac_prop_info_set_default_fec(
mac_prop_info_handle_t, link_fec_t);
extern void mac_prop_info_set_range_uint32(
mac_prop_info_handle_t,
uint32_t, uint32_t);
extern void mac_prop_info_set_perm(mac_prop_info_handle_t,
uint8_t);
extern void mac_hcksum_get(const mblk_t *, uint32_t *,
uint32_t *, uint32_t *, uint32_t *,
uint32_t *);
extern void mac_hcksum_set(mblk_t *, uint32_t, uint32_t,
uint32_t, uint32_t, uint32_t);
extern void mac_hcksum_clone(const mblk_t *, mblk_t *);
extern void mac_lso_get(mblk_t *, uint32_t *, uint32_t *);
extern void mac_transceiver_info_set_present(
mac_transceiver_info_t *,
boolean_t);
extern void mac_transceiver_info_set_usable(
mac_transceiver_info_t *,
boolean_t);
typedef enum mac_ether_offload_flags {
MEOI_L2INFO_SET = 1 << 0,
MEOI_L3INFO_SET = 1 << 1,
MEOI_L4INFO_SET = 1 << 2,
MEOI_VLAN_TAGGED = 1 << 3,
MEOI_L3_FRAG_MORE = 1 << 4,
MEOI_L3_FRAG_OFFSET = 1 << 5
} mac_ether_offload_flags_t;
typedef struct mac_ether_offload_info {
mac_ether_offload_flags_t meoi_flags;
size_t meoi_len;
uint8_t meoi_l2hlen;
uint16_t meoi_l3proto;
uint16_t meoi_l3hlen;
uint8_t meoi_l4proto;
uint8_t meoi_l4hlen;
} mac_ether_offload_info_t;
#define MEOI_VLAN_TCI_INVALID UINT32_MAX
extern boolean_t mac_ether_l2_info(mblk_t *, uint8_t *, uint32_t *);
extern void mac_ether_offload_info(mblk_t *, mac_ether_offload_info_t *);
extern void mac_partial_offload_info(mblk_t *, size_t,
mac_ether_offload_info_t *);
#endif
#ifdef __cplusplus
}
#endif
#endif