1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-C << 2 /* << 3 * Copyright(c) 2017 - 2020 Intel Corporation. << 4 */ << 5 << 6 #ifndef _OPA_VNIC_H 1 #ifndef _OPA_VNIC_H 7 #define _OPA_VNIC_H 2 #define _OPA_VNIC_H >> 3 /* >> 4 * Copyright(c) 2017 Intel Corporation. >> 5 * >> 6 * This file is provided under a dual BSD/GPLv2 license. When using or >> 7 * redistributing this file, you may do so under either license. >> 8 * >> 9 * GPL LICENSE SUMMARY >> 10 * >> 11 * This program is free software; you can redistribute it and/or modify >> 12 * it under the terms of version 2 of the GNU General Public License as >> 13 * published by the Free Software Foundation. >> 14 * >> 15 * This program is distributed in the hope that it will be useful, but >> 16 * WITHOUT ANY WARRANTY; without even the implied warranty of >> 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> 18 * General Public License for more details. >> 19 * >> 20 * BSD LICENSE >> 21 * >> 22 * Redistribution and use in source and binary forms, with or without >> 23 * modification, are permitted provided that the following conditions >> 24 * are met: >> 25 * >> 26 * - Redistributions of source code must retain the above copyright >> 27 * notice, this list of conditions and the following disclaimer. >> 28 * - Redistributions in binary form must reproduce the above copyright >> 29 * notice, this list of conditions and the following disclaimer in >> 30 * the documentation and/or other materials provided with the >> 31 * distribution. >> 32 * - Neither the name of Intel Corporation nor the names of its >> 33 * contributors may be used to endorse or promote products derived >> 34 * from this software without specific prior written permission. >> 35 * >> 36 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >> 37 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >> 38 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >> 39 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >> 40 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >> 41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >> 42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >> 43 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >> 44 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >> 45 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >> 46 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >> 47 * >> 48 */ 8 49 9 /* 50 /* 10 * This file contains Intel Omni-Path (OPA) Vi 51 * This file contains Intel Omni-Path (OPA) Virtual Network Interface 11 * Controller (VNIC) specific declarations. 52 * Controller (VNIC) specific declarations. 12 */ 53 */ 13 54 14 #include <rdma/ib_verbs.h> 55 #include <rdma/ib_verbs.h> 15 56 16 /* 16 header bytes + 2 reserved bytes */ 57 /* 16 header bytes + 2 reserved bytes */ 17 #define OPA_VNIC_L2_HDR_LEN (16 + 2) 58 #define OPA_VNIC_L2_HDR_LEN (16 + 2) 18 59 19 #define OPA_VNIC_L4_HDR_LEN 2 60 #define OPA_VNIC_L4_HDR_LEN 2 20 61 21 #define OPA_VNIC_HDR_LEN (OPA_VNIC_L2_HDR 62 #define OPA_VNIC_HDR_LEN (OPA_VNIC_L2_HDR_LEN + \ 22 OPA_VNIC_L4_HDR 63 OPA_VNIC_L4_HDR_LEN) 23 64 24 #define OPA_VNIC_L4_ETHR 0x78 65 #define OPA_VNIC_L4_ETHR 0x78 25 66 26 #define OPA_VNIC_ICRC_LEN 4 67 #define OPA_VNIC_ICRC_LEN 4 27 #define OPA_VNIC_TAIL_LEN 1 68 #define OPA_VNIC_TAIL_LEN 1 28 #define OPA_VNIC_ICRC_TAIL_LEN (OPA_VNIC_ICRC 69 #define OPA_VNIC_ICRC_TAIL_LEN (OPA_VNIC_ICRC_LEN + OPA_VNIC_TAIL_LEN) 29 70 30 #define OPA_VNIC_SKB_MDATA_LEN 4 71 #define OPA_VNIC_SKB_MDATA_LEN 4 31 #define OPA_VNIC_SKB_MDATA_ENCAP_ERR 0x1 72 #define OPA_VNIC_SKB_MDATA_ENCAP_ERR 0x1 32 73 33 /* opa vnic rdma netdev's private data structu 74 /* opa vnic rdma netdev's private data structure */ 34 struct opa_vnic_rdma_netdev { 75 struct opa_vnic_rdma_netdev { 35 struct rdma_netdev rn; /* keep this f 76 struct rdma_netdev rn; /* keep this first */ 36 /* followed by device private data */ 77 /* followed by device private data */ 37 char *dev_priv[]; !! 78 char *dev_priv[0]; 38 }; 79 }; 39 80 40 static inline void *opa_vnic_priv(const struct 81 static inline void *opa_vnic_priv(const struct net_device *dev) 41 { 82 { 42 struct rdma_netdev *rn = netdev_priv(d 83 struct rdma_netdev *rn = netdev_priv(dev); 43 84 44 return rn->clnt_priv; 85 return rn->clnt_priv; 45 } 86 } 46 87 47 static inline void *opa_vnic_dev_priv(const st 88 static inline void *opa_vnic_dev_priv(const struct net_device *dev) 48 { 89 { 49 struct opa_vnic_rdma_netdev *oparn = n 90 struct opa_vnic_rdma_netdev *oparn = netdev_priv(dev); 50 91 51 return oparn->dev_priv; 92 return oparn->dev_priv; 52 } 93 } 53 94 54 /* opa_vnic skb meta data structure */ !! 95 /* opa_vnic skb meta data structrue */ 55 struct opa_vnic_skb_mdata { 96 struct opa_vnic_skb_mdata { 56 u8 vl; 97 u8 vl; 57 u8 entropy; 98 u8 entropy; 58 u8 flags; 99 u8 flags; 59 u8 rsvd; 100 u8 rsvd; 60 } __packed; 101 } __packed; 61 102 62 /* OPA VNIC group statistics */ 103 /* OPA VNIC group statistics */ 63 struct opa_vnic_grp_stats { 104 struct opa_vnic_grp_stats { 64 u64 unicast; 105 u64 unicast; 65 u64 mcastbcast; 106 u64 mcastbcast; 66 u64 untagged; 107 u64 untagged; 67 u64 vlan; 108 u64 vlan; 68 u64 s_64; 109 u64 s_64; 69 u64 s_65_127; 110 u64 s_65_127; 70 u64 s_128_255; 111 u64 s_128_255; 71 u64 s_256_511; 112 u64 s_256_511; 72 u64 s_512_1023; 113 u64 s_512_1023; 73 u64 s_1024_1518; 114 u64 s_1024_1518; 74 u64 s_1519_max; 115 u64 s_1519_max; 75 }; 116 }; 76 117 77 struct opa_vnic_stats { 118 struct opa_vnic_stats { 78 /* standard netdev statistics */ 119 /* standard netdev statistics */ 79 struct rtnl_link_stats64 netstats; 120 struct rtnl_link_stats64 netstats; 80 121 81 /* OPA VNIC statistics */ 122 /* OPA VNIC statistics */ 82 struct opa_vnic_grp_stats tx_grp; 123 struct opa_vnic_grp_stats tx_grp; 83 struct opa_vnic_grp_stats rx_grp; 124 struct opa_vnic_grp_stats rx_grp; 84 u64 tx_dlid_zero; 125 u64 tx_dlid_zero; 85 u64 tx_drop_state; 126 u64 tx_drop_state; 86 u64 rx_drop_state; 127 u64 rx_drop_state; 87 u64 rx_runt; 128 u64 rx_runt; 88 u64 rx_oversize; 129 u64 rx_oversize; 89 }; 130 }; 90 131 91 static inline bool rdma_cap_opa_vnic(struct ib 132 static inline bool rdma_cap_opa_vnic(struct ib_device *device) 92 { 133 { 93 return !!(device->attrs.kernel_cap_fla !! 134 return !!(device->attrs.device_cap_flags & >> 135 IB_DEVICE_RDMA_NETDEV_OPA_VNIC); 94 } 136 } 95 137 96 #endif /* _OPA_VNIC_H */ 138 #endif /* _OPA_VNIC_H */ 97 139
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.