bonding: add support for numa-only in lacp mode
[vpp.git] / src / vnet / bonding / node.h
index e1359d0..94b43dc 100644 (file)
@@ -32,7 +32,7 @@
 #endif
 
 #define BOND_MODULO_SHORTCUT(a) \
-  (((a) == 2) || ((a) == 4) || ((a) == 8) || ((a) == 16))
+  (is_pow2 (a))
 
 #define foreach_bond_mode          \
   _ (1, ROUND_ROBIN, "round-robin") \
@@ -70,17 +70,19 @@ typedef enum
 #undef _
 } bond_load_balance_t;
 
-enum
+typedef enum
 {
   BOND_SEND_GARP_NA = 1,
 } bond_send_garp_na_process_event_t;
 
 typedef struct
 {
+  u32 id;
   u8 hw_addr_set;
   u8 hw_addr[6];
   u8 mode;
   u8 lb;
+  u8 numa_only;
   /* return */
   u32 sw_if_index;
   int rv;
@@ -112,9 +114,11 @@ typedef struct
 typedef struct
 {
   u32 sw_if_index;
+  u32 id;
   u8 interface_name[64];
   u8 mode;
   u8 lb;
+  u8 numa_only;
   u32 active_slaves;
   u32 slaves;
 } bond_interface_details_t;
@@ -155,10 +159,20 @@ typedef struct
   u8 mode;
   u8 lb;
 
+  /* This flag works for active-backup mode only
+     and marks if the working port is local numa. */
+  u8 is_local_numa;
+  /* current working sw_if_index in active-bakeup mode. */
+  u32 sw_if_index_working;
   /* the last slave index for the rr lb */
   u32 lb_rr_last_index;
 
+  /* Real device instance in interface vector */
   u32 dev_instance;
+
+  /* Interface ID being shown to user */
+  u32 id;
+
   u32 hw_if_index;
   u32 sw_if_index;
 
@@ -175,6 +189,14 @@ typedef struct
   lacp_port_info_t actor;
   u8 individual_aggregator;
 
+  /* If the flag numa_only is set, it means that only slaves
+     on local numa node works for lacp mode if have at least one,
+     otherwise it works as usual. */
+  u8 numa_only;
+
+  /* How many slaves on local numa node are there in lacp mode? */
+  word n_numa_slaves;
+
   u32 group;
   uword *port_number_bitmap;
   u8 use_custom_mac;
@@ -224,7 +246,7 @@ typedef struct
   lacp_port_info_t partner;
   lacp_port_info_t partner_admin;;
 
-  /* Partner port information */
+  /* Actor port information */
   lacp_port_info_t actor;
   lacp_port_info_t actor_admin;
 
@@ -259,7 +281,16 @@ typedef struct
   f64 actor_churn_timer;
 
   /* time last lacpdu was sent */
-  f64 last_lacpdu_time;
+  f64 last_lacpdu_sent_time;
+
+  /* time last lacpdu was received */
+  f64 last_lacpdu_recd_time;
+
+  /* time last marker pdu was sent */
+  f64 last_marker_pdu_sent_time;
+
+  /* time last marker pdu was received */
+  f64 last_marker_pdu_recd_time;
 
   /* timer used to generate periodic transmission */
   f64 periodic_timer;
@@ -287,6 +318,24 @@ typedef struct
 
   /* bond mode */
   u8 mode;
+
+  /* good lacp pdu received */
+  u64 pdu_received;
+
+  /* bad lacp pdu received */
+  u64 bad_pdu_received;
+
+  /* pdu sent */
+  u64 pdu_sent;
+
+  /* good marker pdu received */
+  u64 marker_pdu_received;
+
+  /* bad marker pdu received */
+  u64 marker_bad_pdu_received;
+
+  /* pdu sent */
+  u64 marker_pdu_sent;
 } slave_if_t;
 
 typedef void (*lacp_enable_disable_func) (vlib_main_t * vm, bond_if_t * bif,
@@ -297,6 +346,9 @@ typedef struct
   /* pool of bonding interfaces */
   bond_if_t *interfaces;
 
+  /* record used interface IDs */
+  uword *id_used;
+
   /* pool of slave interfaces */
   slave_if_t *neighbors;