linux/drivers/net/ethernet/netronome/nfp/ccm_mbox.c

// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
/* Copyright (C) 2019 Netronome Systems, Inc. */

#include <linux/bitfield.h>
#include <linux/io.h>
#include <linux/skbuff.h>

#include "ccm.h"
#include "nfp_net.h"

/* CCM messages via the mailbox.  CMSGs get wrapped into simple TLVs
 * and copied into the mailbox.  Multiple messages can be copied to
 * form a batch.  Threads come in with CMSG formed in an skb, then
 * enqueue that skb onto the request queue.  If threads skb is first
 * in queue this thread will handle the mailbox operation.  It copies
 * up to 64 messages into the mailbox (making sure that both requests
 * and replies will fit.  After FW is done processing the batch it
 * copies the data out and wakes waiting threads.
 * If a thread is waiting it either gets its the message completed
 * (response is copied into the same skb as the request, overwriting
 * it), or becomes the first in queue.
 * Completions and next-to-run are signaled via the control buffer
 * to limit potential cache line bounces.
 */

#define NFP_CCM_MBOX_BATCH_LIMIT
#define NFP_CCM_TIMEOUT
#define NFP_CCM_MAX_QLEN

enum nfp_net_mbox_cmsg_state {};

/**
 * struct nfp_ccm_mbox_cmsg_cb - CCM mailbox specific info
 * @state:	processing state (/stage) of the message
 * @err:	error encountered during processing if any
 * @max_len:	max(request_len, reply_len)
 * @exp_reply:	expected reply length (0 means don't validate)
 * @posted:	the message was posted and nobody waits for the reply
 */
struct nfp_ccm_mbox_cmsg_cb {};

static u32 nfp_ccm_mbox_max_msg(struct nfp_net *nn)
{}

static void
nfp_ccm_mbox_msg_init(struct sk_buff *skb, unsigned int exp_reply, int max_len)
{}

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

static bool nfp_ccm_mbox_done(struct sk_buff *skb)
{}

static bool nfp_ccm_mbox_in_progress(struct sk_buff *skb)
{}

static void nfp_ccm_mbox_set_busy(struct sk_buff *skb)
{}

static bool nfp_ccm_mbox_is_posted(struct sk_buff *skb)
{}

static void nfp_ccm_mbox_mark_posted(struct sk_buff *skb)
{}

static bool nfp_ccm_mbox_is_first(struct nfp_net *nn, struct sk_buff *skb)
{}

static bool nfp_ccm_mbox_should_run(struct nfp_net *nn, struct sk_buff *skb)
{}

static void nfp_ccm_mbox_mark_next_runner(struct nfp_net *nn)
{}

static void
nfp_ccm_mbox_write_tlv(struct nfp_net *nn, u32 off, u32 type, u32 len)
{}

static void nfp_ccm_mbox_copy_in(struct nfp_net *nn, struct sk_buff *last)
{}

static struct sk_buff *
nfp_ccm_mbox_find_req(struct nfp_net *nn, __be16 tag, struct sk_buff *last)
{}

static void nfp_ccm_mbox_copy_out(struct nfp_net *nn, struct sk_buff *last)
{}

static void
nfp_ccm_mbox_mark_all_err(struct nfp_net *nn, struct sk_buff *last, int err)
{}

static void nfp_ccm_mbox_run_queue_unlock(struct nfp_net *nn)
	__releases(&nn->mbox_cmsg.queue.lock)
{}

static int nfp_ccm_mbox_skb_return(struct sk_buff *skb)
{}

/* If wait timed out but the command is already in progress we have
 * to wait until it finishes.  Runners has ownership of the skbs marked
 * as busy.
 */
static int
nfp_ccm_mbox_unlink_unlock(struct nfp_net *nn, struct sk_buff *skb,
			   enum nfp_ccm_type type)
	__releases(&nn->mbox_cmsg.queue.lock)
{}

static int
nfp_ccm_mbox_msg_prepare(struct nfp_net *nn, struct sk_buff *skb,
			 enum nfp_ccm_type type,
			 unsigned int reply_size, unsigned int max_reply_size,
			 gfp_t flags)
{}

static int
nfp_ccm_mbox_msg_enqueue(struct nfp_net *nn, struct sk_buff *skb,
			 enum nfp_ccm_type type, bool critical)
{}

int __nfp_ccm_mbox_communicate(struct nfp_net *nn, struct sk_buff *skb,
			       enum nfp_ccm_type type,
			       unsigned int reply_size,
			       unsigned int max_reply_size, bool critical)
{}

int nfp_ccm_mbox_communicate(struct nfp_net *nn, struct sk_buff *skb,
			     enum nfp_ccm_type type,
			     unsigned int reply_size,
			     unsigned int max_reply_size)
{}

static void nfp_ccm_mbox_post_runq_work(struct work_struct *work)
{}

static void nfp_ccm_mbox_post_wait_work(struct work_struct *work)
{}

int nfp_ccm_mbox_post(struct nfp_net *nn, struct sk_buff *skb,
		      enum nfp_ccm_type type, unsigned int max_reply_size)
{}

struct sk_buff *
nfp_ccm_mbox_msg_alloc(struct nfp_net *nn, unsigned int req_size,
		       unsigned int reply_size, gfp_t flags)
{}

bool nfp_ccm_mbox_fits(struct nfp_net *nn, unsigned int size)
{}

int nfp_ccm_mbox_init(struct nfp_net *nn)
{}

void nfp_ccm_mbox_clean(struct nfp_net *nn)
{}

int nfp_ccm_mbox_alloc(struct nfp_net *nn)
{}

void nfp_ccm_mbox_free(struct nfp_net *nn)
{}