rq_enet_desc.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
  3. * Copyright 2007 Nuova Systems, Inc. All rights reserved.
  4. *
  5. * This program is free software; you may redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; version 2 of the License.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  10. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  12. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  13. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  14. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  16. * SOFTWARE.
  17. *
  18. */
  19. #ifndef _RQ_ENET_DESC_H_
  20. #define _RQ_ENET_DESC_H_
  21. /* Ethernet receive queue descriptor: 16B */
  22. struct rq_enet_desc {
  23. __le64 address;
  24. __le16 length_type;
  25. u8 reserved[6];
  26. };
  27. enum rq_enet_type_types {
  28. RQ_ENET_TYPE_ONLY_SOP = 0,
  29. RQ_ENET_TYPE_NOT_SOP = 1,
  30. RQ_ENET_TYPE_RESV2 = 2,
  31. RQ_ENET_TYPE_RESV3 = 3,
  32. };
  33. #define RQ_ENET_ADDR_BITS 64
  34. #define RQ_ENET_LEN_BITS 14
  35. #define RQ_ENET_LEN_MASK ((1 << RQ_ENET_LEN_BITS) - 1)
  36. #define RQ_ENET_TYPE_BITS 2
  37. #define RQ_ENET_TYPE_MASK ((1 << RQ_ENET_TYPE_BITS) - 1)
  38. static inline void rq_enet_desc_enc(struct rq_enet_desc *desc,
  39. u64 address, u8 type, u16 length)
  40. {
  41. desc->address = cpu_to_le64(address);
  42. desc->length_type = cpu_to_le16((length & RQ_ENET_LEN_MASK) |
  43. ((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS));
  44. }
  45. static inline void rq_enet_desc_dec(struct rq_enet_desc *desc,
  46. u64 *address, u8 *type, u16 *length)
  47. {
  48. *address = le64_to_cpu(desc->address);
  49. *length = le16_to_cpu(desc->length_type) & RQ_ENET_LEN_MASK;
  50. *type = (u8)((le16_to_cpu(desc->length_type) >> RQ_ENET_LEN_BITS) &
  51. RQ_ENET_TYPE_MASK);
  52. }
  53. #endif /* _RQ_ENET_DESC_H_ */