Skip to content

Add cmd to framework

thokala edited this page Nov 9, 2012 · 6 revisions

Commands are represented in tnvme as a C++ classes in tnvme/Cmds directory. For details of commands, refer to https://github.com/nvmecompliance/tnvme/wiki/Commands.

Details on how to add a cmd to framework.

Create a C++ class in tnvme/Cmds directory with the name of the class being the cmd name. For example if the cmd you are adding is Async Event Request Cmd to framework, then the name of the class in the tnvme/Cmds directory should be AsyncEventReq and the files which contain these classes are named as asyncEventReq.cpp and asyncEventReq.h.

All the commands are derived from the base class called Cmd. The resource manager is used to track the objects that are created and destroyed and the new cmd that you are adding is also a resource which should also be added to the framework using shared pointers using boost in order for them to be correctly tracked. In general use any of the existing Cmds/asyncEventReq.h and Cmds/asyncEventReq.cpp to build your cmd by renaming then variables correctly. Replace correct opcode in your cpp file for your command. Determine if the command uses any data buffers and add prp mask support, data direction accordingly. The trackable in the default method reuqires you to provide a name and you should give it as OBJ_YOURCMD. This same object name should be added in the enum definition of the tnvme/trackable.h file for ObjType. Open the file tnvme/trackable.cpp file and in the method Trackable::GetObjName(ObjType obj) add a case of your object and provide a name of the object.

The last step in adding this object to the framework is to add the Singletons/ObjRsrc.cpp file. Open tnvme/Singletons/ObjRsrc.cpp file and add YOURCMD with your class name in the AllocWorker() method using INSTANTIATE_OBJ macro. For the above asyncEvenReq cmd example the marco will be NSTANTIATE_OBJ(ASYNCEVENTREQ, AsyncEventReq).

Clone this wiki locally