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

knet.h (8872B)


      1 /*
      2  * 
      3  * 
      4  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5  * 
      6  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      7  * 
      8  * DO NOT EDIT THIS FILE!
      9  * This file is auto-generated.
     10  * Edits to this file will be lost when it is regenerated.
     11  */
     12 
     13 #ifndef __BCM_KNET_H__
     14 #define __BCM_KNET_H__
     15 
     16 #include <bcm/types.h>
     17 #include <bcm/rx.h>
     18 
     19 /* Network interface types */
     20 #define BCM_KNET_NETIF_T_TX_CPU_INGRESS 1          /* Tx packets are sent
     21                                                       through CPU port ingress
     22                                                       logic. */
     23 #define BCM_KNET_NETIF_T_TX_LOCAL_PORT  2          /* Tx packets are sent to
     24                                                       local device port
     25                                                       bypassing switch logic. */
     26 #define BCM_KNET_NETIF_T_TX_META_DATA   3          /* Tx packets are sent using
     27                                                       raw meta data as DMA
     28                                                       descriptors. */
     29 
     30 /* Network interface flags */
     31 #define BCM_KNET_NETIF_F_ADD_TAG        0x00000001 /* Add VLAN tag to packets
     32                                                       sent directly to physical
     33                                                       port. */
     34 #define BCM_KNET_NETIF_F_RCPU_ENCAP     0x00000002 /* Use RCPU encapsulation for
     35                                                       packets that enter and
     36                                                       exit this interface. */
     37 #define BCM_KNET_NETIF_F_KEEP_RX_TAG    0x00000004 /* Keep tag of packets which
     38                                                       will be sent to this
     39                                                       interface. */
     40 
     41 #define BCM_KNET_NETIF_NAME_MAX 16         
     42 
     43 /* Kernel network interface structure. */
     44 typedef struct bcm_knet_netif_s {
     45     int id;                             /* Network interface ID. */
     46     int type;                           /* Network interface type
     47                                            (BCM_KNET_NETIF_T_XXX). */
     48     uint32 flags;                       /* BCM_KNET_NETIF_F_XXX flags. */
     49     bcm_mac_t mac_addr;                 /* MAC address associated with this
     50                                            network interface. */
     51     bcm_vlan_t vlan;                    /* VLAN ID associated with this
     52                                            interface. */
     53     bcm_port_t port;                    /* Local port associated with this
     54                                            interface. */
     55     bcm_cos_queue_t cosq;               /* Cos offset from base queue of port
     56                                            associated with this interface. */
     57     char name[BCM_KNET_NETIF_NAME_MAX]; /* Network interface name (assigned by
     58                                            kernel) */
     59     uint32 cb_user_data;                /* Netif user data for knet rx cb. */
     60 } bcm_knet_netif_t;
     61 
     62 /* Filter types */
     63 #define BCM_KNET_FILTER_T_RX_PKT    1          /* Rx packet filter. */
     64 
     65 /* Filter destinstion types */
     66 #define BCM_KNET_DEST_T_NULL        0          /* Null destination (drop
     67                                                   packet). */
     68 #define BCM_KNET_DEST_T_NETIF       1          /* Send packet to virtual network
     69                                                   interface. */
     70 #define BCM_KNET_DEST_T_BCM_RX_API  2          /* Send packet to BCM Rx API. */
     71 #define BCM_KNET_DEST_T_CALLBACK    3          /* Send packet to kernel
     72                                                   call-back function. */
     73 
     74 /* Filter flags */
     75 #define BCM_KNET_FILTER_F_STRIP_TAG 0x00000001 /* Strip VLAN tag from packets
     76                                                   sent to vitual network
     77                                                   interfaces. */
     78 
     79 #define BCM_KNET_FILTER_DESC_MAX    32         
     80 
     81 #define BCM_KNET_FILTER_SIZE_MAX    256        
     82 
     83 /* Match criteria selection */
     84 #define BCM_KNET_FILTER_M_RAW           0x00000001 /* Match raw packet data */
     85 #define BCM_KNET_FILTER_M_VLAN          0x00000002 /* Match VLAN ID */
     86 #define BCM_KNET_FILTER_M_INGPORT       0x00000004 /* Match local ingress port */
     87 #define BCM_KNET_FILTER_M_SRC_MODPORT   0x00000008 /* Match source module port */
     88 #define BCM_KNET_FILTER_M_SRC_MODID     0x00000010 /* Match source module ID */
     89 #define BCM_KNET_FILTER_M_REASON        0x00000020 /* Match copy-to-CPU reason
     90                                                       code */
     91 #define BCM_KNET_FILTER_M_FP_RULE       0x00000040 /* Match filter processor
     92                                                       rule number */
     93 #define BCM_KNET_FILTER_M_ERROR         0x00000080 /* Match error bit */
     94 
     95 /* Kernel packet filter structure. */
     96 typedef struct bcm_knet_filter_s {
     97     int id;                             /* Filter ID. */
     98     int type;                           /* Filter type (BCM_KNET_FILTER_T_XXX). */
     99     uint32 flags;                       /* BCM_KNET_FILTER_F_XXX flags. */
    100     int priority;                       /* Filter priority (0 is highest). */
    101     int dest_type;                      /* Filter destination type. */
    102     int dest_id;                        /* Filter destination ID. */
    103     int dest_proto;                     /* If non-zero this value overrides the
    104                                            default protocol type when matching
    105                                            packet is passed to network stack. */
    106     int mirror_type;                    /* Mirror destination type. */
    107     int mirror_id;                      /* Mirror destination ID. */
    108     int mirror_proto;                   /* If non-zero this value overrides the
    109                                            default protocol type when matching
    110                                            packet is passed to network stack. */
    111     uint32 match_flags;                 /* BCM_KNET_FILTER_M_XXX flags. */
    112     char desc[BCM_KNET_FILTER_DESC_MAX]; /* Filter description (optional) */
    113     bcm_vlan_t m_vlan;                  /* VLAN ID to match. */
    114     bcm_port_t m_ingport;               /* Local ingress port to match. */
    115     int m_src_modport;                  /* Source module port to match. */
    116     int m_src_modid;                    /* Source module ID to match. */
    117     bcm_rx_reasons_t m_reason;          /* Copy-to-CPU reason to match. */
    118     int m_fp_rule;                      /* Filter processor rule to match. */
    119     int raw_size;                       /* Size of valid raw data and mask. */
    120     uint8 m_raw_data[BCM_KNET_FILTER_SIZE_MAX]; /* Raw data to match. */
    121     uint8 m_raw_mask[BCM_KNET_FILTER_SIZE_MAX]; /* Raw data mask for match. */
    122     uint32 cb_user_data;                /* Filter user data for knet rx cb. */
    123 } bcm_knet_filter_t;
    124 
    125 /* Initialize a bcm_knet_netif_t structure. */
    126 extern void bcm_knet_netif_t_init(
    127     bcm_knet_netif_t *netif);
    128 
    129 /* Initialize a bcm_knet_filter_t structure. */
    130 extern void bcm_knet_filter_t_init(
    131     bcm_knet_filter_t *filter);
    132 
    133 #ifndef BCM_HIDE_DISPATCHABLE
    134 
    135 /* Initialize the kernel networking subsystem. */
    136 extern int bcm_knet_init(
    137     int unit);
    138 
    139 /* Clean up the kernel networking subsystem. */
    140 extern int bcm_knet_cleanup(
    141     int unit);
    142 
    143 /* Create a kernel network interface. */
    144 extern int bcm_knet_netif_create(
    145     int unit, 
    146     bcm_knet_netif_t *netif);
    147 
    148 /* Destroy a kernel network interface. */
    149 extern int bcm_knet_netif_destroy(
    150     int unit, 
    151     int netif_id);
    152 
    153 /* Get a kernel network interface configuration. */
    154 extern int bcm_knet_netif_get(
    155     int unit, 
    156     int netif_id, 
    157     bcm_knet_netif_t *netif);
    158 
    159 #endif /* BCM_HIDE_DISPATCHABLE */
    160 
    161 /* Kernel network interface traverse callback */
    162 typedef int (*bcm_knet_netif_traverse_cb)(
    163     int unit, 
    164     bcm_knet_netif_t *netif, 
    165     void *user_data);
    166 
    167 #ifndef BCM_HIDE_DISPATCHABLE
    168 
    169 /* Traverse kernel network interface objects */
    170 extern int bcm_knet_netif_traverse(
    171     int unit, 
    172     bcm_knet_netif_traverse_cb trav_fn, 
    173     void *user_data);
    174 
    175 /* Create a kernel packet filter. */
    176 extern int bcm_knet_filter_create(
    177     int unit, 
    178     bcm_knet_filter_t *filter);
    179 
    180 /* Destroy a kernel packet filter. */
    181 extern int bcm_knet_filter_destroy(
    182     int unit, 
    183     int filter_id);
    184 
    185 /* Get a kernel packet filter configuration. */
    186 extern int bcm_knet_filter_get(
    187     int unit, 
    188     int filter_id, 
    189     bcm_knet_filter_t *filter);
    190 
    191 #endif /* BCM_HIDE_DISPATCHABLE */
    192 
    193 /* Kernel packet filter traverse callback */
    194 typedef int (*bcm_knet_filter_traverse_cb)(
    195     int unit, 
    196     bcm_knet_filter_t *filter, 
    197     void *user_data);
    198 
    199 #ifndef BCM_HIDE_DISPATCHABLE
    200 
    201 /* Traverse kernel packet filter objects */
    202 extern int bcm_knet_filter_traverse(
    203     int unit, 
    204     bcm_knet_filter_traverse_cb trav_fn, 
    205     void *user_data);
    206 
    207 #endif /* BCM_HIDE_DISPATCHABLE */
    208 
    209 #endif /* __BCM_KNET_H__ */