linux/drivers/greybus/connection.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Greybus connections
 *
 * Copyright 2014 Google Inc.
 * Copyright 2014 Linaro Ltd.
 */

#include <linux/workqueue.h>
#include <linux/greybus.h>

#include "greybus_trace.h"

#define GB_CONNECTION_CPORT_QUIESCE_TIMEOUT

static void gb_connection_kref_release(struct kref *kref);

static DEFINE_SPINLOCK(gb_connections_lock);
static DEFINE_MUTEX(gb_connection_mutex);

/* Caller holds gb_connection_mutex. */
static bool gb_connection_cport_in_use(struct gb_interface *intf, u16 cport_id)
{}

static void gb_connection_get(struct gb_connection *connection)
{}

static void gb_connection_put(struct gb_connection *connection)
{}

/*
 * Returns a reference-counted pointer to the connection if found.
 */
static struct gb_connection *
gb_connection_hd_find(struct gb_host_device *hd, u16 cport_id)
{}

/*
 * Callback from the host driver to let us know that data has been
 * received on the bundle.
 */
void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id,
		       u8 *data, size_t length)
{}
EXPORT_SYMBOL_GPL();

static void gb_connection_kref_release(struct kref *kref)
{}

static void gb_connection_init_name(struct gb_connection *connection)
{}

/*
 * _gb_connection_create() - create a Greybus connection
 * @hd:			host device of the connection
 * @hd_cport_id:	host-device cport id, or -1 for dynamic allocation
 * @intf:		remote interface, or NULL for static connections
 * @bundle:		remote-interface bundle (may be NULL)
 * @cport_id:		remote-interface cport id, or 0 for static connections
 * @handler:		request handler (may be NULL)
 * @flags:		connection flags
 *
 * Create a Greybus connection, representing the bidirectional link
 * between a CPort on a (local) Greybus host device and a CPort on
 * another Greybus interface.
 *
 * A connection also maintains the state of operations sent over the
 * connection.
 *
 * Serialised against concurrent create and destroy using the
 * gb_connection_mutex.
 *
 * Return: A pointer to the new connection if successful, or an ERR_PTR
 * otherwise.
 */
static struct gb_connection *
_gb_connection_create(struct gb_host_device *hd, int hd_cport_id,
		      struct gb_interface *intf,
		      struct gb_bundle *bundle, int cport_id,
		      gb_request_handler_t handler,
		      unsigned long flags)
{}

struct gb_connection *
gb_connection_create_static(struct gb_host_device *hd, u16 hd_cport_id,
			    gb_request_handler_t handler)
{}

struct gb_connection *
gb_connection_create_control(struct gb_interface *intf)
{}

struct gb_connection *
gb_connection_create(struct gb_bundle *bundle, u16 cport_id,
		     gb_request_handler_t handler)
{}
EXPORT_SYMBOL_GPL();

struct gb_connection *
gb_connection_create_flags(struct gb_bundle *bundle, u16 cport_id,
			   gb_request_handler_t handler,
			   unsigned long flags)
{}
EXPORT_SYMBOL_GPL();

struct gb_connection *
gb_connection_create_offloaded(struct gb_bundle *bundle, u16 cport_id,
			       unsigned long flags)
{}
EXPORT_SYMBOL_GPL();

static int gb_connection_hd_cport_enable(struct gb_connection *connection)
{}

static void gb_connection_hd_cport_disable(struct gb_connection *connection)
{}

static int gb_connection_hd_cport_connected(struct gb_connection *connection)
{}

static int gb_connection_hd_cport_flush(struct gb_connection *connection)
{}

static int gb_connection_hd_cport_quiesce(struct gb_connection *connection)
{}

static int gb_connection_hd_cport_clear(struct gb_connection *connection)
{}

/*
 * Request the SVC to create a connection from AP's cport to interface's
 * cport.
 */
static int
gb_connection_svc_connection_create(struct gb_connection *connection)
{}

static void
gb_connection_svc_connection_destroy(struct gb_connection *connection)
{}

/* Inform Interface about active CPorts */
static int gb_connection_control_connected(struct gb_connection *connection)
{}

static void
gb_connection_control_disconnecting(struct gb_connection *connection)
{}

static void
gb_connection_control_disconnected(struct gb_connection *connection)
{}

static int gb_connection_shutdown_operation(struct gb_connection *connection,
					    u8 phase)
{}

static int gb_connection_cport_shutdown(struct gb_connection *connection,
					u8 phase)
{}

static int
gb_connection_cport_shutdown_phase_1(struct gb_connection *connection)
{}

static int
gb_connection_cport_shutdown_phase_2(struct gb_connection *connection)
{}

/*
 * Cancel all active operations on a connection.
 *
 * Locking: Called with connection lock held and state set to DISABLED or
 * DISCONNECTING.
 */
static void gb_connection_cancel_operations(struct gb_connection *connection,
					    int errno)
	__must_hold(&connection->lock)
{}

/*
 * Cancel all active incoming operations on a connection.
 *
 * Locking: Called with connection lock held and state set to ENABLED_TX.
 */
static void
gb_connection_flush_incoming_operations(struct gb_connection *connection,
					int errno)
	__must_hold(&connection->lock)
{}

/*
 * _gb_connection_enable() - enable a connection
 * @connection:		connection to enable
 * @rx:			whether to enable incoming requests
 *
 * Connection-enable helper for DISABLED->ENABLED, DISABLED->ENABLED_TX, and
 * ENABLED_TX->ENABLED state transitions.
 *
 * Locking: Caller holds connection->mutex.
 */
static int _gb_connection_enable(struct gb_connection *connection, bool rx)
{}

int gb_connection_enable(struct gb_connection *connection)
{}
EXPORT_SYMBOL_GPL();

int gb_connection_enable_tx(struct gb_connection *connection)
{}
EXPORT_SYMBOL_GPL();

void gb_connection_disable_rx(struct gb_connection *connection)
{}
EXPORT_SYMBOL_GPL();

void gb_connection_mode_switch_prepare(struct gb_connection *connection)
{}

void gb_connection_mode_switch_complete(struct gb_connection *connection)
{}

void gb_connection_disable(struct gb_connection *connection)
{}
EXPORT_SYMBOL_GPL();

/* Disable a connection without communicating with the remote end. */
void gb_connection_disable_forced(struct gb_connection *connection)
{}
EXPORT_SYMBOL_GPL();

/* Caller must have disabled the connection before destroying it. */
void gb_connection_destroy(struct gb_connection *connection)
{}
EXPORT_SYMBOL_GPL();

void gb_connection_latency_tag_enable(struct gb_connection *connection)
{}
EXPORT_SYMBOL_GPL();

void gb_connection_latency_tag_disable(struct gb_connection *connection)
{}
EXPORT_SYMBOL_GPL();