openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

bfcmap_vlan.h (5233B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  */
      7 #ifndef BFCMAP_VLANMAP_H
      8 #define BFCMAP_VLANMAP_H
      9 
     10 struct bfcmap_dev_ctrl_s;
     11 
     12 struct bfcmap_port_ctrl_s;
     13 
     14 struct bfcmap_int_hw_mapper_s;
     15 
     16 /*
     17  * The following structure is SW abstraction of FCMAP vlanmap. It 
     18  * contains information about the vlanmap and its corresponding 
     19  * action. Also it keeps tract of the channel ID to which this
     20  * vlanmap is bound (If controlled vlanmap).
     21  */
     22 typedef struct bfcmap_int_vlanmap_entry_s {
     23     /*
     24     int                     vlanmapId;
     25     */
     26 
     27     bfcmap_vlan_vsan_map_t    vlanmap;   /* vlanmap information */
     28 
     29 #define BFCMAP_VLANMAP_F_INSTALLED         0x0001
     30     buint32_t               flags;
     31 
     32     struct bfcmap_port_ctrl_s    *pc;
     33 
     34     /* Next vlanmap entry sharing same bucket index. */
     35     struct bfcmap_int_vlanmap_entry_s  *next;
     36 
     37     /* Index in the mapper table */
     38     int                     hw_index;
     39 
     40     /* MP table to which the vlanmap belongs. */
     41     struct bfcmap_int_hw_mapper_s *mapper;
     42 
     43     /* Pointer to next vlanmap if sharing the same mapper table 
     44      * entry */
     45     struct bfcmap_int_vlanmap_entry_s *hw_next;
     46 
     47 } bfcmap_int_vlanmap_entry_t;
     48 
     49 /*
     50  * The following structure contains the callbacks for comparing
     51  * vlanmap, programming HW vlanmap tables, moving vlanmaps in HW etc.
     52  */
     53 typedef struct bfcmap_int_hw_mapper_vec_s {
     54     int (*mp_cmp)(struct bfcmap_dev_ctrl_s*, struct bfcmap_port_ctrl_s *, 
     55                   bfcmap_int_vlanmap_entry_t*, bfcmap_int_vlanmap_entry_t*, buint32_t);
     56     int (*mp_clear)(struct bfcmap_dev_ctrl_s*, struct bfcmap_port_ctrl_s*,
     57                     int, int, buint32_t);
     58     int (*mp_move)(struct bfcmap_dev_ctrl_s*, struct bfcmap_port_ctrl_s*,
     59                     int, int, int, buint32_t);
     60     int (*mp_write)(struct bfcmap_dev_ctrl_s*, struct bfcmap_port_ctrl_s*,
     61                     bfcmap_int_vlanmap_entry_t*, int, buint32_t);
     62 #if defined (BCM_WARM_BOOT_SUPPORT)  /*  */
     63     int (*mp_read)(struct bfcmap_dev_ctrl_s*, struct bfcmap_port_ctrl_s*,
     64                     bfcmap_int_vlanmap_entry_t*, int,
     65                     bfcmap_int_vlanmap_entry_t**,
     66                     buint32_t);
     67 #endif /* BCM_WARM_BOOT_SUPPORT */
     68 } bfcmap_hw_mapper_vec_t;
     69 
     70 
     71 typedef struct bfcmap_int_hw_mapper_s {
     72     bfcmap_int_vlanmap_entry_t    **hw_vlanmap_tbl;
     73     int                     max_entry;
     74     buint32_t               cb_data;
     75     bfcmap_hw_mapper_vec_t vec;
     76     bfcmap_sal_lock_t      lock;
     77 } bfcmap_int_hw_mapper_t;
     78 
     79 #define BFCMAP_MP_ENTRY_PTR(fil, i)   ((fil)->hw_vlanmap_tbl + (i))
     80 
     81 #define BFCMAP_MP_ENTRY(fil, i)      (*((fil)->hw_vlanmap_tbl + (i)))
     82 
     83 #define BFCMAP_MP_MOVE_ENTRY(mpc,fil,fi,ti,n)    \
     84             (fil)->vec.mp_move((mpc)->parent, (mpc), (fi),(ti),(n),(fil)->cb_data)
     85 
     86 #define BFCMAP_MP_WRITE_ENTRY(mpc,fil,idx)     \
     87             (fil)->vec.mp_write((mpc)->parent, (mpc), BFCMAP_MP_ENTRY((fil),(idx)),(idx),(fil)->cb_data)
     88 
     89 #if defined (BCM_WARM_BOOT_SUPPORT)  /*  */
     90 #define BFCMAP_MP_READ_ENTRY(mpc,fil,idx, new_map)     \
     91             (fil)->vec.mp_read((mpc)->parent, (mpc), BFCMAP_MP_ENTRY((fil),(idx)),(idx), (new_map),(fil)->cb_data)
     92 #endif /* BCM_WARM_BOOT_SUPPORT */
     93 
     94 
     95 #define BFCMAP_MP_CMP_ENTRY(mpc,fil,e1,e2)          \
     96             (fil)->vec.mp_cmp((mpc)->parent, (mpc), (e1),(e2),(fil)->cb_data)
     97 
     98 #define BFCMAP_MP_CLR_ENTRY(mpc,fil,idx,n)          \
     99             (fil)->vec.mp_clear((mpc)->parent,(mpc),(idx),(n),(fil)->cb_data)
    100 
    101 
    102 #define BFCMAP_MP_VLAN_VSAN_VALID(vid,vfid)   \
    103     ( (vid) < (1 << 12) && (vfid) < (1 << 12) )
    104 
    105 
    106 extern int bfcmap_int_vlanmap_init(void);
    107 
    108 extern bfcmap_int_hw_mapper_t *
    109 bfcmap_int_hw_mapper_create(struct bfcmap_port_ctrl_s *mpc, 
    110                      int max_en, 
    111                      buint32_t cb_arg, 
    112                      bfcmap_hw_mapper_vec_t *vec);
    113 
    114 extern bfcmap_int_vlanmap_entry_t*
    115 bfcmap_int_vlanmap_find_by_id(struct bfcmap_port_ctrl_s *mpc,
    116                               int vlanid, int vfid);
    117 
    118 extern bfcmap_int_vlanmap_entry_t*
    119 bfcmap_int_vlanmap_get_next_or_first(struct bfcmap_port_ctrl_s *mpc,
    120                            bfcmap_int_hw_mapper_t  *mapper, 
    121                            int vlanid, int vfid);
    122 
    123 
    124 extern bfcmap_int_vlanmap_entry_t*
    125 bfcmap_int_vlanmap_add_or_update(struct bfcmap_port_ctrl_s *mpc, 
    126                            bfcmap_vlan_vsan_map_t *vlanmap);
    127 
    128 extern int
    129 bfcmap_int_vlanmap_delete(struct bfcmap_port_ctrl_s *mpc,
    130                           int vlanid, int vfid);
    131 
    132 
    133 extern int
    134 bfcmap_int_vlanmap_add_to_hw(struct bfcmap_port_ctrl_s *mpc, 
    135                            bfcmap_int_hw_mapper_t  *mapper,
    136                            bfcmap_int_vlanmap_entry_t *fle);
    137 
    138 #if defined (BCM_WARM_BOOT_SUPPORT)  /*  */
    139 extern int
    140 bfcmap_int_vlanmap_get_from_hw(struct bfcmap_port_ctrl_s *mpc, 
    141                            bfcmap_int_hw_mapper_t  *mapper);
    142 #endif /* BCM_WARM_BOOT_SUPPORT */
    143 
    144 extern int
    145 bfcmap_int_vlanmap_delete_from_hw(struct bfcmap_port_ctrl_s *mpc, 
    146                                 bfcmap_int_hw_mapper_t  *mapper,
    147                                 bfcmap_int_vlanmap_entry_t *fle);
    148 
    149 #endif /* BFCMAP_VLANMAP_H */
    150