IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Commit Details
Date: | 2013-04-30 00:55:25 (10 years 10 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | ff9c7a8ce458031330034aa64bb273a56207fe1b |
Message: | atben/misc/atben-spi-performance.txt: SPI performance comparison This was earlier posted to the mailing lists. Updated the URLs. |
Files: |
atben/misc/atben-spi-performance.txt (1 diff) |
Change Details
atben/misc/atben-spi-performance.txt | ||
---|---|---|
1 | Performance analysis of SPI drivers for ATBEN | |
2 | ============================================= | |
3 | ||
4 | This was originally posted on April 10 2013 to the linux-zigbee and | |
5 | the qi-hardware list. The URLs have been updated for stability. | |
6 | ||
7 | What this is all about | |
8 | ---------------------- | |
9 | ||
10 | The ATBEN board on the Ben NanoNote needs a bit-banging SPI driver. | |
11 | There are several ways to implement this, ranging from reuse of the | |
12 | generic spi-gpio driver to an optimized driver that's specific for | |
13 | this platform. | |
14 | ||
15 | I implemented several such approaches and measured their performance | |
16 | in the Ben NanoNote. Below are my findings. | |
17 | ||
18 | Comments welcome. | |
19 | ||
20 | ||
21 | Cast and characters | |
22 | ------------------- | |
23 | ||
24 | spi_atben_gpio: NanoNote-specific framework for setting up the | |
25 | AT86RF230/1 with SPI-GPIO or one of the optimized drivers (below). | |
26 | The name derives from spi_atben (see below) and should be changed | |
27 | (maybe to atben_spi or atben_spi_gpio ?) since it is not an SPI | |
28 | driver but merely a framework that provides configuration data and | |
29 | performs miscellaneous platform setup. | |
30 | https://github.com/wpwrak/ben-wpan-linux/blob/perfcomp/drivers/net/ieee802154/spi_atben_gpio.c | |
31 | ||
32 | spi_atben: like spi_atben_gpio, but contains a highly optimized | |
33 | SPI driver for the ATBEN configuration in the Ben NanoNote. | |
34 | https://github.com/wpwrak/ben-wpan-linux/blob/perfcomp/drivers/net/ieee802154/spi_atben.c | |
35 | ||
36 | spi-jz4740-gpio: SPI-GPIO driver optimized for the Jz4740. Uses the | |
37 | optimized register accesses from spi_atben but pin assignment is not | |
38 | restricted to ATBEN. The only limitation is that MOSI, MISO, and | |
39 | SCLK must be on the same port. | |
40 | https://github.com/wpwrak/ben-wpan-linux/blob/perfcomp/drivers/spi/spi-jz4740-gpio.c | |
41 | ||
42 | spi-gpio-atben: task-specific SPI-GPIO driver using the #include | |
43 | "spi-gpio.c" method. Replaces gpiolib functions with register | |
44 | accesses specific to the ATBEN configuration in the Ben NanoNote. | |
45 | Note that some of the code could be moved into Jz4740 | |
46 | architecture-specific GPIO support. | |
47 | https://github.com/wpwrak/ben-wpan-linux/blob/perfcomp/drivers/spi/spi-gpio-atben.c | |
48 | ||
49 | In the following sections, we abbreviate the stack configurations | |
50 | as follows: | |
51 | ||
52 | Abbreviation Framework Transport Chip driver | |
53 | --------------- --------------- --------------- ----------- | |
54 | spi-gpio spi_atben_gpio spi-gpio at86rf230 | |
55 | spi-gpio-atben spi_atben_gpio spi-gpio-atben at86rf230 | |
56 | spi-jz4740-gpio spi_atben_gpio spi-jz4740-gpio at86rf230 | |
57 | spi_atben spi_atben at86rf230 | |
58 | ||
59 | ||
60 | Measurements | |
61 | ------------ | |
62 | ||
63 | Access time to AT86RF231 registers and buffer, in microseconds, on | |
64 | an otherwise idle Ben NanoNote: | |
65 | ||
66 | Driver read from 0x51 read 120 bytes from buffer | |
67 | | | write 0x0a to 0x15 write 1 byte to buffer (0x33) | |
68 | | | | read 1 byte from buffer write 120 bytes | |
69 | | | | | | | | | |
70 | spi-gpio 81 85 186 1696 97 1596 | |
71 | spi-gpio-atben 63 59 123 498 65 437 | |
72 | spi-jz4740-gpio 10 8 21 280 10 231 | |
73 | spi_atben 10 7 21 280 10 230 | |
74 | ||
75 | Data rate for hypothetical buffer accesses of infinite length. | |
76 | I.e., kbps = 1000*119*8/(t_write120-t_write1) | |
77 | ||
78 | Driver buffer read (kbps) buffer write (kbps) | |
79 | --------------- ----------------------- ------------------- | |
80 | spi-gpio 630 635 | |
81 | spi-gpio-atben 2549 2559 | |
82 | spi-jz4740-gpio 3676 4308 | |
83 | spi_atben 3676 4327 | |
84 | ||
85 | At the air interface, IEEE 802.15.4 has a data rate of 250 kbps. | |
86 | The AT86RF231 transceiver also supports non-standard higher data | |
87 | rates up to 2 Mbps. | |
88 | ||
89 | Driver(s) Code size (lines) | |
90 | --------------------------------------- ----------------- | |
91 | spi_atben_gpio 128 | |
92 | spi_atben_gpio + spi-gpio-atben 128+ 53 | |
93 | spi_atben_gpio + spi-jz4740-gpio 128+416 | |
94 | spi_atben 423 | |
95 | ||
96 | ||
97 | Computational cost | |
98 | ------------------ | |
99 | ||
100 | The high-level operations of sending and receiving produce the | |
101 | following major low-level operations: | |
102 | ||
103 | Operation register buffer waitqueue | |
104 | read write read write | |
105 | --------------- ------- ------- ------- ------- --------- | |
106 | reception 1 - 1 - 1 | |
107 | transmission 9 4 - 1 1 | |
108 | ||
109 | Using the measured data from above, we get the following total | |
110 | computational overhead in microseconds, without considering the | |
111 | waitqueue scheduling delay: | |
112 | ||
113 | Driver reception transmission | |
114 | 1 120 127 1 120 125 (bytes) | |
115 | --------------- ------- ------- ------- ------- ------- ------- | |
116 | spi-gpio 267 1777 1866 1166 2665 2727 | |
117 | spi-gpio-atben 186 561 583 868 1240 1256 | |
118 | spi-jz4740-gpio 31 290 304 132 353 362 | |
119 | ||
120 | Note that the minimum frame length in IEEE 802.15.4 is 5 bytes. | |
121 | The values for 125 (excluding CRC) and 127 (including CRC) bytes | |
122 | are extrapolated. | |
123 | ||
124 | According to [1], maximum-sized frames can be sent/received, | |
125 | including CSMA/CA and acknowledgement, at a rate between one | |
126 | every 4928 us and one every 7168 us. | |
127 | ||
128 | We would therefore get the following maximum CPU load: | |
129 | ||
130 | Driver Reception Transmission | |
131 | --------------- --------------- ------------ | |
132 | spi-gpio 38% 55% | |
133 | spi-gpio-atben 12% 25% | |
134 | spi-jz4740-gpio 6% 7% | |
135 | ||
136 | ||
137 | Observations | |
138 | ------------ | |
139 | ||
140 | spi-gpio needs the smallest amount of new code but is also very | |
141 | inefficient, making it questionable whether this configuration | |
142 | would yield acceptable performance in regular use. | |
143 | ||
144 | With spi-gpio-atben, only a small amount of code is added, but | |
145 | buffer accesses become almost 4 times faster. Register reads and | |
146 | writes are still fairly slow. | |
147 | ||
148 | spi_atben and spi-jz4740-gpio both achieve the best performance | |
149 | without significant differences between them. Both add a complete | |
150 | SPI driver. Of the two, spi-jz4740-gpio is preferable, because it | |
151 | uses the nearly universal spi_atben_gpio framework driver. | |
152 | ||
153 | ||
154 | Conclusion | |
155 | ---------- | |
156 | ||
157 | I think performance trumps most other considerations in this case. | |
158 | spi-gpio is clearly too inefficient. spi_atben_gpio with | |
159 | spi-jz4740-gpio offers the best performance and has a low impact | |
160 | on the system load (< 10%). In case this solution would be met | |
161 | with strong resistance for some reason, spi-gpio-atben would offer | |
162 | a compromise between performance and the amount of code. | |
163 | ||
164 | ||
165 | References | |
166 | ---------- | |
167 | ||
168 | [1] http://www.jennic.com/files/support_files/JN-AN-1035%20Calculating%20802-15-4%20Data%20Rates-1v0.pdf | |
169 | ||
170 | _______________________________________________ | |
171 | Qi Hardware Discussion List | |
172 | Mail to list (members only): discussion@lists.en.qi-hardware.com | |
173 | Subscribe or Unsubscribe: http://lists.en.qi-hardware.com/mailman/listinfo/discussion |