netcp-pa.txt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. Keystone NETCP Packet Accelarator (PA and PA2) Device Driver
  2. ------------------------------------------------------------
  3. This document describes the Keystone NetCP PA device driver. To Know more
  4. details on the hardware, please refers to the following hardware documents:-
  5. Packet Accelerator (PA) for KeyStone Devices User's Guide
  6. http://www.ti.com/lit/ug/sprugs4a/sprugs4a.pdf
  7. KeyStone Architecture II Packet Accelerator 2 (PA2) for K2E and K2L Devices
  8. User's Guide
  9. http://www.ti.com/lit/ug/spruhz2/spruhz2.pdf
  10. Here is a description of the PA hardware as given in the above UG.
  11. The packet accelerator (PA) is one of the main components of the network
  12. coprocessor (NETCP) peripheral. The PA works together with the security
  13. accelerator (SA) and the gigabit Ethernet switch subsystem to form a
  14. network processing solution. The purpose of PA in the NETCP is to perform
  15. packet processing operations such as packet header classification, checksum
  16. generation, and multi-queue routing.
  17. The below section shows the packet flow in the hardware and the hardware
  18. resources associated with the same.
  19. (Resource map and Packet flow diagram)
  20. --------------------------------------
  21. Packet flow ---------------------------
  22. | Linux NetCP PA device |
  23. Ingress (CPSW port x) ---------------------------
  24. | | | | | |
  25. V | | | | |
  26. CPSW | | | | |
  27. | commands | | | ----
  28. | Packet Parse to LUT1 | ---- ^
  29. V -------- | ^ |
  30. ----------Cluster 0-------------- | Chan 0 | | queue
  31. | PDSP0 | L2 Classify Engine | <----| 640 <---| | for
  32. | | Pass 1 LUT 0 | --------- | | flow 31
  33. --------------------------------- | | (Command
  34. Match | | fail route to flow (22 to 25) | | Response)
  35. | ----> xxxx | |
  36. | | |
  37. | commands | Per port Queue
  38. | exception route to PDSP5 | Mapped to flows
  39. V Packet Parse to L3 LUT2 | (22 to 25)
  40. ----------Cluster 1-------------- --------- | for data packets
  41. | | | | |
  42. | | | | Chan 1 |
  43. | PDSP1 | L3 Classify Engine 0 | <----| 641 <---|
  44. | | Pass 1 LUT 1 | --------- |
  45. | | classifcation of | |
  46. | | packet using IP/L3 hdr| |
  47. --------------------------------- |
  48. Match | | fail route to flow |
  49. V -----> (22 to 25)----> xxxx |
  50. ----------Cluster 2-------------- |
  51. | PDSP2 | L3 Classify Engine 1 | |
  52. | | Pass 1 LUT 2 | (not used by |
  53. | | classification of | Linux driver) |
  54. | | IPSec packet using | |
  55. | | inner IP header | |
  56. --------------------------------- |
  57. Match | | fail route to flow |
  58. V ------> (22 to 25)----> xxxx |
  59. ----------Cluster 3-------------- |
  60. | PDSP3 | L4 Classify Engine | (not used by |
  61. | | Pass 2 LUT 2 | Linux driver) |
  62. | | classification of IP | |
  63. | | packet using L4 hdr | |
  64. | | TCP/UDP/Custom | |
  65. --------------------------------- |
  66. |
  67. |
  68. ----------Cluster 4-------------- |
  69. | PDSP4 | Modify/Multi route | |
  70. | | Engine 0 | (not used by |
  71. | | | Linux driver) |
  72. --------------------------------- |
  73. |
  74. ----------Cluster 5-------------- flows |
  75. | PDSP5 | Modify/Multi route | 22 to 25 |
  76. | | Engine 1 |---> xxxx |
  77. | | | |
  78. --------------------------------- (Not used by |
  79. Linux driver) |
  80. ---------- |
  81. | Chan 4 |
  82. |-----------------------| Queue 644 |
  83. V ----------- |
  84. ----------Cluster 4------------- |
  85. | PDSP4 | Modify/Multi route | |
  86. ---| | Engine | |
  87. | | | (Generate L4 | commands |
  88. | | | checksum - UDP/TCP/ | tx checksum/crc |
  89. | | | SCTP) | |
  90. | --------------------------------- Data packets |
  91. | ---------- |
  92. | | Chan 5 |
  93. | |-----------------------| Queue 645<-|
  94. | V -----------
  95. | ----------Cluster 5-------------
  96. | | PDSP5 | Modify/Multi route |
  97. | | | Engine |
  98. | | | (Generate L4 |
  99. | | | checksum - UDP/ |
  100. | | | TCP/SCTP) |
  101. | ---------------------------------
  102. | |
  103. |---------------->|
  104. |
  105. V
  106. CPSW
  107. |
  108. V
  109. Egress (CPSW port x)
  110. |
  111. V
  112. HW Queues 640-645 are for PA cluster 0-5
  113. Tx chan 0-5 are associated with the above queues
  114. Rx flows 31 for command response
  115. Rx flows 22-25 for rx data from each ethernet port
  116. Design Notes
  117. ------------
  118. PA driver PA PDSP interface code re-uses code from PA LLD and it is
  119. necessary to keep this code as close to PA LLD as possible for ease
  120. of maintenance.
  121. The driver sends commands to L2 (cluster 0) and L3 engines (cluster 1)
  122. to add MAC address and IP address in the respective LUTs. In the Egress
  123. path, it receives packet from NetCP core driver through tx_hook and format
  124. the commands to do tx checksums and add the command to PS Data field of
  125. the hw descriptor that is then queued to the Modify/Multi route Engine
  126. 1 for PA on K2HK SoC (cluster 6 on PA on K2E/L SoC). On the Ingress path,
  127. PA driver configures the streaming switch to route the packets to cluster
  128. 0 for processng which then travels through other clusters based on rules
  129. setup in the LUT.
  130. PA resources such as LUT tables are shared resources across ARM and DSP
  131. applications. It is expected that Linux PA driver adds entries to pre
  132. defined indices in the table and others are used by other applications.
  133. Generally packets are matched and routed to specific applicaitions and
  134. rest of the packets fail back to Linux netcp PA device for handling.
  135. Other notes:-
  136. Cluster 5 (Modify/Multi route Engine)
  137. - Configuration command for exception processing in all stages
  138. - PDSP5 is the least busy PDSP and chosen for this
  139. Ingress
  140. - Added entries in IP LUT to match UDP/TCP and forward the same
  141. to L4 LUT2
  142. - IP checksum & SCTP crc verified at L3 Engine 0
  143. - UDP/TCP checksum verified at L4 Engine
  144. Egress
  145. - IP/UDP/TCP/SCTP checksum calculated in Modify or Multi route
  146. Keystone NETCP PA Device for K2E/L
  147. (resource map and packet flow diagram)
  148. ===============================================================================
  149. Keystone NETCP PA Device Driver for K2E/L SoC
  150. (Resource map and Packet flow diagram)
  151. ---------------------------------------------
  152. Packet flow ---------------------------
  153. | Linux NetCP PA device |
  154. Ingress (CPSW port x) ---------------------------
  155. | | | | | |
  156. V | | | | |
  157. CPSW | | | | |
  158. | commands | | | ----
  159. | Packet parse to LUT1 | ---- ^
  160. V | ^ |
  161. --------cluster 0 --------------- | | Queue
  162. | Ingress 0 | |--------- | | for
  163. |-------------------------------| | Chan 8 | | flow 31
  164. | PDSP0 | LUT1_0 (MAC classify) | <--| Queue 904<---| | (Command
  165. | PDSP1 | LUT1_1 (Outer IP ACL) | --------- | | Response)
  166. | | | | |
  167. --------------------------------- | |
  168. Match | | fail route to flow( 22 to 29) | |
  169. | ----> | |
  170. | commands | |
  171. | exception route to cluster 5 | |
  172. | Packet Parse to L3 Ingress | |
  173. V 1, LUT1_0 | Per port Queues
  174. --------cluster 1 --------------- | Mapped to flows
  175. | Ingress 1 | | 22..30
  176. |--------------------------------| | (data)
  177. | PDSP0 | LUT1_0 (Outer IP | ------------ |
  178. | | classify, | | Chan 9 |
  179. | PDSP1 | Custom header) |<---| Queue 905<--|
  180. | | LUT1_1 (IPSEC NAT-T) | ------------ |
  181. | | (IPSEC classify | |
  182. | | first pass) | |
  183. --------------------------------- |
  184. Match | |
  185. V |
  186. --------Cluster 2 --------------| |
  187. | Ingress 2 | |
  188. |-------------------------------| |
  189. | PDSP0 | LUT1_0 (IPSEC classify| |
  190. | | second pass) | |
  191. --------------------------------- |
  192. | |
  193. V |
  194. --------Cluster 3---------------- |
  195. | Ingress 3 | |
  196. |-------------------------------- |
  197. | PDSP0 | LUT1_0(Inner IP | |
  198. | | firewall (ACL) | |
  199. | | Reassembly Prep)| |
  200. | | L3/L4 Header | |
  201. | | Parse | |
  202. --------------------------------- |
  203. | |
  204. V |
  205. --------Cluster 4---------------- |
  206. | Ingress 4 | |
  207. |-------------------------------- |
  208. | PDSP0 | LUT1_0(Inner IP | |
  209. | | classify,L4 | |
  210. | | checksum) | |
  211. | PDSP1 | LUT2 | |
  212. | | (TCP/UDP) | |
  213. --------------------------------- |
  214. | |
  215. V |
  216. --------Cluster 5---------------- |
  217. | Post Classification | |
  218. |-------------------------------- |
  219. | PDSP0 | Packet patch | |
  220. | | | |
  221. | | | |
  222. | PDSP1 | Packet patch | |
  223. | | | |
  224. --------------------------------- |
  225. |
  226. ------------ |
  227. | Chan 14 |
  228. |---------------------| Queue 910<---|
  229. V -----------
  230. ---------Cluster 6--------------|
  231. | Egress 0 |
  232. |-------------------------------|
  233. | PDSP0 | Flow Cache lookup |
  234. | | using L3/L4 header |
  235. | PDSP1 | Inner L3/L4 header |
  236. | | Update (Checksum) |
  237. | | Tx command processing|
  238. | PDSP2 | Outer IP update |
  239. | | IPSec pre-process |
  240. | | Inner IP Fragment |
  241. | | Tx command processing|
  242. ---------------------------------
  243. |
  244. |
  245. V
  246. ---------Cluster 7--------------|
  247. | Egress 1 |
  248. |-------------------------------|
  249. | PDSP0 | NAT-T header insert |
  250. | | second IPSEC |
  251. | | pre-processing |
  252. ---------------------------------
  253. |
  254. |
  255. V
  256. ---------Cluster 8--------------|
  257. | Egress 2 |
  258. |-------------------------------|
  259. | PDSP0 | L2 header insertion |
  260. | | /update and Outer IP |
  261. | | fragmentation |
  262. ---------------------------------
  263. |
  264. V
  265. CPSW
  266. |
  267. V
  268. Egress (CPSW port x)
  269. HW Queues 904-912 are for PA cluster 0-8
  270. Tx chan 8-16 are associated with the above queues
  271. Rx flows 31 for command response
  272. Rx flows 22-25, 27-30 for rx data from each ethernet port
  273. driver files and functional description
  274. ==========================================
  275. drivers/net/ethernet/ti/netcp_pa_core.{c|h}
  276. - file used by both PA and PA2 drivers to implement netcp
  277. core module functions and common functions
  278. - pa_core_ops - provide misc functions that are common across
  279. both PA modules.
  280. - hw ops - PA and PA2 module register hw functions as callbacks
  281. to the core module during init. Core module invoke these functions
  282. to pass control to the hw module (PA and PA2)
  283. drivers/net/ethernet/ti/netcp_pa_host.h
  284. - common host specific message header format definitions/macros
  285. across PA and PA2 drivers
  286. drivers/net/ethernet/ti/netcp_pa.c
  287. - PA driver module. PA has multiple clusters (1 PDSP per cluster).
  288. - PA driver configures L2 (cluster 0) and L3 engines for MAC and IP
  289. rules in the Ingress paths. IP packets are forwarded to Modify/
  290. Multi route Engine 1 for Tx checksum calculation. The commands
  291. to PA for doing this are added to data packets send to PA PDSP
  292. associated with Modify/Multi route Engine 1. These gets added
  293. to data packets as part of tx hooks. Rx hook checks the checksum
  294. status and report the same to the stack.
  295. - Provide Timestamps to tx and rx packets.
  296. drivers/net/ethernet/ti/netcp_pa_fw.h
  297. - PA firmware interface definitions. All command message structures
  298. are defined in this file. These are to be kept in sync with
  299. TI's PA Low Level Design (LLD).
  300. drivers/net/ethernet/ti/netcp_pa2_host.h
  301. - PA2 specific message header format definitions/macros
  302. drivers/net/ethernet/ti/netcp_pa2_fw.h
  303. - PA2 firmware interface definitions
  304. drivers/net/ethernet/ti/netcp_pa2.c
  305. - PA2 driver module
  306. Firmware required by the drivers
  307. ================================
  308. PA driver is responsible for loading and running the PA PDSP available in
  309. each cluster. Following firmwares are required
  310. PA firmwares:-
  311. ks2_pa_pdsp0_classify1.bin
  312. ks2_pa_pdsp1_classify1.bin
  313. ks2_pa_pdsp2_classify1.bin
  314. ks2_pa_pdsp3_classify2.bin
  315. ks2_pa_pdsp4_pam.bin
  316. ks2_pa_pdsp5_pam.bin
  317. PA2 firmwares:-
  318. ks2_pa_in0_pdsp0.bin
  319. ks2_pa_in0_pdsp1.bin
  320. ks2_pa_in1_pdsp0.bin
  321. ks2_pa_in1_pdsp1.bin
  322. ks2_pa_in2_pdsp0.bin
  323. ks2_pa_in3_pdsp0.bin
  324. ks2_pa_in4_pdsp0.bin
  325. ks2_pa_in4_pdsp1.bin
  326. ks2_pa_post_pdsp0.bin
  327. ks2_pa_post_pdsp1.bin
  328. ks2_pa_eg0_pdsp0.bin
  329. ks2_pa_eg0_pdsp1.bin
  330. ks2_pa_eg0_pdsp2.bin
  331. ks2_pa_eg1_pdsp0.bin
  332. ks2_pa_eg2_pdsp0.bin
  333. Format:
  334. The firmware image file contains firmware blob with a header.
  335. The format of the image is as follows:-
  336. +----------------------------------+
  337. | 16 chars of version string |
  338. +----------------------------------+
  339. | 4 Constants(32 bits) for PA |
  340. | OR |
  341. | 32 Constants(32 bits) for PA2 |
  342. +----------------------------------+
  343. | Firmware blob |
  344. +----------------------------------+
  345. DT Specifications at
  346. <file:Documentation/devicetree/bindings/net/keystone-netcp.txt>
  347. Limitations
  348. ==========
  349. Currently when PA driver is built as a dynamically loadable module,
  350. autoprobe doesn't work correctly. A Work around is to blacklist the
  351. PA modules in the filesystem and then load them manually using
  352. the following steps:-
  353. - Bring down the interface (if interface is already up)
  354. - insmod PA module .ko file
  355. - Bring up the interface.