rdma_netlink.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef _RDMA_NETLINK_H
  2. #define _RDMA_NETLINK_H
  3. #include <linux/types.h>
  4. enum {
  5. RDMA_NL_RDMA_CM = 1
  6. };
  7. #define RDMA_NL_GET_CLIENT(type) ((type & (((1 << 6) - 1) << 10)) >> 10)
  8. #define RDMA_NL_GET_OP(type) (type & ((1 << 10) - 1))
  9. #define RDMA_NL_GET_TYPE(client, op) ((client << 10) + op)
  10. enum {
  11. RDMA_NL_RDMA_CM_ID_STATS = 0,
  12. RDMA_NL_RDMA_CM_NUM_OPS
  13. };
  14. enum {
  15. RDMA_NL_RDMA_CM_ATTR_SRC_ADDR = 1,
  16. RDMA_NL_RDMA_CM_ATTR_DST_ADDR,
  17. RDMA_NL_RDMA_CM_NUM_ATTR,
  18. };
  19. struct rdma_cm_id_stats {
  20. __u32 qp_num;
  21. __u32 bound_dev_if;
  22. __u32 port_space;
  23. __s32 pid;
  24. __u8 cm_state;
  25. __u8 node_type;
  26. __u8 port_num;
  27. __u8 qp_type;
  28. };
  29. #ifdef __KERNEL__
  30. #include <linux/netlink.h>
  31. struct ibnl_client_cbs {
  32. int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
  33. struct module *module;
  34. };
  35. int ibnl_init(void);
  36. void ibnl_cleanup(void);
  37. /**
  38. * Add a a client to the list of IB netlink exporters.
  39. * @index: Index of the added client
  40. * @nops: Number of supported ops by the added client.
  41. * @cb_table: A table for op->callback
  42. *
  43. * Returns 0 on success or a negative error code.
  44. */
  45. int ibnl_add_client(int index, int nops,
  46. const struct ibnl_client_cbs cb_table[]);
  47. /**
  48. * Remove a client from IB netlink.
  49. * @index: Index of the removed IB client.
  50. *
  51. * Returns 0 on success or a negative error code.
  52. */
  53. int ibnl_remove_client(int index);
  54. /**
  55. * Put a new message in a supplied skb.
  56. * @skb: The netlink skb.
  57. * @nlh: Pointer to put the header of the new netlink message.
  58. * @seq: The message sequence number.
  59. * @len: The requested message length to allocate.
  60. * @client: Calling IB netlink client.
  61. * @op: message content op.
  62. * Returns the allocated buffer on success and NULL on failure.
  63. */
  64. void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
  65. int len, int client, int op);
  66. /**
  67. * Put a new attribute in a supplied skb.
  68. * @skb: The netlink skb.
  69. * @nlh: Header of the netlink message to append the attribute to.
  70. * @len: The length of the attribute data.
  71. * @data: The attribute data to put.
  72. * @type: The attribute type.
  73. * Returns the 0 and a negative error code on failure.
  74. */
  75. int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
  76. int len, void *data, int type);
  77. #endif /* __KERNEL__ */
  78. #endif /* _RDMA_NETLINK_H */