fman_sp.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright 2008 - 2015 Freescale Semiconductor Inc.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above copyright
  9. * notice, this list of conditions and the following disclaimer in the
  10. * documentation and/or other materials provided with the distribution.
  11. * * Neither the name of Freescale Semiconductor nor the
  12. * names of its contributors may be used to endorse or promote products
  13. * derived from this software without specific prior written permission.
  14. *
  15. * ALTERNATIVELY, this software may be distributed under the terms of the
  16. * GNU General Public License ("GPL") as published by the Free Software
  17. * Foundation, either version 2 of that License or (at your option) any
  18. * later version.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
  21. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23. * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
  24. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  27. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #ifndef __FM_SP_H
  32. #define __FM_SP_H
  33. #include "fman.h"
  34. #include <linux/types.h>
  35. #define ILLEGAL_BASE (~0)
  36. /* defaults */
  37. #define DFLT_FM_SP_BUFFER_PREFIX_CONTEXT_DATA_ALIGN 64
  38. /* Registers bit fields */
  39. #define FMAN_SP_EXT_BUF_POOL_EN_COUNTER 0x40000000
  40. #define FMAN_SP_EXT_BUF_POOL_VALID 0x80000000
  41. #define FMAN_SP_EXT_BUF_POOL_BACKUP 0x20000000
  42. #define FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE 0x00100000
  43. #define FMAN_SP_SG_DISABLE 0x80000000
  44. /* shifts */
  45. #define FMAN_SP_EXT_BUF_MARG_START_SHIFT 16
  46. #define FMAN_SP_DMA_ATTR_SWP_SHIFT 30
  47. #define FMAN_SP_IC_TO_EXT_SHIFT 16
  48. #define FMAN_SP_IC_FROM_INT_SHIFT 8
  49. /* structure for defining internal context copying */
  50. struct fman_sp_int_context_data_copy {
  51. /* < Offset in External buffer to which internal
  52. * context is copied to (Rx) or taken from (Tx, Op).
  53. */
  54. u16 ext_buf_offset;
  55. /* Offset within internal context to copy from
  56. * (Rx) or to copy to (Tx, Op).
  57. */
  58. u8 int_context_offset;
  59. /* Internal offset size to be copied */
  60. u16 size;
  61. };
  62. /* struct for defining external buffer margins */
  63. struct fman_sp_buf_margins {
  64. /* Number of bytes to be left at the beginning
  65. * of the external buffer (must be divisible by 16)
  66. */
  67. u16 start_margins;
  68. /* number of bytes to be left at the end
  69. * of the external buffer(must be divisible by 16)
  70. */
  71. u16 end_margins;
  72. };
  73. struct fman_sp_buffer_offsets {
  74. u32 data_offset;
  75. u32 prs_result_offset;
  76. u32 time_stamp_offset;
  77. u32 hash_result_offset;
  78. };
  79. int fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy
  80. *int_context_data_copy,
  81. struct fman_buffer_prefix_content
  82. *buffer_prefix_content,
  83. struct fman_sp_buf_margins *buf_margins,
  84. struct fman_sp_buffer_offsets
  85. *buffer_offsets,
  86. u8 *internal_buf_offset);
  87. void fman_sp_set_buf_pools_in_asc_order_of_buf_sizes(struct fman_ext_pools
  88. *fm_ext_pools,
  89. u8 *ordered_array,
  90. u16 *sizes_array);
  91. #endif /* __FM_SP_H */