/* NCA processing diagram */
/*    */

digraph g {
center=1;
size = "7.5,10";
fontsize="20";
label = "Inktomi CONFIDENTIAL";
orientation = "portrait";

/*************************
 *     States 
 *************************/

"DOOR_UPCALL" [ label = "Door Upcall" ];
"RELEASE_RESOURCES" [ label = "Release Resources From Prior Downcall" ];
"CHECK_FIRST_BIT" [ label = "Check First Bit" shape=diamond ];

/* Subsequent Upcalls */
"FIND_NCA_VCON" [ label = "Find NCA VConn" ];
"CB_HTTPSM" [ label = "Callback HttpSM" ];
"GET_HTTPSM_LOCK" [ label = "Try HttpSM Lock" shape=diamond];
"LOCK_RETRY" [label = "Create Retry Event" ];
"RETRY_EVENT" [label = "Retry Event" ];

/* First Upcall */
"NCA_ACCEPT" [ label = "NCA Accept" ];
"CREATE_NCA_VCON" [ label = "Create NCA VConn" ];
"PARSE_HDR" [label = "Parse Header" ];
"CREATE_NCA_IN_BUF" [label = "Create NCA Read MIOBuffer" ];
"CREATE_HTTPSM" [label = "Create HttpSM" ];

/* Upcall Return */
"HTTPSM_RETURN" [label = "HttpSM Return" ];
"CHECK_FOR_LIVE_IO" [label = "Check IO State" shape=diamond ];
"CHECK_READ_DONE" [label = "Check Read Done" ];
"CHECK_WRITE_DONE" [label = "Check Write Done" ];
"CHECK_BUFFER_SPACE" [label = "Check Buffer Space" ];
"CHECK_FOR_DATA" [label = "Check Buffer For Data" ];
"CLEAR_ADVISE_BIT" [label = "Clear Advise Bit" ];
"VC_CLOSED" [label = "NCA VConn Closed" ];
"NO_IO" [label = "No Active IO" ];
"SET_PREEMPT_BIT" [label = "Set Preempt Bit" ];
"CLEAR_MORE_BIT" [label = "Clear More Bit" ];
"DOOR_DOWNCALL" [label = "Door Downcall" ];

/* Reenable */
"REENABLE_READ" [label = "Reenable Read" ];
"REENABLE_READ_CHECK" [label = "Check Preempt" ];
"CLEAR_PREEMPT" [label = "Clear Preempt Bit" ];
"REENABLE_WRITE" [label = "Reenable Read" ];
"REENABLE_WRITE_CHECK" [label = "Check For Data" ];
"DO_NOTHING" [label = "Do Nothing" ];

/*************************
 *     Transitions 
 *************************/

/* Upcall Start */
"DOOR_UPCALL" -> "RELEASE_RESOURCES";
"RELEASE_RESOURCES" -> "CHECK_FIRST_BIT";

/* Subsequent Upcalls */
"CHECK_FIRST_BIT" -> "FIND_NCA_VCON" [label = "not first" ];
"FIND_NCA_VCON" -> "GET_HTTPSM_LOCK";
"GET_HTTPSM_LOCK" -> "CB_HTTPSM" [ label = "lock acquired" ];
"GET_HTTPSM_LOCK" -> "LOCK_RETRY" [ label = "lock missed" ];
"RETRY_EVENT" -> "GET_HTTPSM_LOCK";
"CB_HTTPSM" -> "HTTPSM_RETURN";

/* First Upcall */
"CHECK_FIRST_BIT" -> "NCA_ACCEPT" [label = "first" ];
"NCA_ACCEPT" -> "CREATE_NCA_VCON";
"CREATE_NCA_VCON"-> "PARSE_HDR";
"PARSE_HDR" -> "CREATE_NCA_IN_BUF";
"CREATE_NCA_IN_BUF" -> "CREATE_HTTPSM";
"CREATE_HTTPSM" -> "HTTPSM_RETURN";

/* Upcall Return */
"HTTPSM_RETURN" -> "CHECK_FOR_LIVE_IO";
"CHECK_FOR_LIVE_IO" -> "CHECK_READ_DONE" [label = "read" ];
"CHECK_FOR_LIVE_IO" -> "CHECK_WRITE_DONE" [label = "write" ];
"CHECK_FOR_LIVE_IO" -> "VC_CLOSED" [label = "closed" ];
"CHECK_FOR_LIVE_IO" -> "NO_IO" [label = "closed" ];
"CHECK_FOR_LIVE_IO" -> "CLEAR_ADVISE_BIT" [label = "advise" ];

/* Read Return */
"CHECK_READ_DONE" -> "SET_PREEMPT_BIT" [label = "done" ];
"CHECK_READ_DONE" -> "CHECK_BUFFER_SPACE" [label = "not_done" ];
"CHECK_BUFFER_SPACE" -> "SET_PREEMPT_BIT" [label = "buffer full" ];
"CHECK_BUFFER_SPACE" -> "DOOR_DOWNCALL" [label = "buffer not full" ];

/* Write Return */
"CHECK_WRITE_DONE" -> "CLEAR_MORE_BIT" [label = "done" ];
"CHECK_WRITE_DONE" -> "CHECK_FOR_DATA" [label = "not done" ];
"CHECK_FOR_DATA" -> "SET_PREEMPT_BIT" [label = "no data"];
"CHECK_FOR_DATA" -> "DOOR_DOWNCALL" [label = "data"];

"CLEAR_ADVISE_BIT" -> "DOOR_DOWNCALL";
"NO_IO" -> "SET_PREEMPT_BIT";
"VC_CLOSED" -> "CLEAR_MORE_BIT";

"CLEAR_MORE_BIT" -> "DOOR_DOWNCALL";
"SET_PREEMPT_BIT" -> DOOR_DOWNCALL;

/* Reenable */
"REENABLE_WRITE" -> "REENABLE_WRITE_CHECK";
"REENABLE_WRITE_CHECK" -> "DO_NOTHING" [label = "no data"];
"REENABLE_WRITE_CHECK" -> "DOOR_DOWNCALL" [label = "data"]

"REENABLE_READ" -> "REENABLE_READ_CHECK";
"REENABLE_READ_CHECK" -> "DO_NOTHING" [label = "no preempt"];
"REENABLE_READ_CHECK" -> "CLEAR_PREEMPT" [label = "preempt"];
"CLEAR_PREEMPT" -> "DOOR_DOWNCALL";

}
