linux/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018 Chelsio Communications, Inc.
 *
 * Written by: Atul Gupta ([email protected])
 */

#include <linux/module.h>
#include <linux/list.h>
#include <linux/workqueue.h>
#include <linux/skbuff.h>
#include <linux/timer.h>
#include <linux/notifier.h>
#include <linux/inetdevice.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/sched/signal.h>
#include <linux/kallsyms.h>
#include <linux/kprobes.h>
#include <linux/if_vlan.h>
#include <linux/ipv6.h>
#include <net/ipv6.h>
#include <net/transp_v6.h>
#include <net/ip6_route.h>
#include <net/inet_common.h>
#include <net/tcp.h>
#include <net/dst.h>
#include <net/tls.h>
#include <net/addrconf.h>
#include <net/secure_seq.h>

#include "chtls.h"
#include "chtls_cm.h"
#include "clip_tbl.h"
#include "t4_tcb.h"

/*
 * State transitions and actions for close.  Note that if we are in SYN_SENT
 * we remain in that state as we cannot control a connection while it's in
 * SYN_SENT; such connections are allowed to establish and are then aborted.
 */
static unsigned char new_state[16] =;

static struct chtls_sock *chtls_sock_create(struct chtls_dev *cdev)
{}

static void chtls_sock_release(struct kref *ref)
{}

static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
					    struct sock *sk)
{}

static void assign_rxopt(struct sock *sk, unsigned int opt)
{}

static void chtls_purge_receive_queue(struct sock *sk)
{}

static void chtls_purge_write_queue(struct sock *sk)
{}

static void chtls_purge_recv_queue(struct sock *sk)
{}

static void abort_arp_failure(void *handle, struct sk_buff *skb)
{}

static struct sk_buff *alloc_ctrl_skb(struct sk_buff *skb, int len)
{}

static void chtls_send_abort(struct sock *sk, int mode, struct sk_buff *skb)
{}

static void chtls_send_reset(struct sock *sk, int mode, struct sk_buff *skb)
{}

static void release_tcp_port(struct sock *sk)
{}

static void tcp_uncork(struct sock *sk)
{}

static void chtls_close_conn(struct sock *sk)
{}

/*
 * Perform a state transition during close and return the actions indicated
 * for the transition.  Do not make this function inline, the main reason
 * it exists at all is to avoid multiple inlining of tcp_set_state.
 */
static int make_close_transition(struct sock *sk)
{}

void chtls_close(struct sock *sk, long timeout)
{}

/*
 * Wait until a socket enters on of the given states.
 */
static int wait_for_states(struct sock *sk, unsigned int states)
{}

int chtls_disconnect(struct sock *sk, int flags)
{}

#define SHUTDOWN_ELIGIBLE_STATE
void chtls_shutdown(struct sock *sk, int how)
{}

void chtls_destroy_sock(struct sock *sk)
{}

static void reset_listen_child(struct sock *child)
{}

static void chtls_disconnect_acceptq(struct sock *listen_sk)
{}

static int listen_hashfn(const struct sock *sk)
{}

static struct listen_info *listen_hash_add(struct chtls_dev *cdev,
					   struct sock *sk,
					   unsigned int stid)
{}

static int listen_hash_find(struct chtls_dev *cdev,
			    struct sock *sk)
{}

static int listen_hash_del(struct chtls_dev *cdev,
			   struct sock *sk)
{}

static void cleanup_syn_rcv_conn(struct sock *child, struct sock *parent)
{}

static void chtls_reset_synq(struct listen_ctx *listen_ctx)
{}

int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
{}

void chtls_listen_stop(struct chtls_dev *cdev, struct sock *sk)
{}

static int chtls_pass_open_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
{}

static int chtls_close_listsrv_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
{}

static void chtls_purge_wr_queue(struct sock *sk)
{}

static void chtls_release_resources(struct sock *sk)
{}

static void chtls_conn_done(struct sock *sk)
{}

static void do_abort_syn_rcv(struct sock *child, struct sock *parent)
{}

static void pass_open_abort(struct sock *child, struct sock *parent,
			    struct sk_buff *skb)
{}

static void bl_pass_open_abort(struct sock *lsk, struct sk_buff *skb)
{}

static void chtls_pass_open_arp_failure(struct sock *sk,
					struct sk_buff *skb)
{}

static void chtls_accept_rpl_arp_failure(void *handle,
					 struct sk_buff *skb)
{}

static unsigned int chtls_select_mss(const struct chtls_sock *csk,
				     unsigned int pmtu,
				     struct cpl_pass_accept_req *req)
{}

static unsigned int select_rcv_wscale(int space, int wscale_ok, int win_clamp)
{}

static void chtls_pass_accept_rpl(struct sk_buff *skb,
				  struct cpl_pass_accept_req *req,
				  unsigned int tid)

{}

static void inet_inherit_port(struct sock *lsk, struct sock *newsk)
{}

static int chtls_backlog_rcv(struct sock *sk, struct sk_buff *skb)
{}

static void chtls_set_tcp_window(struct chtls_sock *csk)
{}

static struct sock *chtls_recv_sock(struct sock *lsk,
				    struct request_sock *oreq,
				    void *network_hdr,
				    const struct cpl_pass_accept_req *req,
				    struct chtls_dev *cdev)
{}

/*
 * Populate a TID_RELEASE WR.  The skb must be already propely sized.
 */
static  void mk_tid_release(struct sk_buff *skb,
			    unsigned int chan, unsigned int tid)
{}

static int chtls_get_module(struct sock *sk)
{}

static void chtls_pass_accept_request(struct sock *sk,
				      struct sk_buff *skb)
{}

/*
 * Handle a CPL_PASS_ACCEPT_REQ message.
 */
static int chtls_pass_accept_req(struct chtls_dev *cdev, struct sk_buff *skb)
{}

/*
 * Completes some final bits of initialization for just established connections
 * and changes their state to TCP_ESTABLISHED.
 *
 * snd_isn here is the ISN after the SYN, i.e., the true ISN + 1.
 */
static void make_established(struct sock *sk, u32 snd_isn, unsigned int opt)
{}

static void chtls_abort_conn(struct sock *sk, struct sk_buff *skb)
{}

static struct sock *reap_list;
static DEFINE_SPINLOCK(reap_list_lock);

/*
 * Process the reap list.
 */
DECLARE_TASK_FUNC(process_reap_list, task_param)
{}

static DECLARE_WORK(reap_task, process_reap_list);

static void add_to_reap_list(struct sock *sk)
{}

static void add_pass_open_to_parent(struct sock *child, struct sock *lsk,
				    struct chtls_dev *cdev)
{}

static void bl_add_pass_open_to_parent(struct sock *lsk, struct sk_buff *skb)
{}

static int chtls_pass_establish(struct chtls_dev *cdev, struct sk_buff *skb)
{}

/*
 * Handle receipt of an urgent pointer.
 */
static void handle_urg_ptr(struct sock *sk, u32 urg_seq)
{}

static void check_sk_callbacks(struct chtls_sock *csk)
{}

/*
 * Handles Rx data that arrives in a state where the socket isn't accepting
 * new data.
 */
static void handle_excess_rx(struct sock *sk, struct sk_buff *skb)
{}

static void chtls_recv_data(struct sock *sk, struct sk_buff *skb)
{}

static int chtls_rx_data(struct chtls_dev *cdev, struct sk_buff *skb)
{}

static void chtls_recv_pdu(struct sock *sk, struct sk_buff *skb)
{}

static int chtls_rx_pdu(struct chtls_dev *cdev, struct sk_buff *skb)
{}

static void chtls_set_hdrlen(struct sk_buff *skb, unsigned int nlen)
{}

static void chtls_rx_hdr(struct sock *sk, struct sk_buff *skb)
{}

static int chtls_rx_cmp(struct chtls_dev *cdev, struct sk_buff *skb)
{}

static void chtls_timewait(struct sock *sk)
{}

static void chtls_peer_close(struct sock *sk, struct sk_buff *skb)
{}

static void chtls_close_con_rpl(struct sock *sk, struct sk_buff *skb)
{}

static struct sk_buff *get_cpl_skb(struct sk_buff *skb,
				   size_t len, gfp_t gfp)
{}

static void set_abort_rpl_wr(struct sk_buff *skb, unsigned int tid,
			     int cmd)
{}

static void send_defer_abort_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
{}

/*
 * Add an skb to the deferred skb queue for processing from process context.
 */
static void t4_defer_reply(struct sk_buff *skb, struct chtls_dev *cdev,
			   defer_handler_t handler)
{}

static void chtls_send_abort_rpl(struct sock *sk, struct sk_buff *skb,
				 struct chtls_dev *cdev,
				 int status, int queue)
{}

/*
 * This is run from a listener's backlog to abort a child connection in
 * SYN_RCV state (i.e., one on the listener's SYN queue).
 */
static void bl_abort_syn_rcv(struct sock *lsk, struct sk_buff *skb)
{}

static int abort_syn_rcv(struct sock *sk, struct sk_buff *skb)
{}

static void chtls_abort_req_rss(struct sock *sk, struct sk_buff *skb)
{}

static void chtls_abort_rpl_rss(struct sock *sk, struct sk_buff *skb)
{}

static int chtls_conn_cpl(struct chtls_dev *cdev, struct sk_buff *skb)
{}

static void chtls_rx_ack(struct sock *sk, struct sk_buff *skb)
{}

static int chtls_wr_ack(struct chtls_dev *cdev, struct sk_buff *skb)
{}

static int chtls_set_tcb_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
{}

chtls_handler_func chtls_handlers[NUM_CPL_CMDS] =;