/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
/*
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
#ifndef _SYS_MAC_CLIENT_IMPL_H
#define _SYS_MAC_CLIENT_IMPL_H
#include <sys/mac_client.h>
#include <sys/mac_provider.h>
#include <sys/mac_impl.h>
#include <sys/mac_stat.h>
#include <sys/mac_flow_impl.h>
#ifdef __cplusplus
extern "C" {
#endif
extern kmem_cache_t *mac_client_impl_cache;
extern kmem_cache_t *mac_unicast_impl_cache;
extern kmem_cache_t *mac_promisc_impl_cache;
/*
* Need a list to chain all VIDs assigned to a client. Normally, one
* MAC client only has one VID. But vsw might need multiple VIDs.
*/
/*
* One of these is instantiated per MAC client promiscuous callback.
*
* Each element of this structure belongs to two linked list. One
* for the mac_client_impl_t (mci_promisc_list) which created allocated
* the callback, the other for the mac_impl_t (mi_promisc_list) corresponding
* to the MAC client.
* The former allows us to do bookkeeping, the latter allows us
* to more efficiently dispatch packets to the promiscuous callbacks.
*/
typedef union mac_tx_percpu_s {
struct {
} pcpu_lr;
/*
* One of these is instantiated for each MAC client.
*/
/*
* This flow entry will contain all the internal constructs
* such as SRS etc. for this MAC client. The MAC client may
* have more than one flow corresponding to each upper client
* sharing this mac_client_impl_t.
*/
/*
* If this is a client that has a pass thru MAC (e.g. a VNIC),
* then we also keep the handle for the client's upper MAC.
*/
void *mci_p_unicast_list;
/*
* The mac_client_impl_t may be shared by multiple clients, i.e
* multiple VLANs sharing the same MAC client. In this case the
* own flow entry, but the rest underlying components SRS, etc,
* are common.
*/
/* Resource Management Functions */
/* Tx notify callback */
/* per MAC client stats */ /* None */
/*
* Priority range for this MAC client. This the range
* corresponding to the priority configured (nr_flow_priority).
*/
/*
* Hybrid I/O related definitions.
*/
/* for multicast support */
/*
* Mac protection related fields
*/
/*
* Protected by mci_tx_pcpu[0].pcpu_tx_lock
*/
/* Must be last in the structure for dynamic sizing */
};
#define MAC_CLIENT_IMPL_SIZE \
(sizeof (mac_client_impl_t) + \
(mac_tx_percpu_cnt * sizeof (mac_tx_percpu_t)))
extern int mac_tx_percpu_cnt;
/* Defensive coding, non-null mcip_flent could be an assert */
/*
* We validate the VLAN id of the packet w.r.t the client's vid,
* if required (i.e. !MCIS_DISABLE_TX_VID_CHECK). DLS clients
* will have MCIS_DISABLE_TX_VID_CHECK set.
* (In the case of aggr when we get back packets, due to
* the underlying driver being flow controlled, we won't
* drop the packet even if it is VLAN tagged as we
* don't set MCIS_DISABLE_TX_VID_CHECK for an aggr.)
*/
ETHERTYPE_VLAN) { \
/* \
* err is set to EINVAL (so the caller can take the \
* appropriate action. e.g. freemsg()) for two cases: \
* -client is not responsible for filling in the vid. \
* -client is responsible for filling in the vid, but \
* the vid doesn't match the vid of the MAC client. \
*/ \
struct ether_vlan_header *evhp; \
\
(err) = 0; \
} \
} \
}
/*
* To allow the hot path to not grab any additional locks, we keep a single
* entry VLAN ID cache that caches whether or not a given VID belongs to a
* MAC client.
*/
#define MCIP_VIDCACHE_BOOLSHIFT 0
#define MCIP_VIDCACHE_INVALID 0
((1U << MCIP_VIDCACHE_VALIDSHIFT) | \
((vid) << MCIP_VIDCACHE_VIDSHIFT) | \
((bool) ? (1U << MCIP_VIDCACHE_BOOLSHIFT) : 0))
#define MCIP_VIDCACHE_VID(v) \
(((v) & MCIP_VIDCACHE_VIDMASK) >> MCIP_VIDCACHE_VIDSHIFT)
/* MCI state flags */
/* Mac protection flags */
/* in mac_client.c */
extern void mac_client_init(void);
extern void mac_client_fini(void);
extern void mac_update_resources(mac_resource_props_t *,
extern int mac_client_set_rings_prop(mac_client_impl_t *,
#ifdef __cplusplus
}
#endif
#endif /* _SYS_MAC_CLIENT_IMPL_H */