Files
@ bd21c8aa7237
Branch filter:
Location: vmkdrivers/vmkdrivers/src_9/drivers/net/mlnx/compat/mlnx_compat.h
bd21c8aa7237
10.9 KiB
text/x-chdr
ESXi-6.0.0b
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | /*
* Copyright (c) 2011-2013 Mellanox Technologies. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef _MLNX_COMPAT_H
#define _MLNX_COMPAT_H
#include <linux/gfp.h>
#include <linux/workqueue.h>
#include <linux/if_vlan.h>
#include <linux/ethtool.h>
#include <linux/pci.h>
#include <linux/bitmap.h>
#include <linux/rbtree.h>
#include <linux/fs.h>
/************************************************************************/
#include "hash.h"
/************************************************************************/
/*
#define __VMKERNEL_BF_ENABLE__
#define __VMKERNEL_SYSFS_SUPPORT__
#define __VMKERNEL_LARGE_DMA_SEG_ENABLE__
#define __VMKERNEL_MLNX_SENSNE_ENABLE__
#define __VMKERNEL_HASH_EXPAND_ENABLE__
#define __VMKERNEL_NETLINK_SUPPORT__
#define __VMKERNEL_IPOIB_PACKET_DEBUG__
#define __VMKERNEL_MLX4_EN_SUPPORT__
#define __VMKERNEL_ETHTOOL_RSS_NUM_RINGS_SUPPORT__
#define __VMKERNEL_ETHTOOL_SELF_TEST_SUPPORT__
#define __VMKERNEL_TX_INLINE_WQE_ENABLE__
#define __VMKERNEL_NETDEV_SELECT_QUEUE_SUPPORT__
#define __VMKERNEL_NETDEV_ADVANCE_FEATURES_SUPPORT__
#define __VMKERNEL_NETDEV_GRO_FEATURE_SUPPORT__
#define __VMKERNEL_NETDEV_OPS_SET_FEATURES_SUPPORT__
#define __VMKERNEL_NETDEV_OPS_VALIDATE_ADDR_SUPPORT__
#define __MLNX_VMKERNEL_40G_SPEED_SUPPORT__
*/
/*
#define __MEMTRACK__
#define IPOIB_SHOW_ARP_DBG
*/
#ifndef CONFIG_MLX4_DEBUG
#define CONFIG_MLX4_DEBUG
#endif
#define __VMKERNEL_MLX4_EN_TX_HASH__
#define __VMKERNEL_KOBJECT_FIX_BUG__
/*
* Pseudo device defines -
* In old DDKs NETIF_F_PSEUDO_REG not exists and
* we try to workaround this.
* In this case we also define __VMKERNEL_PSEUDO_OLD_API__
* so we will know we are using old DDK
*/
#ifndef NETIF_F_PSEUDO_REG
#define NETIF_F_PSEUDO_REG 0x10000000000
#define __VMKERNEL_PSEUDO_OLD_API__
#endif /* NETIF_F_PSEUDO_REG */
/*
* Netqueue RSS for VXLAN defines
* If vmkapi support RSS for VXLAN than we enable
* this feature in netqueue code
*/
#if (VMKAPI_REVISION >= VMK_REVISION_FROM_NUMBERS(2, 1, 0, 0))
#define __VMKERNEL_RSS_NETQ_SUPPORT__
#endif
#if (VMKAPI_REVISION >= VMK_REVISION_FROM_NUMBERS(2, 2, 0, 0))
#define __MLNX_VMKERNEL_40G_SPEED_SUPPORT__
#endif
/************************************************************************/
/* Prints */
#ifndef KERN_ERR
#define KERN_ERR ""
#endif
#ifndef KERN_WARNING
#define KERN_WARNING ""
#endif
#ifndef KERN_CONT
#define KERN_CONT ""
#endif
#define pr_err(fmt, ...) \
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warning(fmt, ...) \
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
#define pr_cont(fmt, ...) \
printk(KERN_CONT fmt, ##__VA_ARGS__)
#define printk_once(fmt, ...) \
({ \
static bool __print_once; \
\
if (!__print_once) { \
__print_once = true; \
printk(fmt, ##__VA_ARGS__); \
} \
})
#define pr_fmt(fmt) fmt
/************************************************************************/
/* Networking */
/* Netdev */
#define for_each_netdev_rcu(net, d) \
for ((d) = dev_base; (d); \
(d) = rcu_dereference(d)->next)
typedef int netdev_tx_t;
/* if_vlan.h */
#ifndef VLAN_N_VID
#define VLAN_N_VID 4096
#endif /* VLAN_N_VID */
/* if_ether.h */
#ifndef ETH_FCS_LEN
#define ETH_FCS_LEN 4
#endif /* NOT ETH_FCS_LEN */
/* skbuff.h */
static inline unsigned int skb_frag_size(const skb_frag_t *frag)
{
return frag->size;
}
static inline void skb_frag_size_set(skb_frag_t *frag, unsigned int size)
{
frag->size = size;
}
static inline void skb_frag_size_sub(skb_frag_t *frag, int delta)
{
frag->size -= delta;
}
static inline struct page *skb_frag_page(const skb_frag_t *frag)
{
#ifdef __VMKERNEL_MODULE__
return frag->page;
#else
return frag->page.p;
#endif /* __VMKERNEL_MODULE__ */
}
static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page)
{
#ifdef __VMKERNEL_MODULE__
frag->page = page;
#else
frag->page.p = page;
#endif /* __VMKERNEL_MODULE__ */
}
static inline void skb_frag_set_page(struct sk_buff *skb, int f,
struct page *page)
{
__skb_frag_set_page(&skb_shinfo(skb)->frags[f], page);
}
static inline dma_addr_t skb_frag_dma_map(struct device *dev,
const skb_frag_t *frag,
size_t offset, size_t size,
enum dma_data_direction dir)
{
return dma_map_page(dev, skb_frag_page(frag),
frag->page_offset + offset, size, dir);
}
static inline void __skb_frag_unref(skb_frag_t *frag)
{
put_page(skb_frag_page(frag));
}
static inline void skb_frag_unref(struct sk_buff *skb, int f)
{
__skb_frag_unref(&skb_shinfo(skb)->frags[f]);
}
static inline void skb_record_rx_queue(struct sk_buff *skb, u16 rx_queue)
{
vmknetddi_queueops_set_skb_queueid(skb,
VMKNETDDI_QUEUEOPS_MK_RX_QUEUEID(rx_queue));
}
/************************************************************************/
/* Some defines and types */
typedef unsigned long phys_addr_t;
#define num_possible_cpus() smp_num_cpus
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
#define for_each_set_bit(bit, addr, size) \
for ((bit) = find_first_bit((addr), (size)); \
(bit) < (size); \
(bit) = find_next_bit((addr), (size), (bit) + 1))
#define __packed __attribute__((packed))
#define uninitialized_var(x) x = x
#define iowrite32(v, addr) writel((v), (addr))
#define iowrite32be(v, addr) iowrite32(be32_to_cpu(v), (addr))
/************************************************************************/
/* VLANs */
#define vlan_dev_vlan_id(netdev) (VLAN_DEV_INFO(netdev)->vlan_id)
#define vlan_dev_real_dev(netdev) (VLAN_DEV_INFO(netdev)->real_dev)
/************************************************************************/
/* DMA */
/* In vmkernel we don't support dma attributes */
struct dma_attrs;
#define dma_map_single_attrs(dev, cpu_addr, size, dir, attrs) \
dma_map_single(dev, cpu_addr, size, dir)
#define dma_unmap_single_attrs(dev, dma_addr, size, dir, attrs) \
dma_unmap_single(dev, dma_addr, size, dir)
#define dma_map_sg_attrs(dev, sgl, nents, dir, attrs) \
dma_map_sg(dev, sgl, nents, dir)
#define dma_unmap_sg_attrs(dev, sgl, nents, dir, attrs) \
dma_unmap_sg(dev, sgl, nents, dir)
/************************************************************************/
/* PCI */
static inline int pci_pcie_cap(struct pci_dev *pdev)
{
return pci_find_capability(pdev, PCI_CAP_ID_EXP);
}
/*
* DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
* @_table: device table name
*
* This macro is used to create a struct pci_device_id array (a device table)
* in a generic manner.
*/
#define DEFINE_PCI_DEVICE_TABLE(_table) \
const struct pci_device_id _table[]
/*
* PCI_VDEVICE - macro used to describe a specific pci device in short form
* @vendor: the vendor name
* @device: the 16 bit PCI Device ID
*
* This macro is used to create a struct pci_device_id that matches a
* specific PCI device. The subvendor, and subdevice fields will be set
* to PCI_ANY_ID. The macro allows the next field to follow as the device
* private data.
*/
#define PCI_VDEVICE(vendor, device) \
PCI_VENDOR_ID_##vendor, (device), \
PCI_ANY_ID, PCI_ANY_ID, 0, 0
/************************************************************************/
/* Bitmap */
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
unsigned long bitmap_find_next_zero_area(unsigned long *map,
unsigned long size,
unsigned long start,
unsigned int nr,
unsigned long align_mask);
void bitmap_set(unsigned long *map, int start, int nr);
void bitmap_clear(unsigned long *map, int start, int nr);
/************************************************************************/
/* Radix tree */
#define radix_tree_root hash_table
#define radix_tree_lookup mlnx_radix_tree_lookup
#define radix_tree_insert mlnx_radix_tree_insert
#define radix_tree_delete mlnx_radix_tree_delete
#ifdef INIT_RADIX_TREE
#undef INIT_RADIX_TREE
#endif
#define INIT_RADIX_TREE(p_tree, flags) do { \
memset((p_tree), 0, sizeof(struct hash_table)); \
} while (0);
static inline void * mlnx_radix_tree_lookup(struct radix_tree_root *p_tree,
unsigned long index) {
return hash_lookup(p_tree, index);
}
static inline int mlnx_radix_tree_insert(struct radix_tree_root *p_tree,
unsigned long index,
void *p_data) {
return hash_insert(p_tree, index, p_data);
}
static inline void * mlnx_radix_tree_delete(struct radix_tree_root *p_tree,
unsigned long index) {
return hash_delete(p_tree, index);
}
/************************************************************************/
/* Ethtool */
int __ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *p_cmd);
void ethtool_cmd_speed_set(struct ethtool_cmd *ep, __u32 speed);
__u32 ethtool_cmd_speed(const struct ethtool_cmd *ep);
/************************************************************************/
/* Hex dump */
int hex_to_bin(char ch);
/************************************************************************/
/* Pages */
unsigned long get_zeroed_page(gfp_t gfp_mask);
/************************************************************************/
/* Work Queues */
#define alloc_workqueue(name, flags, max_active) \
__create_workqueue((name), (max_active))
int __cancel_delayed_work(struct delayed_work *dwork);
static inline struct delayed_work *to_delayed_work(struct work_struct *work)
{
return container_of(work, struct delayed_work, work);
}
/************************************************************************/
/* Mem */
/*
* kmemdup - duplicate region of memory
*
* @src: memory region to duplicate
* @len: memory region length
* @gfp: GFP mask to use
*/
void *kmemdup(const void *src, size_t len, gfp_t gfp);
/************************************************************************/
/* File */
int nonseekable_open(struct inode *inode, struct file *filp);
#endif /* _MLNX_COMPAT_H */
|