rdma_netlink.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _RDMA_NETLINK_H
  2. #define _RDMA_NETLINK_H
  3. #include <linux/netlink.h>
  4. #include <uapi/rdma/rdma_netlink.h>
  5. struct ibnl_client_cbs {
  6. int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
  7. struct module *module;
  8. };
  9. int ibnl_init(void);
  10. void ibnl_cleanup(void);
  11. /**
  12. * Add a a client to the list of IB netlink exporters.
  13. * @index: Index of the added client
  14. * @nops: Number of supported ops by the added client.
  15. * @cb_table: A table for op->callback
  16. *
  17. * Returns 0 on success or a negative error code.
  18. */
  19. int ibnl_add_client(int index, int nops,
  20. const struct ibnl_client_cbs cb_table[]);
  21. /**
  22. * Remove a client from IB netlink.
  23. * @index: Index of the removed IB client.
  24. *
  25. * Returns 0 on success or a negative error code.
  26. */
  27. int ibnl_remove_client(int index);
  28. /**
  29. * Put a new message in a supplied skb.
  30. * @skb: The netlink skb.
  31. * @nlh: Pointer to put the header of the new netlink message.
  32. * @seq: The message sequence number.
  33. * @len: The requested message length to allocate.
  34. * @client: Calling IB netlink client.
  35. * @op: message content op.
  36. * Returns the allocated buffer on success and NULL on failure.
  37. */
  38. void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
  39. int len, int client, int op, int flags);
  40. /**
  41. * Put a new attribute in a supplied skb.
  42. * @skb: The netlink skb.
  43. * @nlh: Header of the netlink message to append the attribute to.
  44. * @len: The length of the attribute data.
  45. * @data: The attribute data to put.
  46. * @type: The attribute type.
  47. * Returns the 0 and a negative error code on failure.
  48. */
  49. int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
  50. int len, void *data, int type);
  51. /**
  52. * Send the supplied skb to a specific userspace PID.
  53. * @skb: The netlink skb
  54. * @nlh: Header of the netlink message to send
  55. * @pid: Userspace netlink process ID
  56. * Returns 0 on success or a negative error code.
  57. */
  58. int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
  59. __u32 pid);
  60. /**
  61. * Send the supplied skb to a netlink group.
  62. * @skb: The netlink skb
  63. * @nlh: Header of the netlink message to send
  64. * @group: Netlink group ID
  65. * @flags: allocation flags
  66. * Returns 0 on success or a negative error code.
  67. */
  68. int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
  69. unsigned int group, gfp_t flags);
  70. /**
  71. * Check if there are any listeners to the netlink group
  72. * @group: the netlink group ID
  73. * Returns 0 on success or a negative for no listeners.
  74. */
  75. int ibnl_chk_listeners(unsigned int group);
  76. #endif /* _RDMA_NETLINK_H */