Print this page
11490 SRS ring polling disabled for VLANs
11491 Want DLS bypass for VLAN traffic
11492 add VLVF bypass to ixgbe core
2869 duplicate packets with vnics over aggrs
11489 DLS stat delete and aggr kstat can deadlock
Portions contributed by: Theo Schlossnagle <jesus@omniti.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>


   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright (c) 2012, Joyent, Inc.  All rights reserved.
  25  */
  26 /*
  27  * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
  28  */
  29 
  30 #ifndef _SYS_MAC_CLIENT_IMPL_H
  31 #define _SYS_MAC_CLIENT_IMPL_H
  32 
  33 #include <sys/modhash.h>
  34 #include <sys/mac_client.h>
  35 #include <sys/mac_provider.h>
  36 #include <sys/mac.h>
  37 #include <sys/mac_impl.h>
  38 #include <sys/mac_stat.h>
  39 #include <net/if.h>
  40 #include <sys/mac_flow_impl.h>
  41 
  42 #ifdef  __cplusplus
  43 extern "C" {
  44 #endif
  45 
  46 extern kmem_cache_t     *mac_client_impl_cache;
  47 extern kmem_cache_t     *mac_unicast_impl_cache;
  48 extern kmem_cache_t     *mac_promisc_impl_cache;
  49 
  50 /*
  51  * Need a list to chain all VIDs assigned to a client. Normally, one
  52  * MAC client only has one VID. But vsw might need multiple VIDs.
  53  */
  54 typedef struct mac_unicast_impl_s {                     /* Protected by */
  55         struct mac_unicast_impl_s       *mui_next;      /* SL */
  56         mac_address_t                   *mui_map;       /* SL */
  57         uint16_t                        mui_vid;        /* SL */
  58 } mac_unicast_impl_t;
  59 
  60 #define MAC_CLIENT_FLAGS_PRIMARY                0X0001
  61 #define MAC_CLIENT_FLAGS_VNIC_PRIMARY           0x0002
  62 #define MAC_CLIENT_FLAGS_MULTI_PRIMARY          0x0004
  63 #define MAC_CLIENT_FLAGS_PASSIVE_PRIMARY        0x0008
  64 
  65 /*
  66  * One of these is instantiated per MAC client promiscuous callback.
  67  *
  68  * Each element of this structure belongs to two linked list. One
  69  * for the mac_client_impl_t (mci_promisc_list) which created allocated
  70  * the callback, the other for the mac_impl_t (mi_promisc_list) corresponding
  71  * to the MAC client.
  72  * The former allows us to do bookkeeping, the latter allows us
  73  * to more efficiently dispatch packets to the promiscuous callbacks.
  74  */
  75 typedef struct mac_promisc_impl_s {                     /* Protected by */
  76         mac_cb_t                        mpi_mci_link;   /* mi_promisc_lock */
  77         mac_cb_t                        mpi_mi_link;    /* mi_promisc_lock */
  78         mac_client_promisc_type_t       mpi_type;       /* WO */
  79         mac_rx_t                        mpi_fn;         /* WO */
  80         void                            *mpi_arg;       /* WO */


 114          * If this is a client that has a pass thru MAC (e.g. a VNIC),
 115          * then we also keep the handle for the client's upper MAC.
 116          */
 117         struct mac_impl_s       *mci_upper_mip;         /* WO */
 118 
 119         uint32_t                mci_state_flags;        /* WO */
 120         mac_rx_t                mci_rx_fn;              /* Rx Quiescence */
 121         void                    *mci_rx_arg;            /* Rx Quiescence */
 122         mac_direct_rx_t         mci_direct_rx_fn;       /* SL */
 123         void                    *mci_direct_rx_arg;     /* SL */
 124         mac_rx_t                mci_rx_p_fn;            /* Rx Quiescence */
 125         void                    *mci_rx_p_arg;          /* Rx Quiescence */
 126         void                    *mci_p_unicast_list;
 127 
 128         mac_cb_t                *mci_promisc_list;      /* mi_promisc_lock */
 129 
 130         mac_address_t           *mci_unicast;
 131         uint32_t                mci_flags;              /* SL */
 132         krwlock_t               mci_rw_lock;
 133         mac_unicast_impl_t      *mci_unicast_list;      /* mci_rw_lock */

 134         /*
 135          * The mac_client_impl_t may be shared by multiple clients, i.e
 136          * multiple VLANs sharing the same MAC client. In this case the
 137          * address/vid tubles differ and are each associated with their
 138          * own flow entry, but the rest underlying components SRS, etc,
 139          * are common.




 140          */
 141         flow_entry_t            *mci_flent_list;        /* mci_rw_lock */
 142         uint_t                  mci_nflents;            /* mci_rw_lock */
 143         uint_t                  mci_nvids;              /* mci_rw_lock */
 144         volatile uint32_t       mci_vidcache;           /* VID cache */
 145 
 146         /* Resource Management Functions */
 147         mac_resource_add_t      mci_resource_add;       /* SL */
 148         mac_resource_remove_t   mci_resource_remove;    /* SL */
 149         mac_resource_quiesce_t  mci_resource_quiesce;   /* SL */
 150         mac_resource_restart_t  mci_resource_restart;   /* SL */
 151         mac_resource_bind_t     mci_resource_bind;      /* SL */
 152         void                    *mci_resource_arg;      /* SL */
 153 
 154 
 155         /* Tx notify callback */
 156         kmutex_t                mci_tx_cb_lock;
 157         mac_cb_info_t           mci_tx_notify_cb_info;  /* cb list info */
 158         mac_cb_t                *mci_tx_notify_cb_list; /* The cb list */
 159         uintptr_t               mci_tx_notify_id;


 296 #define MCIP_VIDCACHE_VIDSHIFT          1
 297 #define MCIP_VIDCACHE_VIDMASK           (UINT16_MAX << MCIP_VIDCACHE_VIDSHIFT)
 298 #define MCIP_VIDCACHE_BOOLSHIFT         0
 299 
 300 #define MCIP_VIDCACHE_INVALID           0
 301 
 302 #define MCIP_VIDCACHE_CACHE(vid, bool)  \
 303         ((1U << MCIP_VIDCACHE_VALIDSHIFT) | \
 304         ((vid) << MCIP_VIDCACHE_VIDSHIFT) | \
 305         ((bool) ? (1U << MCIP_VIDCACHE_BOOLSHIFT) : 0))
 306 
 307 #define MCIP_VIDCACHE_ISVALID(v)        ((v) & (1U << MCIP_VIDCACHE_VALIDSHIFT))
 308 #define MCIP_VIDCACHE_VID(v)            \
 309         (((v) & MCIP_VIDCACHE_VIDMASK) >> MCIP_VIDCACHE_VIDSHIFT)
 310 #define MCIP_VIDCACHE_BOOL(v)           ((v) & (1U << MCIP_VIDCACHE_BOOLSHIFT))
 311 
 312 #define MAC_TAG_NEEDED(mcip)                                            \
 313         (((mcip)->mci_state_flags & MCIS_TAG_DISABLE) == 0 &&            \
 314         (mcip)->mci_nvids == 1)                                              \
 315 




































































 316 /* MCI state flags */
 317 #define MCIS_IS_VNIC                    0x0001
 318 #define MCIS_EXCLUSIVE                  0x0002
 319 #define MCIS_TAG_DISABLE                0x0004
 320 #define MCIS_STRIP_DISABLE              0x0008
 321 #define MCIS_IS_AGGR_PORT               0x0010
 322 #define MCIS_CLIENT_POLL_CAPABLE        0x0020
 323 #define MCIS_DESC_LOGGED                0x0040
 324 #define MCIS_SHARE_BOUND                0x0080
 325 #define MCIS_DISABLE_TX_VID_CHECK       0x0100
 326 #define MCIS_USE_DATALINK_NAME          0x0200
 327 #define MCIS_UNICAST_HW                 0x0400
 328 #define MCIS_IS_AGGR                    0x0800
 329 #define MCIS_RX_BYPASS_DISABLE          0x1000
 330 #define MCIS_NO_UNICAST_ADDR            0x2000
 331 
 332 /* Mac protection flags */
 333 #define MPT_FLAG_V6_LOCAL_ADDR_SET      0x0001
 334 #define MPT_FLAG_PROMISC_FILTERED       0x0002
 335 
 336 /* in mac_client.c */
 337 extern void mac_promisc_client_dispatch(mac_client_impl_t *, mblk_t *);
 338 extern void mac_client_init(void);
 339 extern void mac_client_fini(void);
 340 extern void mac_promisc_dispatch(mac_impl_t *, mblk_t *,
 341     mac_client_impl_t *);
 342 
 343 extern int mac_validate_props(mac_impl_t *, mac_resource_props_t *);
 344 
 345 extern mac_client_impl_t *mac_vnic_lower(mac_impl_t *);
 346 extern mac_client_impl_t *mac_primary_client_handle(mac_impl_t *);
 347 extern uint16_t i_mac_flow_vid(flow_entry_t *);
 348 extern boolean_t i_mac_capab_get(mac_handle_t, mac_capab_t, void *);


   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright (c) 2012, Joyent, Inc.  All rights reserved.
  25  */
  26 /*
  27  * Copyright 2018 Joyent, Inc.
  28  */
  29 
  30 #ifndef _SYS_MAC_CLIENT_IMPL_H
  31 #define _SYS_MAC_CLIENT_IMPL_H
  32 
  33 #include <sys/modhash.h>
  34 #include <sys/mac_client.h>
  35 #include <sys/mac_provider.h>
  36 #include <sys/mac.h>
  37 #include <sys/mac_impl.h>
  38 #include <sys/mac_stat.h>
  39 #include <net/if.h>
  40 #include <sys/mac_flow_impl.h>
  41 
  42 #ifdef  __cplusplus
  43 extern "C" {
  44 #endif
  45 
  46 extern kmem_cache_t     *mac_client_impl_cache;
  47 extern kmem_cache_t     *mac_unicast_impl_cache;
  48 extern kmem_cache_t     *mac_promisc_impl_cache;
  49 
  50 /*
  51  * Need a list to chain all VIDs assigned to a client. Normally, one
  52  * MAC client only has one VID. But vsw might need multiple VIDs.
  53  */
  54 typedef struct mac_unicast_impl_s {                     /* Protected by */
  55         struct mac_unicast_impl_s       *mui_next;      /* SL */
  56         mac_address_t                   *mui_map;       /* SL */
  57         uint16_t                        mui_vid;        /* SL */
  58 } mac_unicast_impl_t;
  59 
  60 #define MAC_CLIENT_FLAGS_PRIMARY                0x0001
  61 #define MAC_CLIENT_FLAGS_VNIC_PRIMARY           0x0002
  62 #define MAC_CLIENT_FLAGS_MULTI_PRIMARY          0x0004
  63 #define MAC_CLIENT_FLAGS_PASSIVE_PRIMARY        0x0008
  64 
  65 /*
  66  * One of these is instantiated per MAC client promiscuous callback.
  67  *
  68  * Each element of this structure belongs to two linked list. One
  69  * for the mac_client_impl_t (mci_promisc_list) which created allocated
  70  * the callback, the other for the mac_impl_t (mi_promisc_list) corresponding
  71  * to the MAC client.
  72  * The former allows us to do bookkeeping, the latter allows us
  73  * to more efficiently dispatch packets to the promiscuous callbacks.
  74  */
  75 typedef struct mac_promisc_impl_s {                     /* Protected by */
  76         mac_cb_t                        mpi_mci_link;   /* mi_promisc_lock */
  77         mac_cb_t                        mpi_mi_link;    /* mi_promisc_lock */
  78         mac_client_promisc_type_t       mpi_type;       /* WO */
  79         mac_rx_t                        mpi_fn;         /* WO */
  80         void                            *mpi_arg;       /* WO */


 114          * If this is a client that has a pass thru MAC (e.g. a VNIC),
 115          * then we also keep the handle for the client's upper MAC.
 116          */
 117         struct mac_impl_s       *mci_upper_mip;         /* WO */
 118 
 119         uint32_t                mci_state_flags;        /* WO */
 120         mac_rx_t                mci_rx_fn;              /* Rx Quiescence */
 121         void                    *mci_rx_arg;            /* Rx Quiescence */
 122         mac_direct_rx_t         mci_direct_rx_fn;       /* SL */
 123         void                    *mci_direct_rx_arg;     /* SL */
 124         mac_rx_t                mci_rx_p_fn;            /* Rx Quiescence */
 125         void                    *mci_rx_p_arg;          /* Rx Quiescence */
 126         void                    *mci_p_unicast_list;
 127 
 128         mac_cb_t                *mci_promisc_list;      /* mi_promisc_lock */
 129 
 130         mac_address_t           *mci_unicast;
 131         uint32_t                mci_flags;              /* SL */
 132         krwlock_t               mci_rw_lock;
 133         mac_unicast_impl_t      *mci_unicast_list;      /* mci_rw_lock */
 134 
 135         /*
 136          * The mac_client_impl_t may be shared by multiple clients, i.e
 137          * multiple VLANs sharing the same MAC client. In this case the
 138          * address/vid tuples differ and are each associated with their
 139          * own flow entry, but the rest underlying components SRS, etc,
 140          * are common.
 141          *
 142          * This is only needed to support sun4v vsw. There are several
 143          * places in MAC we could simplify the code if we removed
 144          * sun4v support.
 145          */
 146         flow_entry_t            *mci_flent_list;        /* mci_rw_lock */
 147         uint_t                  mci_nflents;            /* mci_rw_lock */
 148         uint_t                  mci_nvids;              /* mci_rw_lock */
 149         volatile uint32_t       mci_vidcache;           /* VID cache */
 150 
 151         /* Resource Management Functions */
 152         mac_resource_add_t      mci_resource_add;       /* SL */
 153         mac_resource_remove_t   mci_resource_remove;    /* SL */
 154         mac_resource_quiesce_t  mci_resource_quiesce;   /* SL */
 155         mac_resource_restart_t  mci_resource_restart;   /* SL */
 156         mac_resource_bind_t     mci_resource_bind;      /* SL */
 157         void                    *mci_resource_arg;      /* SL */
 158 
 159 
 160         /* Tx notify callback */
 161         kmutex_t                mci_tx_cb_lock;
 162         mac_cb_info_t           mci_tx_notify_cb_info;  /* cb list info */
 163         mac_cb_t                *mci_tx_notify_cb_list; /* The cb list */
 164         uintptr_t               mci_tx_notify_id;


 301 #define MCIP_VIDCACHE_VIDSHIFT          1
 302 #define MCIP_VIDCACHE_VIDMASK           (UINT16_MAX << MCIP_VIDCACHE_VIDSHIFT)
 303 #define MCIP_VIDCACHE_BOOLSHIFT         0
 304 
 305 #define MCIP_VIDCACHE_INVALID           0
 306 
 307 #define MCIP_VIDCACHE_CACHE(vid, bool)  \
 308         ((1U << MCIP_VIDCACHE_VALIDSHIFT) | \
 309         ((vid) << MCIP_VIDCACHE_VIDSHIFT) | \
 310         ((bool) ? (1U << MCIP_VIDCACHE_BOOLSHIFT) : 0))
 311 
 312 #define MCIP_VIDCACHE_ISVALID(v)        ((v) & (1U << MCIP_VIDCACHE_VALIDSHIFT))
 313 #define MCIP_VIDCACHE_VID(v)            \
 314         (((v) & MCIP_VIDCACHE_VIDMASK) >> MCIP_VIDCACHE_VIDSHIFT)
 315 #define MCIP_VIDCACHE_BOOL(v)           ((v) & (1U << MCIP_VIDCACHE_BOOLSHIFT))
 316 
 317 #define MAC_TAG_NEEDED(mcip)                                            \
 318         (((mcip)->mci_state_flags & MCIS_TAG_DISABLE) == 0 &&            \
 319         (mcip)->mci_nvids == 1)                                              \
 320 
 321 /*
 322  * MAC Client Implementation State (mci_state_flags)
 323  *
 324  * MCIS_IS_VNIC
 325  *
 326  *      The client is a VNIC.
 327  *
 328  * MCIS_EXCLUSIVE
 329  *
 330  *      The client has exclusive control over the MAC, such that it is
 331  *      the sole client of the MAC.
 332  *
 333  * MCIS_TAG_DISABLE
 334  *
 335  *      MAC will not add VLAN tags to outgoing traffic. If this flag
 336  *      is set it is up to the client to add the correct VLAN tag.
 337  *
 338  * MCIS_STRIP_DISABLE
 339  *
 340  *      MAC will not strip the VLAN tags on incoming traffic before
 341  *      passing it to mci_rx_fn. This only applies to non-bypass
 342  *      traffic.
 343  *
 344  * MCIS_IS_AGGR_PORT
 345  *
 346  *      The client represents a port on an aggr.
 347  *
 348  * MCIS_CLIENT_POLL_CAPABLE
 349  *
 350  *      The client is capable of polling the Rx TCP/UDP softrings.
 351  *
 352  * MCIS_DESC_LOGGED
 353  *
 354  *      This flag is set when the client's link info has been logged
 355  *      by the mac_log_linkinfo() timer. This ensures that the
 356  *      client's link info is only logged once.
 357  *
 358  * MCIS_SHARE_BOUND
 359  *
 360  *      This client has an HIO share bound to it.
 361  *
 362  * MCIS_DISABLE_TX_VID_CHECK
 363  *
 364  *      MAC will not check the VID of the client's Tx traffic.
 365  *
 366  * MCIS_USE_DATALINK_NAME
 367  *
 368  *      The client is using the same name as its underlying MAC. This
 369  *      happens when dlmgmtd is unreachable during client creation.
 370  *
 371  * MCIS_UNICAST_HW
 372  *
 373  *      The client requires MAC address hardware classification. This
 374  *      is only used by sun4v vsw.
 375  *
 376  * MCIS_IS_AGGR_CLIENT
 377  *
 378  *      The client sits atop an aggr.
 379  *
 380  * MCIS_RX_BYPASS_DISABLE
 381  *
 382  *      Do not allow the client to enable DLS bypass.
 383  *
 384  * MCIS_NO_UNICAST_ADDR
 385  *
 386  *      This client has no MAC unicast addresss associated with it.
 387  *
 388  */
 389 /* MCI state flags */
 390 #define MCIS_IS_VNIC                    0x0001
 391 #define MCIS_EXCLUSIVE                  0x0002
 392 #define MCIS_TAG_DISABLE                0x0004
 393 #define MCIS_STRIP_DISABLE              0x0008
 394 #define MCIS_IS_AGGR_PORT               0x0010
 395 #define MCIS_CLIENT_POLL_CAPABLE        0x0020
 396 #define MCIS_DESC_LOGGED                0x0040
 397 #define MCIS_SHARE_BOUND                0x0080
 398 #define MCIS_DISABLE_TX_VID_CHECK       0x0100
 399 #define MCIS_USE_DATALINK_NAME          0x0200
 400 #define MCIS_UNICAST_HW                 0x0400
 401 #define MCIS_IS_AGGR_CLIENT             0x0800
 402 #define MCIS_RX_BYPASS_DISABLE          0x1000
 403 #define MCIS_NO_UNICAST_ADDR            0x2000
 404 
 405 /* Mac protection flags */
 406 #define MPT_FLAG_V6_LOCAL_ADDR_SET      0x0001
 407 #define MPT_FLAG_PROMISC_FILTERED       0x0002
 408 
 409 /* in mac_client.c */
 410 extern void mac_promisc_client_dispatch(mac_client_impl_t *, mblk_t *);
 411 extern void mac_client_init(void);
 412 extern void mac_client_fini(void);
 413 extern void mac_promisc_dispatch(mac_impl_t *, mblk_t *,
 414     mac_client_impl_t *);
 415 
 416 extern int mac_validate_props(mac_impl_t *, mac_resource_props_t *);
 417 
 418 extern mac_client_impl_t *mac_vnic_lower(mac_impl_t *);
 419 extern mac_client_impl_t *mac_primary_client_handle(mac_impl_t *);
 420 extern uint16_t i_mac_flow_vid(flow_entry_t *);
 421 extern boolean_t i_mac_capab_get(mac_handle_t, mac_capab_t, void *);