diff options
| author | Linux Build Service Account <lnxbuild@localhost> | 2019-09-19 23:47:01 -0700 |
|---|---|---|
| committer | Linux Build Service Account <lnxbuild@localhost> | 2019-09-19 23:47:01 -0700 |
| commit | d4009ffcd8674d76a77441c1edaefcb886668fb9 (patch) | |
| tree | 7b2ca75730e4f9de891b22efdbd5babf3e6381b1 /include/linux | |
| parent | 88dccf7d633bf154097ee158ec19965bdc1cc429 (diff) | |
| parent | 36f663352d8e241b313ae19a94c5d30ea077e243 (diff) | |
Merge 36f663352d8e241b313ae19a94c5d30ea077e243 on remote branch
Change-Id: I65222b09858e0e72a2532954573a1d191882e6c3
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/acpi.h | 5 | ||||
| -rw-r--r-- | include/linux/ceph/buffer.h | 3 | ||||
| -rw-r--r-- | include/linux/coda.h | 3 | ||||
| -rw-r--r-- | include/linux/coda_psdev.h | 11 | ||||
| -rw-r--r-- | include/linux/compiler.h | 16 | ||||
| -rw-r--r-- | include/linux/cred.h | 7 | ||||
| -rw-r--r-- | include/linux/elevator.h | 2 | ||||
| -rw-r--r-- | include/linux/fs.h | 3 | ||||
| -rw-r--r-- | include/linux/gpio.h | 24 | ||||
| -rw-r--r-- | include/linux/hid.h | 1 | ||||
| -rw-r--r-- | include/linux/if_pppox.h | 3 | ||||
| -rw-r--r-- | include/linux/mmc/host.h | 4 | ||||
| -rw-r--r-- | include/linux/module.h | 4 | ||||
| -rw-r--r-- | include/linux/qcn_sdio_al.h | 296 | ||||
| -rw-r--r-- | include/linux/qdsp6v2/apr.h | 2 | ||||
| -rw-r--r-- | include/linux/qdsp6v2/rtac.h | 2 | ||||
| -rw-r--r-- | include/linux/rcupdate.h | 2 | ||||
| -rw-r--r-- | include/linux/sched.h | 4 | ||||
| -rw-r--r-- | include/linux/siphash.h | 145 |
19 files changed, 498 insertions, 39 deletions
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 3672893b275e..6a30f1e03aa9 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -226,7 +226,10 @@ void acpi_set_irq_model(enum acpi_irq_model_id model, #ifdef CONFIG_X86_IO_APIC extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity); #else -#define acpi_get_override_irq(gsi, trigger, polarity) (-1) +static inline int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity) +{ + return -1; +} #endif /* * This function undoes the effect of one call to acpi_register_gsi(). diff --git a/include/linux/ceph/buffer.h b/include/linux/ceph/buffer.h index 07ca15e76100..dada47a4360f 100644 --- a/include/linux/ceph/buffer.h +++ b/include/linux/ceph/buffer.h @@ -29,7 +29,8 @@ static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b) static inline void ceph_buffer_put(struct ceph_buffer *b) { - kref_put(&b->kref, ceph_buffer_release); + if (b) + kref_put(&b->kref, ceph_buffer_release); } extern int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end); diff --git a/include/linux/coda.h b/include/linux/coda.h index d30209b9cef8..0ca0c83fdb1c 100644 --- a/include/linux/coda.h +++ b/include/linux/coda.h @@ -58,8 +58,7 @@ Mellon the rights to redistribute these changes without encumbrance. #ifndef _CODA_HEADER_ #define _CODA_HEADER_ -#if defined(__linux__) typedef unsigned long long u_quad_t; -#endif + #include <uapi/linux/coda.h> #endif diff --git a/include/linux/coda_psdev.h b/include/linux/coda_psdev.h index 5b8721efa948..fe1466daf291 100644 --- a/include/linux/coda_psdev.h +++ b/include/linux/coda_psdev.h @@ -19,6 +19,17 @@ struct venus_comm { struct mutex vc_mutex; }; +/* messages between coda filesystem in kernel and Venus */ +struct upc_req { + struct list_head uc_chain; + caddr_t uc_data; + u_short uc_flags; + u_short uc_inSize; /* Size is at most 5000 bytes */ + u_short uc_outSize; + u_short uc_opcode; /* copied from data to save lookup */ + int uc_unique; + wait_queue_head_t uc_sleep; /* process' wait queue */ +}; static inline struct venus_comm *coda_vcp(struct super_block *sb) { diff --git a/include/linux/compiler.h b/include/linux/compiler.h index ed772311ec1f..5508011cc0c7 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -52,6 +52,22 @@ extern void __chk_io_ptr(const volatile void __iomem *); #ifdef __KERNEL__ +/* + * Minimal backport of compiler_attributes.h to add support for __copy + * to v4.9.y so that we can use it in init/exit_module to avoid + * -Werror=missing-attributes errors on GCC 9. + */ +#ifndef __has_attribute +# define __has_attribute(x) __GCC4_has_attribute_##x +# define __GCC4_has_attribute___copy__ 0 +#endif + +#if __has_attribute(__copy__) +# define __copy(symbol) __attribute__((__copy__(symbol))) +#else +# define __copy(symbol) +#endif + #ifdef __GNUC__ #include <linux/compiler-gcc.h> #endif diff --git a/include/linux/cred.h b/include/linux/cred.h index 9e120c92551b..d2db1da3036c 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -153,7 +153,11 @@ struct cred { struct user_struct *user; /* real user ID subscription */ struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */ struct group_info *group_info; /* supplementary groups for euid/fsgid */ - struct rcu_head rcu; /* RCU deletion hook */ + /* RCU deletion */ + union { + int non_rcu; /* Can we skip RCU deletion? */ + struct rcu_head rcu; /* RCU deletion hook */ + }; }; extern void __put_cred(struct cred *); @@ -251,6 +255,7 @@ static inline const struct cred *get_cred(const struct cred *cred) { struct cred *nonconst_cred = (struct cred *) cred; validate_creds(cred); + nonconst_cred->non_rcu = 0; return get_new_cred(nonconst_cred); } diff --git a/include/linux/elevator.h b/include/linux/elevator.h index 638b324f0291..92ad08a29884 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h @@ -97,7 +97,7 @@ struct elevator_type struct module *elevator_owner; /* managed by elevator core */ - char icq_cache_name[ELV_NAME_MAX + 5]; /* elvname + "_io_cq" */ + char icq_cache_name[ELV_NAME_MAX + 6]; /* elvname + "_io_cq" */ struct list_head list; }; diff --git a/include/linux/fs.h b/include/linux/fs.h index 7493e807f073..66360a2f97bc 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3141,4 +3141,7 @@ static inline bool dir_relax(struct inode *inode) extern bool path_noexec(const struct path *path); extern void inode_nohighmem(struct inode *inode); +int vfs_ioc_setflags_prepare(struct inode *inode, unsigned int oldflags, + unsigned int flags); + #endif /* _LINUX_FS_H */ diff --git a/include/linux/gpio.h b/include/linux/gpio.h index d12b5d566e4b..11555bd821b7 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -229,30 +229,6 @@ static inline int irq_to_gpio(unsigned irq) return -EINVAL; } -static inline int -gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, - unsigned int gpio_offset, unsigned int pin_offset, - unsigned int npins) -{ - WARN_ON(1); - return -EINVAL; -} - -static inline int -gpiochip_add_pingroup_range(struct gpio_chip *chip, - struct pinctrl_dev *pctldev, - unsigned int gpio_offset, const char *pin_group) -{ - WARN_ON(1); - return -EINVAL; -} - -static inline void -gpiochip_remove_pin_ranges(struct gpio_chip *chip) -{ - WARN_ON(1); -} - static inline int devm_gpio_request(struct device *dev, unsigned gpio, const char *label) { diff --git a/include/linux/hid.h b/include/linux/hid.h index 5f1e901353ed..d16de62231d3 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -378,7 +378,6 @@ struct hid_global { struct hid_local { unsigned usage[HID_MAX_USAGES]; /* usage array */ - u8 usage_size[HID_MAX_USAGES]; /* usage size array */ unsigned collection_index[HID_MAX_USAGES]; /* collection index array */ unsigned usage_index; unsigned usage_minimum; diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h index 63828a5870f1..e578f38480e5 100644 --- a/include/linux/if_pppox.h +++ b/include/linux/if_pppox.h @@ -105,6 +105,9 @@ extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp); extern void unregister_pppox_proto(int proto_num); extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */ extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); +extern int pppox_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); + +#define PPPOEIOCSFWD32 _IOW(0xB1 ,0, compat_size_t) /* PPPoX socket states */ enum { diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 49648aa63ee3..2dff3db6e4f3 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -735,8 +735,8 @@ static inline int mmc_boot_partition_access(struct mmc_host *host) static inline bool mmc_card_and_host_support_async_int(struct mmc_host *host) { - return ((host->caps2 & MMC_CAP2_ASYNC_SDIO_IRQ_4BIT_MODE) && - (host->card->cccr.async_intr_sup)); + return (host->card && (host->caps2 & MMC_CAP2_ASYNC_SDIO_IRQ_4BIT_MODE) + && (host->card->cccr.async_intr_sup)); } static inline int mmc_host_uhs(struct mmc_host *host) diff --git a/include/linux/module.h b/include/linux/module.h index dfe5c2e25ba1..d237d0574179 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -127,13 +127,13 @@ extern void cleanup_module(void); #define module_init(initfn) \ static inline initcall_t __maybe_unused __inittest(void) \ { return initfn; } \ - int init_module(void) __attribute__((alias(#initfn))); + int init_module(void) __copy(initfn) __attribute__((alias(#initfn))); /* This is only required if you want to be unloadable. */ #define module_exit(exitfn) \ static inline exitcall_t __maybe_unused __exittest(void) \ { return exitfn; } \ - void cleanup_module(void) __attribute__((alias(#exitfn))); + void cleanup_module(void) __copy(exitfn) __attribute__((alias(#exitfn))); #endif diff --git a/include/linux/qcn_sdio_al.h b/include/linux/qcn_sdio_al.h new file mode 100644 index 000000000000..bee020b0ccb4 --- /dev/null +++ b/include/linux/qcn_sdio_al.h @@ -0,0 +1,296 @@ +/* Copyright (c) 2019 The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _QCN_SDIO_AL_ +#define _QCN_SDIO_AL_ + + +/** + * ------------------------------------ + * ------- SDIO AL Interface ---------- + * ------------------------------------ + * + * This file contains the proposed SDIO AL (Abstraction Layer) interface. + * Terminologies: + * SDIO AL : SDIO host function-1 driver + * SDIO AL client: Clients of SDIO host function-1 driver. + * WLAN, QMI, DIAG etc. are possible clients. + * Remote SDIO client: SDIO client on device side which implements ADMA + * functionality as function-1 + */ + +enum sdio_al_dma_direction { + SDIO_AL_TX, + SDIO_AL_RX, +}; + +/** + * struct sdio_al_client_handle - unique handler to identify + * each SDIO AL (Abstraction Layer) client + * + * @id: unique id for each client + * @block_size: block size + * @func: pointer to sdio_func data structure, some clients may need this. + * @client_priv: This is client priv that can used by client driver. + */ +struct sdio_al_client_handle { + int id; + struct sdio_al_client_data *client_data; + unsigned int block_size; + struct sdio_func *func; + void *client_priv; +}; + +/** + * struct sdio_al_xfer_result - Completed buffer information + * + * @buf_addr: Address of data buffer + * + * @xfer_len: Transfer data length in bytes + * + * @xfer_status: status of transfer, 0 if successful, + * negative in case of error + */ +struct sdio_al_xfer_result { + void *buf_addr; + size_t xfer_len; + int xfer_status; +}; + +enum sdio_al_lpm_event { + LPM_ENTER, /* SDIO client will be put to LPM mode soon */ + LPM_EXIT, /* SDIO client has exited LPM mode */ +}; + +/** + * sdio_al_client_data - client data of sdio_al + * + * @name: client name, could be one of the following: + * "SDIO_AL_CLIENT_WLAN", + * "SDIO_AL_CLIENT_QMI", + * "SDIO_AL_CLIENT_DIAG", + * "SDIO_AL_CLIENT_TTY" + * + * @probe: This probe function is called by SDIO AL driver when it is ready for + * SDIO traffic. SDIO AL client must wait for this callback before + * initiating any transfer over SDIO transport layer. + * + * @remove: This remove function is called by SDIO AL driver when it isn't ready + * for SDIO traffic. SDIO AL client must stop issuing any transfers + * after getting this callback, ongoing transfers would be errored out + * by SDIO AL. + * + * @lpm_notify_cb: callback to notify SDIO AL clients about Low Power modes. + * + */ +struct sdio_al_client_data { + const char *name; + + int id; + + int mode; + + int (*probe)(struct sdio_al_client_handle *); + + int (*remove)(struct sdio_al_client_handle *); + + void (*lpm_notify_cb)(struct sdio_al_client_handle *, + enum sdio_al_lpm_event event); +}; + +/** + * sdio_al_channel_handle - channel handle of sdio_al + * + * @id: Channel id unique at the AL layer + * + * @client_data: Client to which this channel belongs + * + */ +struct sdio_al_channel_handle { + unsigned int channel_id; + + struct sdio_al_channel_data *channel_data; + void *priv; +}; + +/** + * sdio_al_channel_data - channel data of sdio_al + * + * @name: channel name, could be one of the following: + * "SDIO_AL_WLAN_CH0", + * "SDIO_AL_WLAN_CH1", + * "SDIO_AL_QMI_CH0", + * "SDIO_AL_DIAG_CH0", + * "SDIO_AL_TTY_CH0" + * + * @client_data: The client driver by which this channel is being claimed + * + * @ul_xfer_cb: UL/TX data transfer callback. + * SDIO AL client can queue request using sdio_al_queue_transfer() + * asynchronous API, once request is transported over SDIO + * transport, SDIO AL calls "ul_xfer_cb" to notify the transfer + complete. + * + * @dl_xfer_cb: DL/RX data transfer callback + * Once SDIO AL receives requested data from remote SDIO client + * then SDIO AL invokes "dl_xfer_cb" callback to notify the SDIO + * AL client. + * + * @dl_data_avail_cb: callback to notify SDIO AL client that it can read + * specified bytes of data from remote SDIO client, SDIO AL client + * is then expected call sdio_al_queue_transfer() to read the data. + * This is optional and if client doesn't provide this callback + * then SDIO AL would allocate the buffer and SDIO AL + * client would have to memcpy the buffer in dl_xfer_cb(). + * + */ +struct sdio_al_channel_data { + const char *name; + + struct sdio_al_client_data *client_data; + + void (*ul_xfer_cb)(struct sdio_al_channel_handle *, + struct sdio_al_xfer_result *, void *ctxt); + + void (*dl_xfer_cb)(struct sdio_al_channel_handle *, + struct sdio_al_xfer_result *, void *ctxt); + + void (*dl_data_avail_cb)(struct sdio_al_channel_handle *, + unsigned int len); + + void (*dl_meta_data_cb)(struct sdio_al_channel_handle *, + unsigned int data); +}; + +/** + * sdio_al_is_ready - API Check to know whether the al driver is ready + * This API can be used to deffer the probe incase of early execution. + * + * @return zero on success and negative value on error. + * + */ +int sdio_al_is_ready(void); + +/** + * sdio_al_register_client - register as client of sdio AL (function-1 driver) + * SDIO AL driver would allocate the unique instance of + * "struct sdio_al_client_handle" and returns to client. + * + * @client_data: pointer to SDIO AL client data (struct sdio_al_client_data) + * + * @return valid sdio_al_client_handler ptr on success, negative value on error. + * + */ +struct sdio_al_client_handle *sdio_al_register_client( + struct sdio_al_client_data *client_data); + +/** + * sdio_al_deregister_client - deregisters client from SDIO AL + * (function-1 driver) + * + * @handle: sdio_al client handler + * + */ +void sdio_al_deregister_client(struct sdio_al_client_handle *handle); + +/** + * sdio_al_register_channel - register a channel for a client of SDIO AL + * SDIO AL driver would allocate a unique instance of the "struct + * sdio_al_channel_handle" and returns to the client. + * + * @client_handle: The client to which the channel shall belong + * + * @channel_data: The channel data which contains the details of the channel + * + * @return valid channel handle in success error on success, error pointer on + * failure + */ +struct sdio_al_channel_handle *sdio_al_register_channel( + struct sdio_al_client_handle *client_handle, + struct sdio_al_channel_data *client_data); + +/** + * sdio_al_deregister_channel - deregister a channel for a client of SDIO AL + * + * @ch_handle: The channel handle which needs to deregistered + * + * @return none + */ +void sdio_al_deregister_channel(struct sdio_al_channel_handle *ch_handle); + + +/** + * sdio_al_queue_transfer_async - Queue asynchronous data transfer request + * All transfers are asynchronous transfers, SDIO AL will call + * ul_xfer_cb or dl_xfer_cb callback to nofity completion to SDIO AL client. + * + * @ch_handle: sdio_al channel handle + * + * @dir: Data direction (DMA_TO_DEVICE for TX, DMA_FROM_DEVICE for RX) + * + * @buf: Data buffer + * + * @len: Size in bytes + * + * @priority: set any non-zero value for higher priority, 0 for normal priority + * All SDIO AL clients except WLAN client is expected to use normal + * priority. + * + * @return 0 on success, non-zero in case of error + */ +int sdio_al_queue_transfer_async(struct sdio_al_channel_handle *handle, + enum sdio_al_dma_direction dir, + void *buf, size_t len, int priority, void *ctxt); + +/** + * sdio_al_queue_transfer - Queue synchronous data transfer request + * In constrast to asynchronous transfer API sdio_al_queue_transfer(), this + * API will completely the request synchronously. If there is no outstanding + * request at SDIO AL Layer, request will be immediately initiated on SDIO bus. + * + * @ch_handle: sdio_al channel handle + * + * @dir: Data direction (DMA_TO_DEVICE for TX, DMA_FROM_DEVICE for RX) + * + * @buf: Data buffer + * + * @len: Size in bytes + * + * @priority: set any non-zero value for higher priority, 0 for normal priority + * All SDIO AL clients except WLAN client is expected to use normal + * priority. + * + * @return 0 on success, non-zero in case of error + */ +int sdio_al_queue_transfer(struct sdio_al_channel_handle *ch_handle, + enum sdio_al_dma_direction dir, + void *buf, size_t len, int priority); + + +/** + * sdio_al_meta_transfer - Queue synchronous data transfer request + * In constrast to asynchronous transfer API sdio_al_queue_transfer(), this + * API will completely the request synchronously. If there is no outstanding + * request at SDIO AL Layer, request will be immediately initiated on SDIO bus. + * + * @ch_handle: sdio_al channel handle + * + * @data: Meta data to be transferred + * + * @return 0 on success, non-zero in case of error + */ +int sdio_al_meta_transfer(struct sdio_al_channel_handle *ch_handle, + unsigned int data, unsigned int trans); + +extern void qcn_sdio_client_probe_complete(int id); +int qcn_sdio_card_state(bool enable); +#endif /* _QCN_SDIO_AL_ */ diff --git a/include/linux/qdsp6v2/apr.h b/include/linux/qdsp6v2/apr.h index e7e2a53a70d7..d80320e74661 100644 --- a/include/linux/qdsp6v2/apr.h +++ b/include/linux/qdsp6v2/apr.h @@ -210,4 +210,6 @@ static inline int apr_end_rx_rt(void *handle) int apr_start_rx_rt(void *handle); int apr_end_rx_rt(void *handle); #endif +int apr_dummy_init(void); +void apr_dummy_exit(void); #endif diff --git a/include/linux/qdsp6v2/rtac.h b/include/linux/qdsp6v2/rtac.h index eeea0eb0a837..5bd0923fd72b 100644 --- a/include/linux/qdsp6v2/rtac.h +++ b/include/linux/qdsp6v2/rtac.h @@ -22,7 +22,7 @@ #define RTAC_CVS 1 #define RTAC_VOICE_MODES 2 -#define RTAC_MAX_ACTIVE_DEVICES 4 +#define RTAC_MAX_ACTIVE_DEVICES 6 #define RTAC_MAX_ACTIVE_POPP 8 #define DEFAULT_APP_TYPE 0x00011130 diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index addd03641e1a..0a93e9d1708e 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -852,7 +852,7 @@ static inline void rcu_preempt_sleep_check(void) * read-side critical sections may be preempted and they may also block, but * only when acquiring spinlocks that are subject to priority inheritance. */ -static inline void rcu_read_lock(void) +static __always_inline void rcu_read_lock(void) { __rcu_read_lock(); __acquire(RCU); diff --git a/include/linux/sched.h b/include/linux/sched.h index 2378cbf2612d..a05e1e82ecf3 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2149,7 +2149,7 @@ extern int arch_task_struct_size __read_mostly; extern void task_numa_fault(int last_node, int node, int pages, int flags); extern pid_t task_numa_group_id(struct task_struct *p); extern void set_numabalancing_state(bool enabled); -extern void task_numa_free(struct task_struct *p); +extern void task_numa_free(struct task_struct *p, bool final); extern bool should_numa_migrate_memory(struct task_struct *p, struct page *page, int src_nid, int dst_cpu); #else @@ -2164,7 +2164,7 @@ static inline pid_t task_numa_group_id(struct task_struct *p) static inline void set_numabalancing_state(bool enabled) { } -static inline void task_numa_free(struct task_struct *p) +static inline void task_numa_free(struct task_struct *p, bool final) { } static inline bool should_numa_migrate_memory(struct task_struct *p, diff --git a/include/linux/siphash.h b/include/linux/siphash.h new file mode 100644 index 000000000000..bf21591a9e5e --- /dev/null +++ b/include/linux/siphash.h @@ -0,0 +1,145 @@ +/* Copyright (C) 2016 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. + * + * This file is provided under a dual BSD/GPLv2 license. + * + * SipHash: a fast short-input PRF + * https://131002.net/siphash/ + * + * This implementation is specifically for SipHash2-4 for a secure PRF + * and HalfSipHash1-3/SipHash1-3 for an insecure PRF only suitable for + * hashtables. + */ + +#ifndef _LINUX_SIPHASH_H +#define _LINUX_SIPHASH_H + +#include <linux/types.h> +#include <linux/kernel.h> + +#define SIPHASH_ALIGNMENT __alignof__(u64) +typedef struct { + u64 key[2]; +} siphash_key_t; + +static inline bool siphash_key_is_zero(const siphash_key_t *key) +{ + return !(key->key[0] | key->key[1]); +} + +u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key); +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +u64 __siphash_unaligned(const void *data, size_t len, const siphash_key_t *key); +#endif + +u64 siphash_1u64(const u64 a, const siphash_key_t *key); +u64 siphash_2u64(const u64 a, const u64 b, const siphash_key_t *key); +u64 siphash_3u64(const u64 a, const u64 b, const u64 c, + const siphash_key_t *key); +u64 siphash_4u64(const u64 a, const u64 b, const u64 c, const u64 d, + const siphash_key_t *key); +u64 siphash_1u32(const u32 a, const siphash_key_t *key); +u64 siphash_3u32(const u32 a, const u32 b, const u32 c, + const siphash_key_t *key); + +static inline u64 siphash_2u32(const u32 a, const u32 b, + const siphash_key_t *key) +{ + return siphash_1u64((u64)b << 32 | a, key); +} +static inline u64 siphash_4u32(const u32 a, const u32 b, const u32 c, + const u32 d, const siphash_key_t *key) +{ + return siphash_2u64((u64)b << 32 | a, (u64)d << 32 | c, key); +} + + +static inline u64 ___siphash_aligned(const __le64 *data, size_t len, + const siphash_key_t *key) +{ + if (__builtin_constant_p(len) && len == 4) + return siphash_1u32(le32_to_cpup((const __le32 *)data), key); + if (__builtin_constant_p(len) && len == 8) + return siphash_1u64(le64_to_cpu(data[0]), key); + if (__builtin_constant_p(len) && len == 16) + return siphash_2u64(le64_to_cpu(data[0]), le64_to_cpu(data[1]), + key); + if (__builtin_constant_p(len) && len == 24) + return siphash_3u64(le64_to_cpu(data[0]), le64_to_cpu(data[1]), + le64_to_cpu(data[2]), key); + if (__builtin_constant_p(len) && len == 32) + return siphash_4u64(le64_to_cpu(data[0]), le64_to_cpu(data[1]), + le64_to_cpu(data[2]), le64_to_cpu(data[3]), + key); + return __siphash_aligned(data, len, key); +} + +/** + * siphash - compute 64-bit siphash PRF value + * @data: buffer to hash + * @size: size of @data + * @key: the siphash key + */ +static inline u64 siphash(const void *data, size_t len, + const siphash_key_t *key) +{ +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + if (!IS_ALIGNED((unsigned long)data, SIPHASH_ALIGNMENT)) + return __siphash_unaligned(data, len, key); +#endif + return ___siphash_aligned(data, len, key); +} + +#define HSIPHASH_ALIGNMENT __alignof__(unsigned long) +typedef struct { + unsigned long key[2]; +} hsiphash_key_t; + +u32 __hsiphash_aligned(const void *data, size_t len, + const hsiphash_key_t *key); +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +u32 __hsiphash_unaligned(const void *data, size_t len, + const hsiphash_key_t *key); +#endif + +u32 hsiphash_1u32(const u32 a, const hsiphash_key_t *key); +u32 hsiphash_2u32(const u32 a, const u32 b, const hsiphash_key_t *key); +u32 hsiphash_3u32(const u32 a, const u32 b, const u32 c, + const hsiphash_key_t *key); +u32 hsiphash_4u32(const u32 a, const u32 b, const u32 c, const u32 d, + const hsiphash_key_t *key); + +static inline u32 ___hsiphash_aligned(const __le32 *data, size_t len, + const hsiphash_key_t *key) +{ + if (__builtin_constant_p(len) && len == 4) + return hsiphash_1u32(le32_to_cpu(data[0]), key); + if (__builtin_constant_p(len) && len == 8) + return hsiphash_2u32(le32_to_cpu(data[0]), le32_to_cpu(data[1]), + key); + if (__builtin_constant_p(len) && len == 12) + return hsiphash_3u32(le32_to_cpu(data[0]), le32_to_cpu(data[1]), + le32_to_cpu(data[2]), key); + if (__builtin_constant_p(len) && len == 16) + return hsiphash_4u32(le32_to_cpu(data[0]), le32_to_cpu(data[1]), + le32_to_cpu(data[2]), le32_to_cpu(data[3]), + key); + return __hsiphash_aligned(data, len, key); +} + +/** + * hsiphash - compute 32-bit hsiphash PRF value + * @data: buffer to hash + * @size: size of @data + * @key: the hsiphash key + */ +static inline u32 hsiphash(const void *data, size_t len, + const hsiphash_key_t *key) +{ +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + if (!IS_ALIGNED((unsigned long)data, HSIPHASH_ALIGNMENT)) + return __hsiphash_unaligned(data, len, key); +#endif + return ___hsiphash_aligned(data, len, key); +} + +#endif /* _LINUX_SIPHASH_H */ |
