Line data Source code
1 : /* 2 : * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef vnsw_agent_gmp_intf_h 6 : #define vnsw_agent_gmp_intf_h 7 : 8 : /* 9 : * GMP interface handle 10 : * 11 : * This structure represents an interface from the GMP toolkit's point of 12 : * view--a pointer to it is defined as the abstract interface ID. 13 : * 14 : * The GMP toolkit uses the same type to represent an interface for both 15 : * the host and router sides. rpd needs to bind different structures in 16 : * the host case (the mgm_instance) and the router case (the gmp_intf). 17 : * So we embed this common structure within each. The structure carries 18 : * a boolean that defines whether we're looking at a host 19 : * or a router interface; with that knowledge we can use the wrapper inlines 20 : * to extract the mgm_inst or gmp_intf structures as appropriate. 21 : * 22 : * The structure also has a thread entry for the transmit interface thread; 23 : * this is used for both host and router interfaces. 24 : */ 25 : typedef struct gmp_intf_handle_ { 26 : boolean gmpifh_host; /* TRUE if this is a host interface */ 27 : task_thread gmpifh_xmit_thread; /* Entry on transmit thread */ 28 : } gmp_intf_handle; 29 : 30 : THREAD_TO_STRUCT(gmp_xmit_thread_to_handle, gmp_intf_handle, 31 : gmpifh_xmit_thread); 32 : 33 : /* 34 : * gmp_intf 35 : * 36 : * This structure is rpd's manifestation of an interface for use by 37 : * GMPR. It is created upon the first reference to an interface in 38 : * configuration (whether or not the physical interface exists or is 39 : * up) and is destroyed when there are no longer any references to the 40 : * interface. gmp_intfs are bound to mgm_ifs (when they are up) and 41 : * are keyed by ifae and protocol. 42 : */ 43 : 44 : typedef struct gmp_intf_ { 45 : patnode gmpif_patnode; /* Patricia node */ 46 : gmp_proto gmpif_proto; /* Protocol (MLD or IGMP) */ 47 : gmp_intf_handle gmpif_handle; /* GMP interface handle */ 48 : uint32_t gmpif_refcount; /* Reference count for locking */ 49 : void *vm_interface; 50 : gmpr_intf_params params; 51 : } gmp_intf; 52 : 53 : PATNODE_TO_STRUCT(gmp_intf_patnode_to_intf, gmp_intf, gmpif_patnode); 54 3 : MEMBER_TO_STRUCT(gmp_handle_to_gif, gmp_intf, gmp_intf_handle, gmpif_handle); 55 : 56 : /* Inlines */ 57 : 58 : /* 59 : * gmp_intf_is_local 60 : * 61 : * Returns TRUE if the gmp_intf pointer represents the local "interface" 62 : * (is NULL) or FALSE if not. 63 : */ 64 : static inline boolean 65 : gmp_intf_is_local (gmp_intf *gif) 66 : { 67 : return (gif == NULL); 68 : } 69 : 70 : 71 : /* 72 : * gmp_gif_to_handle 73 : * 74 : * Convert a gmp_intf pointer to a gmp_intf_handle pointer. If the gmp_intf 75 : * pointer is NULL, we return a NULL handle. 76 : */ 77 : static inline gmp_intf_handle * 78 9 : gmp_gif_to_handle (gmp_intf *gif) 79 : { 80 9 : if (gif) 81 9 : return &gif->gmpif_handle; 82 : else 83 0 : return NULL; 84 : } 85 : 86 : #endif /* vnsw_agent_gmp_intf_h */