rq_enet_desc.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2008 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. #ifndef _RQ_ENET_DESC_H_
  19. #define _RQ_ENET_DESC_H_
  20. /* Ethernet receive queue descriptor: 16B */
  21. struct rq_enet_desc {
  22. __le64 address;
  23. __le16 length_type;
  24. u8 reserved[6];
  25. };
  26. enum rq_enet_type_types {
  27. RQ_ENET_TYPE_ONLY_SOP = 0,
  28. RQ_ENET_TYPE_NOT_SOP = 1,
  29. RQ_ENET_TYPE_RESV2 = 2,
  30. RQ_ENET_TYPE_RESV3 = 3,
  31. };
  32. #define RQ_ENET_ADDR_BITS 64
  33. #define RQ_ENET_LEN_BITS 14
  34. #define RQ_ENET_LEN_MASK ((1 << RQ_ENET_LEN_BITS) - 1)
  35. #define RQ_ENET_TYPE_BITS 2
  36. #define RQ_ENET_TYPE_MASK ((1 << RQ_ENET_TYPE_BITS) - 1)
  37. static inline void rq_enet_desc_enc(struct rq_enet_desc *desc,
  38. u64 address, u8 type, u16 length)
  39. {
  40. desc->address = cpu_to_le64(address);
  41. desc->length_type = cpu_to_le16((length & RQ_ENET_LEN_MASK) |
  42. ((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS));
  43. }
  44. static inline void rq_enet_desc_dec(struct rq_enet_desc *desc,
  45. u64 *address, u8 *type, u16 *length)
  46. {
  47. *address = le64_to_cpu(desc->address);
  48. *length = le16_to_cpu(desc->length_type) & RQ_ENET_LEN_MASK;
  49. *type = (u8)((le16_to_cpu(desc->length_type) >> RQ_ENET_LEN_BITS) &
  50. RQ_ENET_TYPE_MASK);
  51. }
  52. #endif /* _RQ_ENET_DESC_H_ */