qlink_util.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2015-2016 Quantenna Communications, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef _QTN_FMAC_QLINK_UTIL_H_
  17. #define _QTN_FMAC_QLINK_UTIL_H_
  18. #include <linux/types.h>
  19. #include <linux/skbuff.h>
  20. #include "qlink.h"
  21. static inline void
  22. qtnf_cmd_skb_put_buffer(struct sk_buff *skb, const u8 *buf_src, size_t len)
  23. {
  24. skb_put_data(skb, buf_src, len);
  25. }
  26. static inline void qtnf_cmd_skb_put_tlv_arr(struct sk_buff *skb,
  27. u16 tlv_id, const u8 arr[],
  28. size_t arr_len)
  29. {
  30. struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + arr_len);
  31. hdr->type = cpu_to_le16(tlv_id);
  32. hdr->len = cpu_to_le16(arr_len);
  33. memcpy(hdr->val, arr, arr_len);
  34. }
  35. static inline void qtnf_cmd_skb_put_tlv_u8(struct sk_buff *skb, u16 tlv_id,
  36. u8 value)
  37. {
  38. struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
  39. hdr->type = cpu_to_le16(tlv_id);
  40. hdr->len = cpu_to_le16(sizeof(value));
  41. *hdr->val = value;
  42. }
  43. static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff *skb,
  44. u16 tlv_id, u16 value)
  45. {
  46. struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
  47. __le16 tmp = cpu_to_le16(value);
  48. hdr->type = cpu_to_le16(tlv_id);
  49. hdr->len = cpu_to_le16(sizeof(value));
  50. memcpy(hdr->val, &tmp, sizeof(tmp));
  51. }
  52. u16 qlink_iface_type_to_nl_mask(u16 qlink_type);
  53. u8 qlink_chan_width_mask_to_nl(u16 qlink_mask);
  54. #endif /* _QTN_FMAC_QLINK_UTIL_H_ */