opa_vnic.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /*
  3. * Copyright(c) 2017 - 2020 Intel Corporation.
  4. */
  5. #ifndef _OPA_VNIC_H
  6. #define _OPA_VNIC_H
  7. /*
  8. * This file contains Intel Omni-Path (OPA) Virtual Network Interface
  9. * Controller (VNIC) specific declarations.
  10. */
  11. #include <rdma/ib_verbs.h>
  12. /* 16 header bytes + 2 reserved bytes */
  13. #define OPA_VNIC_L2_HDR_LEN (16 + 2)
  14. #define OPA_VNIC_L4_HDR_LEN 2
  15. #define OPA_VNIC_HDR_LEN (OPA_VNIC_L2_HDR_LEN + \
  16. OPA_VNIC_L4_HDR_LEN)
  17. #define OPA_VNIC_L4_ETHR 0x78
  18. #define OPA_VNIC_ICRC_LEN 4
  19. #define OPA_VNIC_TAIL_LEN 1
  20. #define OPA_VNIC_ICRC_TAIL_LEN (OPA_VNIC_ICRC_LEN + OPA_VNIC_TAIL_LEN)
  21. #define OPA_VNIC_SKB_MDATA_LEN 4
  22. #define OPA_VNIC_SKB_MDATA_ENCAP_ERR 0x1
  23. /* opa vnic rdma netdev's private data structure */
  24. struct opa_vnic_rdma_netdev {
  25. struct rdma_netdev rn; /* keep this first */
  26. /* followed by device private data */
  27. char *dev_priv[];
  28. };
  29. static inline void *opa_vnic_priv(const struct net_device *dev)
  30. {
  31. struct rdma_netdev *rn = netdev_priv(dev);
  32. return rn->clnt_priv;
  33. }
  34. static inline void *opa_vnic_dev_priv(const struct net_device *dev)
  35. {
  36. struct opa_vnic_rdma_netdev *oparn = netdev_priv(dev);
  37. return oparn->dev_priv;
  38. }
  39. /* opa_vnic skb meta data structrue */
  40. struct opa_vnic_skb_mdata {
  41. u8 vl;
  42. u8 entropy;
  43. u8 flags;
  44. u8 rsvd;
  45. } __packed;
  46. /* OPA VNIC group statistics */
  47. struct opa_vnic_grp_stats {
  48. u64 unicast;
  49. u64 mcastbcast;
  50. u64 untagged;
  51. u64 vlan;
  52. u64 s_64;
  53. u64 s_65_127;
  54. u64 s_128_255;
  55. u64 s_256_511;
  56. u64 s_512_1023;
  57. u64 s_1024_1518;
  58. u64 s_1519_max;
  59. };
  60. struct opa_vnic_stats {
  61. /* standard netdev statistics */
  62. struct rtnl_link_stats64 netstats;
  63. /* OPA VNIC statistics */
  64. struct opa_vnic_grp_stats tx_grp;
  65. struct opa_vnic_grp_stats rx_grp;
  66. u64 tx_dlid_zero;
  67. u64 tx_drop_state;
  68. u64 rx_drop_state;
  69. u64 rx_runt;
  70. u64 rx_oversize;
  71. };
  72. static inline bool rdma_cap_opa_vnic(struct ib_device *device)
  73. {
  74. return !!(device->attrs.kernel_cap_flags & IBK_RDMA_NETDEV_OPA);
  75. }
  76. #endif /* _OPA_VNIC_H */