--- zzzz-none-000/linux-5.15.111/net/socket.c 2023-05-11 14:00:40.000000000 +0000 +++ puma7-atom-6670-761/linux-5.15.111/net/socket.c 2024-02-07 10:23:31.000000000 +0000 @@ -52,6 +52,13 @@ * Based upon Swansea University Computer Society NET3.039 */ +/* + Includes MaxLinear's changes dated: 2021,2022,2023. + Changed portions - Copyright 2020-2023, MaxLinear, Inc. + Includes Intel Corporation's changes dated: 2017,2018. + Changed portions - Copyright 2017-2020, Intel Corporation. +*/ + #include #include #include @@ -93,7 +100,7 @@ #include #include #include - +#include #include #include @@ -213,6 +220,7 @@ [PF_SMC] = "PF_SMC", [PF_XDP] = "PF_XDP", [PF_MCTP] = "PF_MCTP", + [PF_HWMBOX] = "PF_HWMBOX", }; /* @@ -423,6 +431,18 @@ .kill_sb = kill_anon_super, }; + +static DEFINE_MUTEX(toe_set_hook_mutex); +static int (*toe_acceleration_flag_set_hook)(struct sock *, struct pid *, enum toe_acceleration_flag_set_act); + +void toe_set_hook(int (*hook)(struct sock *, struct pid *, enum toe_acceleration_flag_set_act)) +{ + mutex_lock(&toe_set_hook_mutex); + toe_acceleration_flag_set_hook = hook; + mutex_unlock(&toe_set_hook_mutex); +} +EXPORT_SYMBOL(toe_set_hook); + /* * Obtains the first available file descriptor and sets it up for use. * @@ -455,6 +475,7 @@ struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname) { struct file *file; + struct pid *toe_pid; if (!dname) dname = sock->sk ? sock->sk->sk_prot_creator->name : ""; @@ -470,6 +491,15 @@ sock->file = file; file->private_data = sock; stream_open(SOCK_INODE(sock), file); + if (sock->sk) { + mutex_lock(&toe_set_hook_mutex); + if (toe_acceleration_flag_set_hook) { + toe_pid = find_get_pid(task_pid_nr(current)); + toe_acceleration_flag_set_hook(sock->sk, toe_pid, SOCKET_ALLOCATE); + put_pid(toe_pid); + } + mutex_unlock(&toe_set_hook_mutex); + } return file; } EXPORT_SYMBOL(sock_alloc_file); @@ -641,6 +671,16 @@ static void __sock_release(struct socket *sock, struct inode *inode) { + struct pid * toe_pid; + if (sock->sk) { + mutex_lock(&toe_set_hook_mutex); + if (toe_acceleration_flag_set_hook) { + toe_pid = find_get_pid(task_pid_nr(current)); + toe_acceleration_flag_set_hook(sock->sk, toe_pid, SOCKET_RELEASE); + put_pid(toe_pid); + } + mutex_unlock(&toe_set_hook_mutex); + } if (sock->ops) { struct module *owner = sock->ops->owner; @@ -1082,6 +1122,12 @@ } EXPORT_SYMBOL(brioctl_set); +br_ioctl_hook_t brioctl_get(void) +{ + return br_ioctl_hook; +} +EXPORT_SYMBOL(brioctl_get); + int br_ioctl_call(struct net *net, struct net_bridge *br, unsigned int cmd, struct ifreq *ifr, void __user *uarg) { @@ -1152,6 +1198,9 @@ void __user *argp = (void __user *)arg; int pid, err; struct net *net; +#ifdef CONFIG_AVM_SK_TC_INDEX + unsigned long tc_index; +#endif sock = file->private_data; sk = sock->sk; @@ -1234,6 +1283,20 @@ err = dev_ifconf(net, argp); break; +#ifdef CONFIG_AVM_SK_TC_INDEX + case SIOCSET_TC_INDEX: + err = -EFAULT; + if (get_user(tc_index, (unsigned long __user *)argp)) + break; + sock->sk->sk_tc_index = tc_index; + err = 0; + break; + + case SIOCGET_TC_INDEX: + err = put_user(sock->sk->sk_tc_index, (unsigned long __user *)argp); + break; +#endif + default: err = sock_do_ioctl(net, sock, cmd, arg); break;