rdma_netlink.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. };
  34. int ibnl_init(void);
  35. void ibnl_cleanup(void);
  36. /**
  37. * Add a a client to the list of IB netlink exporters.
  38. * @index: Index of the added client
  39. * @nops: Number of supported ops by the added client.
  40. * @cb_table: A table for op->callback
  41. *
  42. * Returns 0 on success or a negative error code.
  43. */
  44. int ibnl_add_client(int index, int nops,
  45. const struct ibnl_client_cbs cb_table[]);
  46. /**
  47. * Remove a client from IB netlink.
  48. * @index: Index of the removed IB client.
  49. *
  50. * Returns 0 on success or a negative error code.
  51. */
  52. int ibnl_remove_client(int index);
  53. /**
  54. * Put a new message in a supplied skb.
  55. * @skb: The netlink skb.
  56. * @nlh: Pointer to put the header of the new netlink message.
  57. * @seq: The message sequence number.
  58. * @len: The requested message length to allocate.
  59. * @client: Calling IB netlink client.
  60. * @op: message content op.
  61. * Returns the allocated buffer on success and NULL on failure.
  62. */
  63. void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
  64. int len, int client, int op);
  65. /**
  66. * Put a new attribute in a supplied skb.
  67. * @skb: The netlink skb.
  68. * @nlh: Header of the netlink message to append the attribute to.
  69. * @len: The length of the attribute data.
  70. * @data: The attribute data to put.
  71. * @type: The attribute type.
  72. * Returns the 0 and a negative error code on failure.
  73. */
  74. int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
  75. int len, void *data, int type);
  76. #endif /* __KERNEL__ */
  77. #endif /* _RDMA_NETLINK_H */