The present invention relates to network processors, and more particularly, to packet processing applications in a network processor.
For packet processing applications running on top of conventional network processors, it is almost mandatory for them to use the underlying hardware facilities to process packets.
However, with this conventional system, the applications directly utilize the specific hardware facilities of the network processor. When an application becomes directly dependent on a specific hardware architecture, it loses its flexibility in function as well as its portability across platforms. The implementation of one application tailored to one platform will inevitably fail on another platform because the other platform uses different mechanisms. Sometimes, the application needs to be changed just because hardware functions are changed without changes in platform.
With the conventional system, customers need to have a comprehensive understanding of the hardware architecture before they can start any implementation or change any of the current solutions. In addition, they need to update their implementations whenever the network processor hardware features are changed. This limits the applicability of their solution and delays their time to market.
Accordingly, there exists a need for a method and apparatus for developing portable packet processing applications on network processors. The method and apparatus should provide flexibility and portability to packet processing across platforms. The present invention addresses such a need.
A method and apparatus for developing portable packet processing applications on network processors includes a docking platform which provides a common interface for individual packet processing applications to be plugged into the network processing environment. Each application interacts with the docking platform through common interfaces provided by the latter. The docking platform interacts with the other modules inside the system to accomplish the requests from the application. In this manner, the applications become “shielded” from the implementation details of the underlying hardware. The applications need not change when the network processor hardware features are changed. It therefore provides a universal packet processing programming environment in which applications can execute in a portable and flexible manner in various hardware architectures.
The present invention provides a method and apparatus for portable packet processing for network processor applications. The following description is presented to enable one of ordinary skill in the art to make and use the invention and is provided in the context of a patent application and its requirements. Various modifications to the preferred embodiment will be readily apparent to those skilled in the art and the generic principles herein may be applied to other embodiments. Thus, the present invention is not intended to be limited to the embodiment shown but is to be accorded the widest scope consistent with the principles and features described herein.
To more particularly describe the features of the present invention, please refer to
In the preferred embodiment, the docking platform 200 comprises an ingress connector 201 as the common mechanism for packet entry, a PPA shell 202 to perform common behaviors and for providing entry points to invoke application specific behavior, and an egress connector 203 as the common mechanism for packet exit. The entry points to invoke application specific behavior are provided by a packet processing module 204 within the PPA shell 202. The PPA shell and the packet processing module 204 will be described further below with reference to
In the preferred embodiment, the PPA shell 202 binds an application procedure to specific entry points using a procedure bind table. The table contains function pointers to application procedures (i.e., callbacks) that the PPA instance needs to register with the PPA shell 202. These procedures are invoked by the PPA Shell 202 upon receipt of the inbound packets via the ingress connector 201. The application procedure bind table also includes pointers to the application data context and the application control context. The application data context refers to data structures defined and used by the application during media packet processing. The application control context refers to data structures defined and used by the application during GMT packet processing. The application procedure bind table is bound once, upon initialization of the PPA instance.
In this example, the ppa_appl_process_media_pkt function is called by the PPA shell 202 to process media packets. The ppa_appl_process_gmt_pkt function is called by the PPA shell 202 to pass GMT service packets to the application for processing. Its input parameters include a pointer to the GMT service packet that needs to be processed.
The ppa_appl_process_time_out function is called by the PPA shell 202 to notify the application of time out events. Its output parameters include the number of ticks to wait for a response if the timer is restarted. It returns a value indicating whether the application wants to restart the timer and continue waiting, is ready to dequeue and process a new packet from the ingress queue using steps 402 and 403 or wants to resume processing of the incumbent packet.
The ppa_appl_process_enable function is called by the PPA shell 202 during PPA enablement, giving the application an opportunity to allocate resources, initialize data, or configure parameters before the application is enable to process packets.
The ppa_appl_process_diable function is called by the PPA shell 202 during PPA disablement, giving an opportunity for the application to release all resources, and perform any other activities to bring itself to a non-operational state.
The ppa_appl_process_reset function is called by the PPA shell 202 when the PPA is reset, giving an opportunity for the application to release all resources, assume default operating parameters, and perform any other activities associated with bringing itself to an initial operational state.
The ppa_appl_process_config function is called by the PPA shell 202 to perform application configuration. This operation sets the configuration parameters for the next application enablement. Its input parameters includes the length of the configuration data in words and a pointer to the application configuration data that are needed in this operation.
The ppa_appl_process pause function is called by the PPA shell 202 when the application needs to be paused. It indicates that the PPA is about to transfer into a “paused” state. The states of a PPA instance are further described below with
The ppa_appl_process_resume function is called by the PPA shell 202 when the PPA changes its state from “paused” to “enabled”. It provides an opportunity for the application to perform any operation necessary for the transition.
The ppa_appl_process_terminate function is called by the PPA shell 202 when the PPA is about to be terminated. At the minimum, the application should free the service handler tables, the data and control context areas that were allocated when the application was created.
The ppa_appl_process_status_query function is called by the PPA shell 202 when the current application status is being queried.
After binding the application procedures, via step 401, the PPA shell 202 calls the dequeue handler 302 of the ingress connector 201, which dequeues a packet from its queue, via step 402, and passes it to the packet processing module 204. The packet is then processed by the packet processing module 204, via step 403. The processed packet can then be transmitted out of the system via the egress connector 203 or discarded. The packet processing then continues in a loop.
Each submodule includes functions comprising a PPA routine 605 for the docking platform 200 and an application function 606 specific to its associated application. The PPA routine 605 is common to any associated application and constitutes the entry point to the application specific function 606. It is the application specific function 606 that is plugged in by the binding of application procedures. When the docking platform 200 calls a function, the corresponding PPA routine 605 is performed. The application procedures associated with the PPA routine 605 is also called, using the function pointer that was plugged in during PPA instance initialization (step 401 of
The PPA process media packet submodule 602 includes the PPA shell function, ppa_process_media_pkt, bound to the application specific function, appl_process_media_pkt, as described above.
The PPA process GMT packet submodule 603 includes the PPA shell function, ppa-process_gmt_pkt, bound to the application specific function, appl_process_gmt_pkt, as described above. Alternatively, the GMT message parser is called when the appl_process_gmt_pkt function is not defined in the application bind table. The GMT message parser handles the processing of GMT packets using service and event handler tables bound during the creation of the PPA instance. If the appl_process_gmt_pkt function is defined, it returns to the ppa_process_gmt_pkt function after processing the GMT packet. The processing of the GMT packet could either be complete or partial. If the processing is complete, the appl_process_gmt_pkt function returns with an appropriate value. This causes the PPA shell 202 to remain in the “enabled-wait_any” state and dequeue the next packet from the ingress queue using step 402 and process it using step 403. Partial processing of a GMT packet is necessitated by the fact that in order to process the incumbent GMT packet, the PPA instance may need to send another GMT packet to a different PPA instance and wait for a response from the latter. In such cases, the appl_process_gmt_pkt function creates and transmits a new GMT service request packet to another PPA instance, using the transmit GMT packet module 702, and then returns to the ppa_process_gmt_pkt function with a return code indicating that it wants to wait for a GMT service response packet. It also provides the duration to wait. This causes the PPA shell 202 to transition to the “enabled-wait_resp” state and start a timer whose duration is as specified by the appl_process_gmt_pkt function. While in this state, the PPA shell 202 only dequeues GMT service response packets or GMT administration packets from the ingress queue using step 402. If a GMT service response packet is received before the expiration of the timer, the PPA shell 202 stops the timer, transitions the state to “enabled-wait_any” and invokes the ppa_process_gmt_pkt function which in turn calls the appl_process_gmt_pkt function with the GMT service response packet as a parameter. If the timer expires before a GMT service response packet is received, the ppa_process_timeout function is invoked, which in turn calls the appl_process_time_out function. The states of a PPA instance are further described below with
The PPA process time out submodule 604 includes the PPA shell function, ppa_process_timeout, bound to the application specific function, appl_process_time_out. The PPA shell 202 invokes the ppa_process_timeout function only while in the “enabled_wait_resp” and the wait timer expires. The ppa_process_timeout function in turn invokes the appl_process_time_out function. The latter, after performing any application-specific time out activity, returns to the ppa_process_timeout function with an appropriate return value indicating whether the PPA shell 202 should restart the timer and continue to wait for a GMT service response packet, abandon waiting and dequeue the next packet from the ingress queue using step 402 for processing using step 403, or continue processing the incumbent GMT service request packet. In the first case, the PPA shell 202 restarts the timer and continues to remain in the “enabled-wait_resp” state. In the second case, the PPA shell 202 transitions to the “enabled-wait_any” state, dequeues the next packet from the ingress queue using step 402 and processes the packet using step 403. In the third case, the PPA shell 202 transitions to the “enabled-wait_any” state and invokes the ppa_process_gmt_pkt function (which in turn invokes the appl_process_gmt_packet function) with null parameters since the incumbent GMT packet is already known to the application.
Once the processing of a packet is completed, the packet is transmitted out of the docking platform 200 through the egress connector 203. The egress connector 203 defines a common set of interfaces for packet transmission. The interfaces allow applications to handle all packets that are likely to be encountered regardless of whether the transmission decision is to send or discard, whether the transmission mode is unicast or multicast, and whether the packet is a data stream or control information.
The transmit GMT packet module 702 includes the ppa_tx_gmt_pkt_mc function, called by the egress connector 203 to transmit a GMT packet in unicast mode, and the ppa_tx_gmt_pkt_mc function, called by the egress connector 203 to transmit a GMT packet in multicast mode.
The discard media packet module 703 includes the ppa_discard_media_pkt function, called by the egress connector to discard a media packet. The discard GMT packet module 704 includes the ppa_discard_gmt_pkt function, called by the egress connector 203 to discard a GMT packet.
Although the preferred embodiment of the present invention is described above in the context of media and GMT packets, one of ordinary skill in the art will understand that other types of packets may be used without departing from the spirit and scope of the present invention.
Although the present invention is described with the above example functions and routines, one of ordinary skill in the art will understand that other functions and/or routines may be used without departing from the spirit and scope of the present invention.
By using the above functionality, the docking platform 200 manages the overall states of the PPA shell 202.
An instance of a docking platform 200 is created by a root thread. At this time, the PPA shell 202 associated with the docking platform 200 instance is in the “disabled” state. Subsequently, the PPA shell 202 can assume one of four states:
Events that trigger state transition include the following:
Although the preferred embodiment of the present invention is described with the above states, one of ordinary skill in the art will understand that other states may be possible without departing from the spirit and scope of the present invention.
A method and apparatus for developing portable packet processing applications on network processor have been disclosed. The preferred embodiment includes a docking platform which provides a common interface for individual applications to be plugged into the processing environment. Each application interacts with the docking platform through the common interfaces. The docking platform interacts with the other modules inside the system to accomplish the requests from the application. In this manner, the applications become “shielded” from the implementation details of the hardware. The applications need not change when the network processor hardware features are changed. It therefore provides a universal packet processing programming environment in which applications can execute in a portable and flexible manner in various hardware architectures.
Although the present invention has been described in accordance with the embodiments shown, one of ordinary skill in the art will readily recognize that there could be variations to the embodiments and those variations would be within the spirit and scope of the present invention. Accordingly, many modifications may be made by one of ordinary skill in the art without departing from the spirit and scope of the appended claims.