^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright (c) 2016-2017, Mellanox Technologies. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2016-2017, Dave Watson <davejwatson@fb.com>. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * This software is available to you under a choice of one of two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * licenses. You may choose to be licensed under the terms of the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * General Public License (GPL) Version 2, available from the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * COPYING in the main directory of this source tree, or the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * OpenIB.org BSD license below:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Redistribution and use in source and binary forms, with or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * without modification, are permitted provided that the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * conditions are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * - Redistributions of source code must retain the above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * copyright notice, this list of conditions and the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * - Redistributions in binary form must reproduce the above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * copyright notice, this list of conditions and the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * disclaimer in the documentation and/or other materials
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * provided with the distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define TLS_TOE_DEVICE_NAME_MAX 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * This structure defines the routines for Inline TLS driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * The following routines are optional and filled with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * null pointer if not defined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * @name: Its the name of registered Inline tls device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * @dev_list: Inline tls device list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * int (*feature)(struct tls_toe_device *device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * Called to return Inline TLS driver capability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * int (*hash)(struct tls_toe_device *device, struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * This function sets Inline driver for listen and program
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * device specific functioanlity as required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * void (*unhash)(struct tls_toe_device *device, struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * This function cleans listen state set by Inline TLS driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * void (*release)(struct kref *kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * Release the registered device and allocated resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * @kref: Number of reference to tls_toe_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct tls_toe_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) char name[TLS_TOE_DEVICE_NAME_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct list_head dev_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) int (*feature)(struct tls_toe_device *device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int (*hash)(struct tls_toe_device *device, struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) void (*unhash)(struct tls_toe_device *device, struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) void (*release)(struct kref *kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct kref kref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int tls_toe_bypass(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) int tls_toe_hash(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) void tls_toe_unhash(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) void tls_toe_register_device(struct tls_toe_device *device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) void tls_toe_unregister_device(struct tls_toe_device *device);