session: use custom types for session flags and state 21/40621/3
authorFlorin Coras <fcoras@cisco.com>
Fri, 29 Mar 2024 03:07:31 +0000 (20:07 -0700)
committerDave Barach <vpp@barachs.net>
Fri, 29 Mar 2024 21:45:18 +0000 (21:45 +0000)
Type: improvement

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I04f836d09a1cbd5a5b55dc64359d2d761dfc4988

src/vnet/session/session_types.h

index ce115b2..5e65072 100644 (file)
@@ -154,19 +154,19 @@ typedef enum session_ft_action_
 /*
  * Session states
  */
-#define foreach_session_state                          \
-  _(CREATED, "created")                                        \
-  _(LISTENING, "listening")                            \
-  _(CONNECTING, "connecting")                          \
-  _(ACCEPTING, "accepting")                            \
-  _(READY, "ready")                                    \
-  _(OPENED, "opened")                                  \
-  _(TRANSPORT_CLOSING, "transport-closing")            \
-  _(CLOSING, "closing")                                        \
-  _(APP_CLOSED, "app-closed")                          \
-  _(TRANSPORT_CLOSED, "transport-closed")              \
-  _(CLOSED, "closed")                                  \
-  _(TRANSPORT_DELETED, "transport-deleted")            \
+#define foreach_session_state                                                 \
+  _ (CREATED, "created")                                                      \
+  _ (LISTENING, "listening")                                                  \
+  _ (CONNECTING, "connecting")                                                \
+  _ (ACCEPTING, "accepting")                                                  \
+  _ (READY, "ready")                                                          \
+  _ (OPENED, "opened")                                                        \
+  _ (TRANSPORT_CLOSING, "transport-closing")                                  \
+  _ (CLOSING, "closing")                                                      \
+  _ (APP_CLOSED, "app-closed")                                                \
+  _ (TRANSPORT_CLOSED, "transport-closed")                                    \
+  _ (CLOSED, "closed")                                                        \
+  _ (TRANSPORT_DELETED, "transport-deleted")
 
 typedef enum
 {
@@ -174,7 +174,7 @@ typedef enum
   foreach_session_state
 #undef _
     SESSION_N_STATES,
-} session_state_t;
+} __clib_packed session_state_t;
 
 #define foreach_session_flag                                                  \
   _ (RX_EVT, "rx-event")                                                      \
@@ -225,13 +225,13 @@ typedef struct session_
   session_type_t session_type;
 
   /** State in session layer state machine. See @ref session_state_t */
-  volatile u8 session_state;
+  volatile session_state_t session_state;
 
   /** Index of the app worker that owns the session */
   u32 app_wrk_index;
 
   /** Session flags. See @ref session_flags_t */
-  u32 flags;
+  session_flags_t flags;
 
   /** Index of the transport connection associated to the session */
   u32 connection_index;