linux/drivers/net/thunderbolt/main.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Networking over Thunderbolt/USB4 cables using USB4NET protocol
 * (formerly Apple ThunderboltIP).
 *
 * Copyright (C) 2017, Intel Corporation
 * Authors: Amir Levy <[email protected]>
 *          Michael Jamet <[email protected]>
 *          Mika Westerberg <[email protected]>
 */

#include <linux/atomic.h>
#include <linux/highmem.h>
#include <linux/if_vlan.h>
#include <linux/jhash.h>
#include <linux/module.h>
#include <linux/etherdevice.h>
#include <linux/rtnetlink.h>
#include <linux/sizes.h>
#include <linux/thunderbolt.h>
#include <linux/uuid.h>
#include <linux/workqueue.h>

#include <net/ip6_checksum.h>

#include "trace.h"

/* Protocol timeouts in ms */
#define TBNET_LOGIN_DELAY
#define TBNET_LOGIN_TIMEOUT
#define TBNET_LOGOUT_TIMEOUT

#define TBNET_RING_SIZE
#define TBNET_LOGIN_RETRIES
#define TBNET_LOGOUT_RETRIES
#define TBNET_E2E
#define TBNET_MATCH_FRAGS_ID
#define TBNET_64K_FRAMES
#define TBNET_MAX_MTU
#define TBNET_FRAME_SIZE
#define TBNET_MAX_PAYLOAD_SIZE
/* Rx packets need to hold space for skb_shared_info */
#define TBNET_RX_MAX_SIZE
#define TBNET_RX_PAGE_ORDER
#define TBNET_RX_PAGE_SIZE

#define TBNET_L0_PORT_NUM(route)

/**
 * struct thunderbolt_ip_frame_header - Header for each Thunderbolt frame
 * @frame_size: size of the data with the frame
 * @frame_index: running index on the frames
 * @frame_id: ID of the frame to match frames to specific packet
 * @frame_count: how many frames assembles a full packet
 *
 * Each data frame passed to the high-speed DMA ring has this header. If
 * the XDomain network directory announces that %TBNET_MATCH_FRAGS_ID is
 * supported then @frame_id is filled, otherwise it stays %0.
 */
struct thunderbolt_ip_frame_header {};

enum thunderbolt_ip_frame_pdf {};

enum thunderbolt_ip_type {};

struct thunderbolt_ip_header {};

#define TBIP_HDR_LENGTH_MASK
#define TBIP_HDR_SN_MASK
#define TBIP_HDR_SN_SHIFT

struct thunderbolt_ip_login {};

#define TBIP_LOGIN_PROTO_VERSION

struct thunderbolt_ip_login_response {};

struct thunderbolt_ip_logout {};

struct thunderbolt_ip_status {};

struct tbnet_stats {};

struct tbnet_frame {};

struct tbnet_ring {};

/**
 * struct tbnet - ThunderboltIP network driver private data
 * @svc: XDomain service the driver is bound to
 * @xd: XDomain the service belongs to
 * @handler: ThunderboltIP configuration protocol handler
 * @dev: Networking device
 * @napi: NAPI structure for Rx polling
 * @stats: Network statistics
 * @skb: Network packet that is currently processed on Rx path
 * @command_id: ID used for next configuration protocol packet
 * @login_sent: ThunderboltIP login message successfully sent
 * @login_received: ThunderboltIP login message received from the remote
 *		    host
 * @local_transmit_path: HopID we are using to send out packets
 * @remote_transmit_path: HopID the other end is using to send packets to us
 * @connection_lock: Lock serializing access to @login_sent,
 *		     @login_received and @transmit_path.
 * @login_retries: Number of login retries currently done
 * @login_work: Worker to send ThunderboltIP login packets
 * @connected_work: Worker that finalizes the ThunderboltIP connection
 *		    setup and enables DMA paths for high speed data
 *		    transfers
 * @disconnect_work: Worker that handles tearing down the ThunderboltIP
 *		     connection
 * @rx_hdr: Copy of the currently processed Rx frame. Used when a
 *	    network packet consists of multiple Thunderbolt frames.
 *	    In host byte order.
 * @rx_ring: Software ring holding Rx frames
 * @frame_id: Frame ID use for next Tx packet
 *            (if %TBNET_MATCH_FRAGS_ID is supported in both ends)
 * @tx_ring: Software ring holding Tx frames
 */
struct tbnet {};

/* Network property directory UUID: c66189ca-1cce-4195-bdb8-49592e5f5a4f */
static const uuid_t tbnet_dir_uuid =;

/* ThunderboltIP protocol UUID: 798f589e-3616-8a47-97c6-5664a920c8dd */
static const uuid_t tbnet_svc_uuid =;

static struct tb_property_dir *tbnet_dir;

static bool tbnet_e2e =;
module_param_named(e2e, tbnet_e2e, bool, 0444);
MODULE_PARM_DESC();

static void tbnet_fill_header(struct thunderbolt_ip_header *hdr, u64 route,
	u8 sequence, const uuid_t *initiator_uuid, const uuid_t *target_uuid,
	enum thunderbolt_ip_type type, size_t size, u32 command_id)
{}

static int tbnet_login_response(struct tbnet *net, u64 route, u8 sequence,
				u32 command_id)
{}

static int tbnet_login_request(struct tbnet *net, u8 sequence)
{}

static int tbnet_logout_response(struct tbnet *net, u64 route, u8 sequence,
				 u32 command_id)
{}

static int tbnet_logout_request(struct tbnet *net)
{}

static void start_login(struct tbnet *net)
{}

static void stop_login(struct tbnet *net)
{}

static inline unsigned int tbnet_frame_size(const struct tbnet_frame *tf)
{}

static void tbnet_free_buffers(struct tbnet_ring *ring)
{}

static void tbnet_tear_down(struct tbnet *net, bool send_logout)
{}

static int tbnet_handle_packet(const void *buf, size_t size, void *data)
{}

static unsigned int tbnet_available_buffers(const struct tbnet_ring *ring)
{}

static int tbnet_alloc_rx_buffers(struct tbnet *net, unsigned int nbuffers)
{}

static struct tbnet_frame *tbnet_get_tx_buffer(struct tbnet *net)
{}

static void tbnet_tx_callback(struct tb_ring *ring, struct ring_frame *frame,
			      bool canceled)
{}

static int tbnet_alloc_tx_buffers(struct tbnet *net)
{}

static void tbnet_connected_work(struct work_struct *work)
{}

static void tbnet_login_work(struct work_struct *work)
{}

static void tbnet_disconnect_work(struct work_struct *work)
{}

static bool tbnet_check_frame(struct tbnet *net, const struct tbnet_frame *tf,
			      const struct thunderbolt_ip_frame_header *hdr)
{}

static int tbnet_poll(struct napi_struct *napi, int budget)
{}

static void tbnet_start_poll(void *data)
{}

static int tbnet_open(struct net_device *dev)
{}

static int tbnet_stop(struct net_device *dev)
{}

static bool tbnet_xmit_csum_and_map(struct tbnet *net, struct sk_buff *skb,
	struct tbnet_frame **frames, u32 frame_count)
{}

static void *tbnet_kmap_frag(struct sk_buff *skb, unsigned int frag_num,
			     unsigned int *len)
{}

static netdev_tx_t tbnet_start_xmit(struct sk_buff *skb,
				    struct net_device *dev)
{}

static void tbnet_get_stats64(struct net_device *dev,
			      struct rtnl_link_stats64 *stats)
{}

static const struct net_device_ops tbnet_netdev_ops =;

static void tbnet_generate_mac(struct net_device *dev)
{}

static int tbnet_probe(struct tb_service *svc, const struct tb_service_id *id)
{}

static void tbnet_remove(struct tb_service *svc)
{}

static void tbnet_shutdown(struct tb_service *svc)
{}

static int tbnet_suspend(struct device *dev)
{}

static int tbnet_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(tbnet_pm_ops, tbnet_suspend, tbnet_resume);

static const struct tb_service_id tbnet_ids[] =;
MODULE_DEVICE_TABLE(tbsvc, tbnet_ids);

static struct tb_service_driver tbnet_driver =;

static int __init tbnet_init(void)
{}
module_init();

static void __exit tbnet_exit(void)
{}
module_exit(tbnet_exit);

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();