Print this page
Overlay fabric router

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/overlay_impl.h
          +++ new/usr/src/uts/common/sys/overlay_impl.h
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17  #define _SYS_OVERLAY_IMPL_H
  18   18  
  19   19  /*
  20   20   * Overlay device support
  21   21   */
  22   22  
  23   23  #include <sys/overlay.h>
  24   24  #include <sys/overlay_common.h>
  25   25  #include <sys/overlay_plugin.h>
  26   26  #include <sys/overlay_target.h>
       27 +#include <sys/overlay_router.h>
  27   28  #include <sys/ksynch.h>
  28   29  #include <sys/list.h>
  29   30  #include <sys/avl.h>
  30   31  #include <sys/ksocket.h>
  31   32  #include <sys/socket.h>
  32   33  #include <sys/refhash.h>
  33   34  #include <sys/ethernet.h>
  34   35  #include <sys/list.h>
       36 +#include <sys/atomic.h>
  35   37  
  36   38  #ifdef __cplusplus
  37   39  extern "C" {
  38   40  #endif
  39   41  
  40   42  #define OVEP_VERSION_ONE        0x1
  41   43  
  42   44  typedef struct overlay_plugin {
  43   45          kmutex_t ovp_mutex;
  44   46          list_node_t ovp_link;                   /* overlay_plugin_lock */
↓ open down ↓ 32 lines elided ↑ open up ↑
  77   79          overlay_plugin_dest_t   ott_dest;       /* RO */
  78   80          uint64_t                ott_id;         /* RO */
  79   81          overlay_target_flag_t   ott_flags;      /* ott_lock */
  80   82          uint_t                  ott_ocount;     /* ott_lock */
  81   83          union {                                 /* ott_lock */
  82   84                  overlay_target_point_t  ott_point;
  83   85                  struct overlay_target_dyn {
  84   86                          refhash_t       *ott_dhash;
  85   87                          refhash_t       *ott_l3dhash;
  86   88                          avl_tree_t      ott_tree;
  87      -                        /* XXX: Do we actually need a tree sorted by VL3? */
  88   89                          avl_tree_t      ott_l3tree;
  89   90                  } ott_dyn;
  90   91          } ott_u;
  91   92  } overlay_target_t;
  92   93  
  93      -/*
  94      - * Initially at least, we represent a group of fabrics that are attached to
  95      - * each other as a circular linked list.  Within an overlay_dev_t, we then
  96      - * maintain a list of pointers into these lists for each fabric that's
  97      - * present locally on the CN as we learn them:
  98      - *
  99      - */
 100      -typedef struct overlay_fabric_attach {
 101      -        struct overlay_fabric_attach *ofa_next;
 102      -        struct in6_addr ofa_addr;
 103      -        uint32_t        ofa_dcid;
 104      -        uint16_t        ofa_vlan;
 105      -        uint8_t         ofa_prefixlen;
 106      -        uint8_t         ofa_pad;
 107      -} overlay_fabric_attach_t;
       94 +typedef struct overlay_router {
       95 +        kmutex_t                otr_lock;
       96 +        avl_tree_t              otr_tree;       /* RW tree of all fabrics */
       97 +        list_t                  otr_tables;
       98 +} overlay_router_t;
 108   99  
 109      -/*
 110      - * Since we have two different refhashes for an overlay_target_entry_t
 111      - * (VL2 aka MAC address and VL3 aka IP address), we want to maintain
 112      - * the refcount in only one place. We elect to use the ott_dhash
 113      - * refhash to do so.
 114      - */
 115      -#define OVERLAY_TARGET_ENTRY_HOLD(tgt, e) \
 116      -        refhash_hold((tgt)->ott_u.ott_dyn.ott_dhash, e)
 117      -#define OVERLAY_TARGET_ENTRY_RELE(tgt, e) \
 118      -        refhash_rele((tgt)->ott_u.ott_dyn.ott_dhash, e)
 119      -
 120  100  typedef enum overlay_dev_flag {
 121  101          OVERLAY_F_ACTIVATED     = 0x01, /* Activate ioctl completed */
 122  102          OVERLAY_F_IN_MUX        = 0x02, /* Currently in a mux */
 123  103          OVERLAY_F_IN_TX         = 0x04, /* Currently doing tx */
 124  104          OVERLAY_F_IN_RX         = 0x08, /* Currently doing rx */
 125  105          OVERLAY_F_IOMASK        = 0x0c, /* A mask for rx and tx */
 126  106          OVERLAY_F_MDDROP        = 0x10, /* Drop traffic for metadata update */
 127  107          OVERLAY_F_STOPMASK      = 0x1e, /* None set when stopping */
 128  108          OVERLAY_F_VARPD         = 0x20, /* varpd plugin exists */
 129  109          OVERLAY_F_DEGRADED      = 0x40, /* device is degraded */
↓ open down ↓ 10 lines elided ↑ open up ↑
 140  120          void            *odd_pvoid;             /* RO -- only used by plugin */
 141  121          uint_t          odd_ref;                /* protected by odd_lock */
 142  122          uint_t          odd_mtu;                /* protected by odd_lock */
 143  123          overlay_dev_flag_t odd_flags;           /* protected by odd_lock */
 144  124          uint_t          odd_rxcount;            /* protected by odd_lock */
 145  125          uint_t          odd_txcount;            /* protected by odd_lock */
 146  126          overlay_mux_t   *odd_mux;               /* protected by odd_lock */
 147  127          uint64_t        odd_vid;                /* RO if active else odd_lock */
 148  128          avl_node_t      odd_muxnode;            /* managed by mux */
 149  129          overlay_target_t *odd_target;           /* See big theory statement */
 150      -        overlay_fabric_attach_t **odd_fattach;  /* protected by odd_lock */
      130 +        overlay_router_t *odd_router;
 151  131          uint32_t        odd_dcid;               /* RO if active else odd_lock */
 152  132          uint8_t         odd_macaddr[ETHERADDRL]; /* RO same as odd_dcid */
 153  133          char            odd_fmamsg[OVERLAY_STATUS_BUFLEN];      /* odd_lock */
 154  134  } overlay_dev_t;
 155  135  
      136 +struct overlay_route_table;
      137 +typedef struct overlay_route_table overlay_route_table_t;
      138 +
      139 +typedef struct overlay_fabric_entry {
      140 +        avl_node_t              ofe_avllink;
      141 +        overlay_dev_t           *ofe_odd;
      142 +        overlay_route_table_t   *ofe_route_table;
      143 +        volatile uint32_t       ofe_refcnt;
      144 +        overlay_fabric_t        ofe_fabric;
      145 +        list_t                  ofe_targ_list;
      146 +} overlay_fabric_entry_t;
      147 +#define OVERLAY_FAB_ENTRY_REFHOLD(ofe) atomic_inc_32(&(ofe)->ofe_refcnt)
      148 +#define OVERLAY_FAB_ENTRY_REFRELE(ofe) \
      149 +        (void) ((atomic_dec_32_nv(&(ofe)->ofe_refcnt) != 0) || \
      150 +            (overlay_fabric_entry_free(ofe), 0))
      151 +
      152 +struct overlay_route_table {
      153 +        list_node_t             ort_link;
      154 +        overlay_fabric_entry_t  **ort_dest;
      155 +        size_t                  ort_nalloc;
      156 +};
      157 +
 156  158  typedef enum overlay_target_entry_flags {
 157  159          OVERLAY_ENTRY_F_PENDING         = 0x01, /* lookup in progress */
 158  160          OVERLAY_ENTRY_F_VALID           = 0x02, /* entry is currently valid */
 159  161          OVERLAY_ENTRY_F_DROP            = 0x04, /* always drop target */
 160      -        OVERLAY_ENTRY_F_VALID_MASK      = 0x06
      162 +        OVERLAY_ENTRY_F_ROUTER          = 0x08, /* entry is for router */
      163 +        OVERLAY_ENTRY_F_VALID_MASK      = 0x0e,
      164 +        OVERLAY_ENTRY_F_VL3_PENDING     = 0x10,
      165 +        OVERLAY_ENTRY_F_VL3_VALID       = 0x20,
 161  166  } overlay_target_entry_flags_t;
 162  167  
 163  168  typedef struct overlay_target_entry {
 164  169          kmutex_t                ote_lock;
 165  170          refhash_link_t          ote_reflink;    /* hashtable link */
 166  171          refhash_link_t          ote_l3_reflink; /* IP hashtable link */
 167  172          avl_node_t              ote_avllink;    /* iteration link */
 168      -        avl_node_t              ote_l3_avllink; /* IP iteration link */
      173 +        avl_node_t              ote_l3_avllink; /* IP iteration link */
 169  174          list_node_t             ote_qlink;
      175 +        list_node_t             ote_fablink;
      176 +        volatile uint32_t       ote_refcnt;
 170  177          overlay_target_entry_flags_t ote_flags; /* RW: state flags */
 171      -        uint32_t                ote_dcid;
 172      -        uint16_t                ote_vlan;       /* RO: VL3 vlan id */
 173      -        uint8_t                 ote_addr[ETHERADDRL];   /* RO: mac addr */
 174  178          struct in6_addr         ote_ip;         /* RO: VL3 IP */
      179 +        uint8_t                 ote_addr[ETHERADDRL];   /* RO: mac addr */
 175  180          overlay_target_t        *ote_ott;       /* RO */
 176  181          overlay_dev_t           *ote_odd;       /* RO */
      182 +        overlay_fabric_entry_t  *ote_fab;       /* RO */
 177  183          overlay_target_point_t  ote_dest;       /* RW: destination */
 178  184          mblk_t                  *ote_chead;     /* RW: blocked mb chain head */
 179  185          mblk_t                  *ote_ctail;     /* RW: blocked mb chain tail */
 180  186          size_t                  ote_mbsize;     /* RW: outstanding mblk size */
 181  187          hrtime_t                ote_vtime;      /* RW: valid timestamp */
 182  188  } overlay_target_entry_t;
      189 +#define OVERLAY_TARG_ENTRY_REFHOLD(ote) atomic_inc_32(&(ote)->ote_refcnt)
      190 +#define OVERLAY_TARG_ENTRY_REFRELE(ote) \
      191 +        (void) ((atomic_dec_32_nv(&(ote)->ote_refcnt) != 0) || \
      192 +            (overlay_target_entry_dtor(ote), 0))
 183  193  
 184  194  #define OVERLAY_CTL     "overlay"
 185  195  
 186  196  extern dev_info_t *overlay_dip;
 187  197  
 188  198  extern mblk_t *overlay_m_tx(void *, mblk_t *);
 189  199  
 190  200  typedef int (*overlay_dev_iter_f)(overlay_dev_t *, void *);
 191  201  extern void overlay_dev_iter(overlay_dev_iter_f, void *);
 192  202  
↓ open down ↓ 18 lines elided ↑ open up ↑
 211  221  extern int overlay_mux_tx(overlay_mux_t *, struct msghdr *, mblk_t *);
 212  222  
 213  223  extern void overlay_prop_init(overlay_prop_handle_t);
 214  224  
 215  225  extern void overlay_target_init(void);
 216  226  extern int overlay_target_busy(void);
 217  227  extern int overlay_target_open(dev_t *, int, int, cred_t *);
 218  228  extern int overlay_target_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
 219  229  extern int overlay_target_close(dev_t, int, int, cred_t *);
 220  230  extern void overlay_target_free(overlay_dev_t *);
      231 +extern void overlay_target_entry_dtor(void *);
 221  232  
 222  233  #define OVERLAY_TARGET_OK       0
 223  234  #define OVERLAY_TARGET_DROP     1
 224  235  #define OVERLAY_TARGET_ASYNC    2
 225  236  extern int overlay_target_lookup(overlay_dev_t *, mblk_t *, struct sockaddr *,
 226      -    socklen_t *);
      237 +    socklen_t *, uint64_t *);
      238 +extern void overlay_target_queue(overlay_target_entry_t *);
 227  239  extern void overlay_target_quiesce(overlay_target_t *);
 228  240  extern void overlay_target_fini(void);
 229  241  
      242 +extern int overlay_route_lookup(overlay_dev_t *, mblk_t *,
      243 +    const mac_header_info_t *, struct sockaddr *, socklen_t *, uint64_t *);
      244 +extern int overlay_mblk_vl3ip(mblk_t *, struct in6_addr *, struct in6_addr *);
      245 +extern int overlay_router_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
      246 +extern int overlay_fabric_avl(const void *, const void *);
      247 +
 230  248  extern void overlay_fm_init(void);
 231  249  extern void overlay_fm_fini(void);
 232  250  extern void overlay_fm_degrade(overlay_dev_t *, const char *);
 233  251  extern void overlay_fm_restore(overlay_dev_t *);
 234  252  
 235  253  extern overlay_dev_t *overlay_hold_by_dlid(datalink_id_t);
 236  254  extern void overlay_hold_rele(overlay_dev_t *);
 237  255  
 238  256  #ifdef __cplusplus
 239  257  }
 240  258  #endif
 241  259  
 242  260  #endif /* _SYS_OVERLAY_IMPL_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX