From 510ebed7beff2d2aae1901753f54f0c335cc3736 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 3 Mar 2016 09:56:04 +0000 Subject: [PATCH] Add more functions to the LinuxKPI. Define strnicmp as a function macro instead of a regular macro while at it. MFC after: 1 week Sponsored by: Mellanox Technologies --- .../linuxkpi/common/include/linux/etherdevice.h | 6 ++++++ sys/compat/linuxkpi/common/include/linux/kernel.h | 1 + sys/compat/linuxkpi/common/include/linux/slab.h | 1 + sys/compat/linuxkpi/common/include/linux/string.h | 11 ++++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/etherdevice.h b/sys/compat/linuxkpi/common/include/linux/etherdevice.h index 70e5f64581b1..c58136756c26 100644 --- a/sys/compat/linuxkpi/common/include/linux/etherdevice.h +++ b/sys/compat/linuxkpi/common/include/linux/etherdevice.h @@ -93,6 +93,12 @@ ether_addr_equal_64bits(const u8 *pa, const u8 *pb) return (memcmp(pa, pb, 6) == 0); } +static inline void +eth_broadcast_addr(u8 *pa) +{ + memset(pa, 0xff, 6); +} + static inline void random_ether_addr(u8 * dst) { diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 6b6c0afa918c..ef8d0ab218af 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -163,6 +163,7 @@ #define simple_strtol(...) strtol(__VA_ARGS__) #define kstrtol(a,b,c) ({*(c) = strtol(a,0,b); 0;}) #define kstrtoint(a,b,c) ({*(c) = strtol(a,0,b); 0;}) +#define kstrtouint(a,b,c) ({*(c) = strtol(a,0,b); 0;}) #define min(x, y) ((x) < (y) ? (x) : (y)) #define max(x, y) ((x) > (y) ? (x) : (y)) diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h index 1b56b555f44e..f36bc3b99a81 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -46,6 +46,7 @@ MALLOC_DECLARE(M_KMALLOC); #define kzalloc(size, flags) kmalloc((size), (flags) | M_ZERO) #define kzalloc_node(size, flags, node) kzalloc(size, flags) #define kfree(ptr) free(__DECONST(void *, (ptr)), M_KMALLOC) +#define kfree_const(ptr) kfree(ptr) #define krealloc(ptr, size, flags) realloc((ptr), (size), M_KMALLOC, (flags)) #define kcalloc(n, size, flags) kmalloc((n) * (size), flags | M_ZERO) #define vzalloc(size) kzalloc(size, GFP_KERNEL | __GFP_NOWARN) diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h index cf55b098a3fc..b480faf5c2b0 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,8 +37,7 @@ #include -#define strnicmp strncasecmp - +#define strnicmp(...) strncasecmp(__VA_ARGS__) static inline void * kmemdup(const void *src, size_t len, gfp_t gfp) @@ -51,4 +50,10 @@ kmemdup(const void *src, size_t len, gfp_t gfp) return (dst); } +static inline const char * +kstrdup_const(const char *src, gfp_t gfp) +{ + return (kmemdup(src, strlen(src) + 1, gfp)); +} + #endif /* _LINUX_STRING_H_ */