blob: cbe3c2811455014eaf9e8e6dc3d0f1e397c2059c [file] [log] [blame]
Leon Romanovsky6bf9d8f2020-07-19 10:25:21 +03001/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
Vishwanathapura, Niranjana62e45942017-04-12 20:29:21 -07002/*
Gary Leshner7f90a5a2020-05-11 12:06:07 -04003 * Copyright(c) 2017 - 2020 Intel Corporation.
Vishwanathapura, Niranjana62e45942017-04-12 20:29:21 -07004 */
5
Leon Romanovsky6bf9d8f2020-07-19 10:25:21 +03006#ifndef _OPA_VNIC_H
7#define _OPA_VNIC_H
8
Vishwanathapura, Niranjana62e45942017-04-12 20:29:21 -07009/*
10 * This file contains Intel Omni-Path (OPA) Virtual Network Interface
11 * Controller (VNIC) specific declarations.
12 */
13
14#include <rdma/ib_verbs.h>
15
Vishwanathapura, Niranjana62e45942017-04-12 20:29:21 -070016/* 16 header bytes + 2 reserved bytes */
17#define OPA_VNIC_L2_HDR_LEN (16 + 2)
18
19#define OPA_VNIC_L4_HDR_LEN 2
20
21#define OPA_VNIC_HDR_LEN (OPA_VNIC_L2_HDR_LEN + \
22 OPA_VNIC_L4_HDR_LEN)
23
24#define OPA_VNIC_L4_ETHR 0x78
25
26#define OPA_VNIC_ICRC_LEN 4
27#define OPA_VNIC_TAIL_LEN 1
28#define OPA_VNIC_ICRC_TAIL_LEN (OPA_VNIC_ICRC_LEN + OPA_VNIC_TAIL_LEN)
29
30#define OPA_VNIC_SKB_MDATA_LEN 4
31#define OPA_VNIC_SKB_MDATA_ENCAP_ERR 0x1
32
33/* opa vnic rdma netdev's private data structure */
34struct opa_vnic_rdma_netdev {
35 struct rdma_netdev rn; /* keep this first */
36 /* followed by device private data */
Gustavo A. R. Silva5b361322020-02-12 19:04:25 -060037 char *dev_priv[];
Vishwanathapura, Niranjana62e45942017-04-12 20:29:21 -070038};
39
40static inline void *opa_vnic_priv(const struct net_device *dev)
41{
42 struct rdma_netdev *rn = netdev_priv(dev);
43
44 return rn->clnt_priv;
45}
46
47static inline void *opa_vnic_dev_priv(const struct net_device *dev)
48{
49 struct opa_vnic_rdma_netdev *oparn = netdev_priv(dev);
50
51 return oparn->dev_priv;
52}
53
54/* opa_vnic skb meta data structrue */
55struct opa_vnic_skb_mdata {
56 u8 vl;
57 u8 entropy;
58 u8 flags;
59 u8 rsvd;
60} __packed;
61
62/* OPA VNIC group statistics */
63struct opa_vnic_grp_stats {
64 u64 unicast;
65 u64 mcastbcast;
66 u64 untagged;
67 u64 vlan;
68 u64 s_64;
69 u64 s_65_127;
70 u64 s_128_255;
71 u64 s_256_511;
72 u64 s_512_1023;
73 u64 s_1024_1518;
74 u64 s_1519_max;
75};
76
77struct opa_vnic_stats {
78 /* standard netdev statistics */
79 struct rtnl_link_stats64 netstats;
80
81 /* OPA VNIC statistics */
82 struct opa_vnic_grp_stats tx_grp;
83 struct opa_vnic_grp_stats rx_grp;
84 u64 tx_dlid_zero;
85 u64 tx_drop_state;
86 u64 rx_drop_state;
87 u64 rx_runt;
88 u64 rx_oversize;
89};
90
91static inline bool rdma_cap_opa_vnic(struct ib_device *device)
92{
93 return !!(device->attrs.device_cap_flags &
Gary Leshner7f90a5a2020-05-11 12:06:07 -040094 IB_DEVICE_RDMA_NETDEV_OPA);
Vishwanathapura, Niranjana62e45942017-04-12 20:29:21 -070095}
96
97#endif /* _OPA_VNIC_H */