# Patent

## Title
Cyclemaster synchronization in a distributed bridge

## Abstract

A method of synchronizing cyclemasters over a distributed bridge is disclosed. The method comprises: a local portal sending a synchronization signal to a peer portal through a bridge fabric upon occurrence of a cycle synchronization event on the local portal; the peer portal sampling its local cycle timer to obtain a sample value when the peer portal receives the synchronization signal; a bridge manager at an upstream portal communicating the sample value to a bridge manager at an alpha portal; the bridge manager at the alpha portal using the sampled time value to compensate for delays through a bridge fabric, calculate the correction to be applied to a cycle timer associated with the alpha portal, and correct the cycle timer.

## Background
This application is a divisional of and claims priority to U.S. patent application Ser. No. 10/749,613 of the same title filed Dec. 29, 2003 now U.S. Pat. No. 7,237,135, incorporated herein by reference in its entirety.


FIELD OF THE INVENTION
The present invention relates broadly to synchronizing devices in communication with each other over a serial bus connection. Specifically, the present invention relates to synchronizing cyclemasters across a distributed bridge architecture in a IEEE 1394-compliant network.
BACKGROUND OF THE INVENTION
The Institute of Electrical and Electronic Engineers (IEEE) has promulgated a number of versions of a high speed serial bus protocol falling under the IEEE 1394 standard (referred to herein collectively as “1394”). A typical serial bus having a 1394 architecture interconnects multiple node devices via point-to-point links, such as cables, each connecting a single node on the serial bus to another node on the serial bus. Data packets are propagated throughout the serial bus using a number of point-to-point transactions, such that a node that receives a packet from another node via a first point-to-point link retransmits the received packet via other point-to-point links. A tree network configuration and associated packet handling protocol ensures that each node receives every packet once. The 1394-compliant serial bus may be used as an alternate bus for the parallel backplane of a computer system, as a low cost peripheral bus, or as a bus bridge between architecturally compatible buses.
The 1394 standard specifies two primary types of bus access: asynchronous access and isochronous access. Asynchronous access may be described as either “fair” or “priority.” Priority access is used by nodes that need the next available asynchronous opportunity to transfer data. Isochronous access is used by nodes that require guaranteed bandwidth with bounded latency, for example, nodes transmitting video or audio data. The transactions for each type of bus access are comprised of at least one subaction, wherein a subaction is a complete one-way transfer operation.
In the case of digital video data transfers within 1394-compliant systems, the video data may be transferred between a mass storage device and a digital video camera or other recorder under the control of a computer processor or other device. The video data is transferred as a series of frames, each frame being made up of a number of data packets. The individual data packets include a number header fields as well as the video data itself. In order to ensure that each frame of the video data is played out in the proper sequence, the frames are time stamped with an appropriate frame presentation time measured in terms of cycle time of an isochronous transaction on a 1394-compliant bus when they are recorded. The cycle time is maintained by a cyclemaster as described in the 1394 standard. The cyclemaster uses priority access to broadcast a cycle start packet. This initiates an isochronous cycle, during which nodes can use isochronous access, and contains the cyclemaster's cycle time clock information so that all nodes associated maintain the necessary synchronization for audio and video data.
Bus bridges between multiple buses of devices forward request and response subactions from one bus to another, allowing transaction requester and responder components to be located on different buses. Each bus has its own cyclemaster. An exemplary 1394-compliant network of three buses of devices is illustrated in FIG. 1. The first bus includes devices a1, a2, and a3 coupled together by 1394-compliant cables. Specifically, device a1 is coupled to device a2 by cable 40. Device a2 is coupled to device a3 by cable 42. Device a3 is then coupled to portal 22 of bridge 20. Bridge 20 couples the first bus to a second bus, which includes the devices b1, b2 and b3. Portal 24 of bridge 20 is coupled to device b1 by cable 46. Device b1 is coupled to device b2 by cable 48. Device b1 is coupled to device b2 by cable 48. Device b2 is coupled to device b3 by cable 50. Device b3 is coupled to portal 32 of bridge 30. Bridge 30 couples the second bus to a third bus that includes the devices c1 and c2. A second portal 34 of bridge 30 is coupled to device c1 by cable 54. Device c1 is coupled to device c2 by cable 56. Bridges 20 and 30 allow devices on the different buses to communicate with each other using both asynchronous and isochronous communications. For example, if device a1 sends a communication to device b3, the communication is passed along the first bus until it reaches portal 22 of bridge 20. Bridge 20 then recognizes that the communication is addressed to the device b3 and forwards the communication from portal 22 to portal 24.
The 1394 standard requires that 1394 bridges implement a method by which all the cyclemasters in a network are kept in phase. The topology used to model the method is shown in FIG. 2. One cycle master is elected to be the master or net cyclemaster. Cyclemasters on buses directly attached to the bus with the net cycle master are kept in phase with the net cycle master. In turn, other buses attached to these buses are kept in phase with the cycle masters on these buses, and so on. Each bridge is responsible for calculating the amount by which the cyclemaster on the bus on its alpha portal (the portal away from the net cyclemaster) is out of phase with the cyclemaster on the bus on its other portal, and accordingly issuing cyclemaster adjustment commands to the cyclemaster on its alpha portal to shorten or lengthen the cycle by one cycle_offset unit (40 ns). According to the method of the 1394 standard, the phase difference is sampled once during each isochronous period. The bridge simultaneously samples the value of CYCLE_TIME.cycle_offset for both of its portals and subtracts, modulus 3072, the upstream portal's cycle offset from the alpha portal's cycle offset.
FIG. 3 illustrates how the delay from the cyclemasters to the respective portals is considered by the 1394 standard method. The two cycle timers connected to the bridge provide, when simultaneously sampled, CYCLE_TIME.cycle_offset values denoted as upstreamOffset and alphaOffset respectively. In the example illustrated in FIG. 3, the upstream delay is 42 units, and the alpha delay is 17 units (as per the example in section 4.4 of the IEEE Serial Bus Protocol 1394.1). When the two cycle timers are simultaneously sampled, the correction to be applied to the alpha cyclemaster is (208+17)−(193+42)=−10. This negative value is interpreted as a “go faster” command, which causes the alpha cyclemaster to wrap at 3070 instead of 3071. The expectation is that on the next isochronous cycle, the difference will then be −9, and the method eventually brings the difference to a zero value.
However, in a distributed bridge, where the two portals are connected by a long haul or wireless medium, there may be no common clock to be sampled by the cycle timers simultaneously, so the method taught by the 1394 standard is useless. It is now desirable to attach devices by wireless connections to 1394 buses, as well as by significantly longer cable lengths. Thus, there is a heartfelt need to provide synchronization of cyclemasters that facilitate connecting wireless or longhaul connections.
SUMMARY
In one aspect of the present invention, a computerized system disclosed. In one embodiment, the computerized system includes: a plurality of buses interconnected by a plurality of bridges, the plurality of bridges comprising a first bridge and a second bridge, the second bridge comprising a first portal. The first bridge comprises a second portal, a third portal, and a bridge fabric, the first portal being in communication with the third portal via the bridge fabric. The second portal is adapted to receive a cycle synchronization event and upon receiving said event, transmit a synchronization signal through the bridge fabric to the third portal. The third portal is adapted to receive the synchronization signal, sample a local timer to obtain a sample value, and transmit the sample value to the first portal. The first portal is adapted to receive the sample value, use the sample value to compensate for at least some delays in transmission over the bridge, and calculate a correction to be applied to a timer associated with the first portal is disclosed.
In another aspect of the present invention, a bridge apparatus is disclosed. In one embodiment, the bridge apparatus includes: a first module adapted to measure delays in propagation over the bridge fabric; a second module adapted to access a timer associated with the first portal, and provide a sample value based at least in part on said access; and a third module adapted to calculate a correction to be applied to a timer associated with a downstream portal if the sample value is provided within a first time period. The correction is based at least in part upon the sample value and upon delays in propagation over the bridge fabric.
In an alternate embodiment, the bridge apparatus includes: a first module adapted to generate an error condition if a downstream device does not receive a first sample value and a second sample value within a first time period; a second module adapted to sample a timer associated with the first portal to obtain the first sample value; a third module adapted to sample a timer associated with the second portal to obtain the second sample value; and a fourth module adapted to calculate delays in propagation over said bridge device. The bridge device is adapted to communicate with software configured to transmit the first sample value and the second sample value to the downstream device.
In another aspect of the present invention, a computerized system for synchronizing devices in communication with each other over a serial bus connection is disclosed. In one embodiment, the computerized system includes: a plurality of buses interconnected by a plurality of bridges, the plurality of bridges comprising a first bridge and a second bridge. The second bridge includes a first portal, and the first bridge comprises a second portal, a third portal, and a bridge fabric. The first portal is in communication with the third portal via the bridge fabric, and is adapted to perform calculation of a correction only when a sample value is received by the first portal within a first time period, and indicate an error condition at least when the sample value is not received by the first portal within the first time period. The second portal is adapted to receive a cycle synchronization event and upon receiving the event, transmit a synchronization signal through the bridge fabric to the third portal. The third portal is adapted to receive the synchronization signal, sample a local timer to obtain a sample value, and transmit the sample value to the first portal.
In another aspect of the invention, a method for bridging a first portal that is in data communication with a second portal is disclosed. In one embodiment, the first and second portals are in communication via a bridge fabric, and the method includes: measuring delays in propagation over the bridge fabric; accessing a timer associated with the first portal, and providing a sample value based at least in part on said access; and calculating a correction to be applied to a timer associated with a downstream portal if the sample value is provided within a first time period. The correction is based at least in part upon the sample value and upon delays in propagation over the bridge fabric.
Many other features and advantages of the present invention will be realized upon reading the following detailed description, when considered in conjunction with the accompanying drawings, in which:



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 illustrates in block diagram form a 1394-compliant network of buses connected by bridges;
FIG. 2 illustrates a bridge connecting buses having separate cyclemasters;
FIG. 3 is a timing diagram that illustrates how cyclemaster synchronization is performed in accordance with prior art 1394 methods; and
FIG. 4 is a timing diagram that illustrates how cyclemaster synchronization in a distributed bridge is performed in accordance with the present invention.
FIG. 5 is a flowchart illustrating a sequence of acts executed in accordance with an embodiment of the present invention.
FIG. 6 is a flowchart illustrating a sequence of acts executed in accordance with another embodiment of the present invention.



DETAILED DESCRIPTION
Embodiments of the present invention utilize the following calculations. a1_co represents the alpha portal cycle offset at any moment in time. up_co represents the upstream portal cycle offset at any moment in time. d represents the real difference between the two cycle offset values (a1_co−up_co). For the time period covered by the sampling time of the algorithm, d is assumed constant, and represents the difference between the “simultaneous sample” values as expressed in the 1394.1 algorithm. fd represents the fabric delay (assumed constant and the same in both directions). up_co′ represents the sampled value of the upstream portal cycle offset when the sampling signal is received from the alpha portal. Then,

up_co′=d+fd  (1)

a1_co represents the sampled value of the alpha portal cycle offset when the sampling signal is received from the upstream portal. Then,

a1_co=−d+fd  (2)

Subtracting (1) from (2) eliminates the fabric delay

a1_co−up_co′=−d+fd−(d+fd)=−2d  (3)

Hence d=−(a1_co−up_co′)/2  (4)

FIG. 4 illustrates the application of formulae (1)-(4), where d=−15, and fd=38. In this embodiment, the upstream portal samples the value 23 when it receives the sampling signal from the alpha portal, and communicates this value to the alpha portal. The alpha portal samples the value 53 when it receives the sampling signal from the upstream portal. When it receives the value 23 from the upstream portal, the difference is calculated as −(23−53)/2=15. In a preferred embodiment, the arithmetic is performed modulo 3072. The isochronous cycle repeats on a nominal 8 Kz clock (125 usec). The cyclemaster clock is itself a 25 Mhz clock. 3072 ticks of this clock measures 125 microseconds. Thus in normal cyclemaster behavior when the cycle offset reaches 3072, a new isochronous cycle is started and the cycle offset reset to zero.
In an embodiment of the present invention, bridge link hardware incorporates an output sample signal, an input sample signal, and a software readable register for storing the sampled values. Directing attention to FIG. 5, the bridge link fabric connects the four signals (output from one portal to the input of the other portal and vice versa) with a constant delay (act 500). Jitter on the delay is bounded by 20 ns-40 ns, preferably closer to 20 ns. The value of the delay is immaterial, except that the sampled value is subsequently accessed by software in the upstream portal (act 502) and communicated to the downstream portal (act 504) in sufficient time for the downstream portal to issue the cycle adjustment command to the cyclemaster (act 504). In the preferred embodiment, the bridge portal hardware also generates an interrupt signal when it takes a sample, and so is ready for software to read the sample and either send it to the alpha portal (upstream portal) or perform the cycle adjustment calculation (alpha portal). An indication, such as error flag, is made by the bridge fabric if either of the sampled signals is not delivered on time. Software uses the indication to abandon cyclemaster adjustment for the current isochronous cycle. Leaving the cyclemaster unadjusted is not problematic if error indications occur rarely. Alternatively, a double-sample scheme similar to the one described below may be used to provide redundancy.
In another embodiment of the present invention, a combined hardware and software implementation can be utilized to provide synchronization of cyclemasters over a distributed bridge. Directing attention to FIG. 6, in this embodiment, the portals have two sample inputs and two registers. The bridge fabric sends sampling signals (act 600) to the local bridge portal at the moment that a message is launched across the bridge fabric and at the moment that a message arrives from the bridge fabric. These signals are used to trigger the sampling mechanisms in the bridge. The alpha portal generates a cycle synchronization interrupt to the local bridge management software (act 602). This queues an appropriate command message to send to its peer across the bridge fabric (act 604). At the moment that the message is launched (act 606), the bridge fabric hardware triggers a cycle_offset sample in the alpha portal bridge hardware (act 608). At the moment that the message arrives at the upstream portal, the bridge fabric hardware triggers the cycle_offset sample in the upstream portal (act 610). The alpha portal uses the local sample to compensate for the software delay in sending the sampling message (act 612). Similarly, the upstream portal takes a local sample at the moment that it sends its sampling message to the alpha portal (act 614). Software in the upstream portal subsequently communicates this value to the software in the alpha portal (act 616), so that software in the alpha portal can compensate for the software delay in the upstream portal in sending the sampling message to the alpha portal (act 618). At this point, the alpha portal now has enough information to determine whether an adjustment to the cyclemaster on its local bus is necessary, and if so command that adjustment. The signals used by the bridge fabric hardware can be readily derived from existing signals. For example, the sampling signal on message arrival can be the same signal as is used to generate an interrupt. Care needs to be taken that the samples are not overwritten by subsequent message transmissions/arrivals before they have been read by software. However, taking samples, for example, on every message, regardless of whether the message is a sampling message or not, is relatively safe. If a message transmission fails for some reason, then it can be retried. In a preferred embodiment, a polling scheme performs the retries and sets a flag when message transmission is complete. If the bridge fabric supports automatic retries, which may affect delivery latency, then the sampling signal for transmit is reasserted.
While embodiments of methods and apparatus for synchronizing cyclemasters over distributed bridges has been illustrated and described, it is to be understood that many variations can be made to embodiments of the present invention, without departing from the spirit thereof.

## Claims

1. A computerized system, comprising:
a plurality of buses interconnected by a plurality of bridges, said plurality of bridges comprising a first bridge and a second bridge, the second bridge comprising a first portal;
wherein the first bridge comprises a second portal, a third portal, and a bridge fabric, the first portal in communication with the third portal via the bridge fabric;
wherein the second portal is adapted to receive a cycle synchronization event and upon receiving said event, transmit a synchronization signal through the bridge fabric to the third portal;
wherein the third portal is adapted to receive the synchronization signal, sample a local timer to obtain a sample value, and transmit the sample value to the first portal;
wherein the first portal is adapted to receive the sample value, use the sample value to compensate for at least some delays in transmission over the bridge, and calculate a correction to be applied to a timer associated with the first portal.

2. The system of claim 1, wherein the first portal is adapted to perform said calculation of said correction only when the sample value is received by the first portal within a first time period.

3. The system of claim 1, wherein the first portal comprises an alpha portal, the alpha portal being further adapted to correct the timer associated with the alpha portal if the sample value is received by the alpha portal within the first time period.

4. A bridge device for use with a first portal that is in data communication with a second portal via a bridge fabric, the device comprising:
a first module adapted to measure delays in propagation over the bridge fabric;
a second module adapted to access a timer associated with the first portal, and provide a sample value based at least in part on said access;
a third module adapted to calculate a correction to be applied to a timer associated with a downstream portal if the sample value is provided within a first time period, wherein said correction is based at least in part upon the sample value and upon delays in propagation over the bridge fabric.

5. The bridge device of claim 4, further comprising the downstream portal; wherein the third module is associated with the downstream portal.

6. The bridge device of claim 4, wherein the second module is further adapted to generate an interrupt when the timer associated with the first portal is sampled.

7. The bridge device of claim 4, further comprising a sample value register, the sample value register adapted to store the sample value.

8. The bridge device of claim 4, wherein the bridge fabric comprises a wireless transmission medium.

9. The bridge device of claim 4, wherein the bridge fabric comprises a protocol adapted to facilitate communications over a local area network.

10. The bridge device of claim 9, wherein the local area network comprises a wireless transmission medium.

11. A bridge device for use with a first portal in data communication with a second portal, comprising:
a first module adapted to generate an error condition if a downstream device does not receive a first sample value and a second sample value within a first time period;
a second module adapted to sample a timer associated with the first portal to obtain the first sample value;
a third module adapted to sample a timer associated with the second portal to obtain the second sample value;
a fourth module adapted to calculate delays in propagation over said bridge device; and
wherein the bridge device is adapted to communicate with software configured to transmit the first sample value and the second sample value to the downstream device.

12. The bridge device of claim 11, further comprising a sample value register, the sample value register adapted to store the first sample value and the second sample value.

13. The bridge device of claim 11, wherein the fourth module is adapted to calculate delays in propagation over said bridge device based at least in part upon the first sample value and the second sample value.

14. The bridge device of claim 11, wherein the bridge device comprises a wireless transmission protocol.

15. The bridge device of claim 11, wherein the bridge device comprises a protocol adapted to facilitate communications over a local area network.

16. The bridge device of claim 11, wherein said bridge device is adapted for use in an IEEE Std. 1394 compliant serial bus network.

17. A computerized system, comprising:
a plurality of buses interconnected by a plurality of bridges, said plurality of bridges comprising a first bridge and a second bridge, the second bridge comprising a first portal;
wherein the first bridge comprises a second portal, a third portal, and a bridge fabric, the first portal in communication with the third portal via the bridge fabric;
wherein the first portal is adapted to perform said calculation of said correction only when the sample value is received by the first portal within a first time period, and indicate an error condition at least when the sample value is not received by the first portal within the first time period;
wherein the second portal is adapted to receive a cycle synchronization event and upon receiving said event, transmit a synchronization signal through the bridge fabric to the third portal;
wherein the third portal is adapted to receive the synchronization signal, sample a local timer to obtain a sample value, and transmit the sample value to the first portal;
wherein the first portal is adapted to receive the sample value, use the sample value to compensate for at least some delays in transmission over the bridge, and calculate a correction to be applied to a timer associated with the first portal.

18. A bridge device for use with a first portal that is in data communication with a second portal via a bridge fabric, the device comprising:
a first module adapted to measure delays in propagation over the bridge fabric;
a second module adapted to access a timer associated with the first portal, and provide a sample value based at least in part on said access;
a third module adapted to calculate a correction to be applied to a timer associated with a downstream portal if the sample value is provided within a first time period, wherein said correction is based at least in part upon the sample value and upon delays in propagation over the bridge fabric; and
a fourth module adapted to indicate an error if the sample value is not successfully provided within the first time period.

19. The bridge device of claim 18, wherein the fourth module is further adapted to indicate an error by setting one or more error flags.

20. A method for bridging a first portal that is in data communication with a second portal via a bridge fabric, comprising:
measuring delays in propagation over the bridge fabric;
accessing a timer associated with the first portal, and
providing a sample value based at least in part on said access;
calculating a correction to be applied to a timer associated with a downstream portal if the sample value is provided within a first time period, wherein said correction is based at least in part upon the sample value and upon delays in propagation over the bridge fabric.

21. The method of claim 20, further comprising the downstream portal; wherein the third module is associated with the downstream portal.

22. The method of claim 20, additionally comprising generating an interrupt when the timer associated with the first portal is sampled.

23. The method of claim 20, additionally comprising storing a sample value to a sample value register.

24. The method of claim 20, wherein the bridge fabric comprises a wireless transmission medium.

25. The method of claim 20, wherein the bridge fabric comprises a protocol adapted to facilitate communications over a local area network.

26. The method of claim 25, wherein the local area network comprises a wireless transmission medium.