linux/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.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 <net/tcp.h>
#include <net/busy_poll.h>
#include <crypto/aes.h>

#include "chtls.h"
#include "chtls_cm.h"

static bool is_tls_tx(struct chtls_sock *csk)
{}

static bool is_tls_rx(struct chtls_sock *csk)
{}

static int data_sgl_len(const struct sk_buff *skb)
{}

static int nos_ivs(struct sock *sk, unsigned int size)
{}

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

static int max_ivs_size(struct sock *sk, int size)
{}

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

static int flowc_wr_credits(int nparams, int *flowclenp)
{}

static struct sk_buff *create_flowc_wr_skb(struct sock *sk,
					   struct fw_flowc_wr *flowc,
					   int flowclen)
{}

static int send_flowc_wr(struct sock *sk, struct fw_flowc_wr *flowc,
			 int flowclen)
{}

static u8 tcp_state_to_flowc_state(u8 state)
{}

int send_tx_flowc_wr(struct sock *sk, int compl,
		     u32 snd_nxt, u32 rcv_nxt)
{}

/* Copy IVs to WR */
static int tls_copy_ivs(struct sock *sk, struct sk_buff *skb)

{}

/* Copy Key to WR */
static void tls_copy_tx_key(struct sock *sk, struct sk_buff *skb)
{}

static u64 tlstx_incr_seqnum(struct chtls_hws *hws)
{}

static bool is_sg_request(const struct sk_buff *skb)
{}

/*
 * Returns true if an sk_buff carries urgent data.
 */
static bool skb_urgent(struct sk_buff *skb)
{}

/* TLS content type for CPL SFO */
static unsigned char tls_content_type(unsigned char content_type)
{}

static void tls_tx_data_wr(struct sock *sk, struct sk_buff *skb,
			   int dlen, int tls_immd, u32 credits,
			   int expn, int pdus)
{}

/*
 * Calculate the TLS data expansion size
 */
static int chtls_expansion_size(struct sock *sk, int data_len,
				int fullpdu,
				unsigned short *pducnt)
{}

/* WR with IV, KEY and CPL SFO added */
static void make_tlstx_data_wr(struct sock *sk, struct sk_buff *skb,
			       int tls_tx_imm, int tls_len, u32 credits)
{}

static void make_tx_data_wr(struct sock *sk, struct sk_buff *skb,
			    unsigned int immdlen, int len,
			    u32 credits, u32 compl)
{}

static int chtls_wr_size(struct chtls_sock *csk, const struct sk_buff *skb,
			 bool size)
{}

static bool is_ofld_imm(struct chtls_sock *csk, const struct sk_buff *skb)
{}

static unsigned int calc_tx_flits(const struct sk_buff *skb,
				  unsigned int immdlen)
{}

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

int chtls_push_frames(struct chtls_sock *csk, int comp)
{}

static void mark_urg(struct tcp_sock *tp, int flags,
		     struct sk_buff *skb)
{}

/*
 * Returns true if a connection should send more data to TCP engine
 */
static bool should_push(struct sock *sk)
{}

/*
 * Returns true if a TCP socket is corked.
 */
static bool corked(const struct tcp_sock *tp, int flags)
{}

/*
 * Returns true if a send should try to push new data.
 */
static bool send_should_push(struct sock *sk, int flags)
{}

void chtls_tcp_push(struct sock *sk, int flags)
{}

/*
 * Calculate the size for a new send sk_buff.  It's maximum size so we can
 * pack lots of data into it, unless we plan to send it immediately, in which
 * case we size it more tightly.
 *
 * Note: we don't bother compensating for MSS < PAGE_SIZE because it doesn't
 * arise in normal cases and when it does we are just wasting memory.
 */
static int select_size(struct sock *sk, int io_len, int flags, int len)
{}

void skb_entail(struct sock *sk, struct sk_buff *skb, int flags)
{}

static struct sk_buff *get_tx_skb(struct sock *sk, int size)
{}

static struct sk_buff *get_record_skb(struct sock *sk, int size, bool zcopy)
{}

static void tx_skb_finalize(struct sk_buff *skb)
{}

static void push_frames_if_head(struct sock *sk)
{}

static int chtls_skb_copy_to_page_nocache(struct sock *sk,
					  struct iov_iter *from,
					  struct sk_buff *skb,
					  struct page *page,
					  int off, int copy)
{}

static bool csk_mem_free(struct chtls_dev *cdev, struct sock *sk)
{}

static int csk_wait_memory(struct chtls_dev *cdev,
			   struct sock *sk, long *timeo_p)
{}

static int chtls_proccess_cmsg(struct sock *sk, struct msghdr *msg,
			       unsigned char *record_type)
{}

int chtls_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
{}

void chtls_splice_eof(struct socket *sock)
{}

static void chtls_select_window(struct sock *sk)
{}

/*
 * Send RX credits through an RX_DATA_ACK CPL message.  We are permitted
 * to return without sending the message in case we cannot allocate
 * an sk_buff.  Returns the number of credits sent.
 */
static u32 send_rx_credits(struct chtls_sock *csk, u32 credits)
{}

#define CREDIT_RETURN_STATE

/*
 * Called after some received data has been read.  It returns RX credits
 * to the HW for the amount of data processed.
 */
static void chtls_cleanup_rbuf(struct sock *sk, int copied)
{}

static int chtls_pt_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
			    int flags, int *addr_len)
{}

/*
 * Peek at data in a socket's receive buffer.
 */
static int peekmsg(struct sock *sk, struct msghdr *msg,
		   size_t len, int flags)
{}

int chtls_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
		  int flags, int *addr_len)
{}